Garbage Collection Stack Scanning Optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In modern Java processing systems, the increasing number of threads and stack frames in large-scale applications leads to a significant overhead in stack scanning during garbage collection (GC), particularly in generational GC, as conventional techniques fail to effectively reduce the time taken by stack scanning.

Innovation Solution

Implementing a method that uses a scanning unnecessary area starting pointer and a nursery object reference list for each thread to limit stack scanning to only the top stack frames that reference nursery objects, thereby reducing the area that needs to be scanned in subsequent GC cycles.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If stack scanning is performed on the entire stack area to ensure all nursery objects are detected, then the reliability of garbage collection is improved, but the time taken by stack scanning increases significantly

Engineering Contradiction:
Improvenursery object detection accuracyVSAvoidstack scanning time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent divides the stack scanning task into two segments: (1) scanning the entire stack once to build a reference list of nursery objects, and (2) scanning only the portion of the stack above the highest referenced nursery object in subsequent GC cycles. This segmentation allows the system to avoid redundant scanning of lower stack portions while maintaining complete nursery object detection.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary stack scanning to identify and record all nursery object references before subsequent garbage collection cycles. By pre-building a reference list during the first scan and storing the highest reference position, the system eliminates the need to re-scan the same stack portions, significantly reducing time in subsequent GC operations while preserving detection accuracy.

Inventive Principle:
Principle #10Preliminary action

2Adaptability or versatility

If the number of threads and stack frames is increased to support large-scale applications, then the adaptability of the system is improved, but the stack scanning overhead increases

Engineering Contradiction:
Improvesupport for large-scale applicationsVSAvoidstack scanning overhead
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The patent applies segmentation by dividing the stack scanning workload based on nursery object reference positions. Instead of scanning the entire stack of every thread uniformly, the system segments the scanning range to only include portions above the highest nursery object reference, reducing overhead proportional to the number of threads and stack frames.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system implements self-service by having each thread's stack scanning automatically optimized based on its own nursery object reference patterns. The highest reference position is tracked per-thread, allowing each thread's stack to be scanned only to the necessary extent, making the system adaptable to varying thread counts and stack depths without linearly increasing overhead.

Inventive Principle:
Principle #25Self-service

3Device complexity

If conventional garbage collection techniques are used without optimization, then the device complexity is kept simple, but the productivity of garbage collection is reduced

Engineering Contradiction:
ImproveGC implementation simplicityVSAvoidgarbage collection speed
Core Design Contradiction:
Device complexityVSProductivity

Solution Approach 1:

The patent introduces a preliminary stack scanning phase that builds a reference list of nursery objects and determines the highest reference position. This preliminary action enables subsequent GC cycles to skip redundant scanning, significantly improving GC speed while adding only moderate complexity through the reference list data structure and highest position tracking.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces an intermediary mechanism (the reference list and highest nursery object position tracker) that mediates between the simple conventional GC approach and the need for faster performance. This intermediary stores scanning results and uses them to optimize subsequent scans, achieving productivity improvement with controlled complexity increase.

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS11314640B2Method, program, and system for reducing the cost of stack scanning
Publication Date: 2022.04.26 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US11314640B2 patent drawing
  • US11314640B2 patent drawing
  • US11314640B2 patent drawing

AI summary

A method for reducing the cost of stack scanning in garbage collection (GC) includes, in the GC of the first-generation heap area, registering, in a nursery object reference list prepared for each thread, one or more addresses, within each stack, which each refer to a nursery object, and updating a scanning unnecessary area starting pointer such that the addresses listed in the nursery object reference list are included in the area from the bottom of the stack to the address pointed to by the scanning unnecessary area starting pointer. The method further includes, in the next GC of the first-generation heap area, for the area from the bottom of the stack to the address pointed to by the scanning unnecessary area starting pointer, performing the GC processing on the addresses included in the nursery object reference list.