Thread-local byte counting for multi-threaded garbage collection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional garbage collection techniques, especially generational garbage collectors, cause long and unpredictable delays due to the need to suspend normal processing, which is problematic in real-time or interactive systems, and existing pre-tenuring methods face challenges in accurately identifying object allocations for efficient memory reclamation in multi-threaded environments.

Innovation Solution

A modified matrix approach is used where each application thread has an N-entry array for allocated byte counts, allowing local updates without atomic operations or locks, and the allocation code is generated to update thread-local counts, with candidate sites being evaluated for pre-tenuring based on survival rates across collection cycles.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If conventional garbage collection techniques are used to reclaim unused memory, then memory reclamation is achieved, but long and unpredictable delays occur due to suspending normal processing

Engineering Contradiction:
Improvememory reclamationVSAvoidgarbage collection delay
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent divides the heap into multiple segments and uses multiple threads to perform garbage collection simultaneously on different segments. This segmentation allows collection work to be distributed across threads, reducing the time any single thread must be stopped and enabling more concurrent processing of collection tasks.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent performs preliminary actions by identifying candidate allocation sites and pre-calculating their survival rates before actual garbage collection occurs. This preliminary analysis allows the system to pre-determine which objects are likely to survive, enabling more efficient collection decisions when actual collection happens without requiring full suspension of processing.

Inventive Principle:
Principle #10Preliminary action

2Productivity

If pre-tenuring is used to allocate objects directly in old generation, then collection efficiency is improved, but accurate identification of candidate objects in multi-threaded environments becomes difficult

Engineering Contradiction:
Improvecollection efficiencyVSAvoidobject identification complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent segments the object identification process by having each thread maintain its own local data structures for tracking allocation sites and object survival information. This per-thread segmentation avoids the need for complex global synchronization mechanisms while still enabling accurate pre-tenuring decisions for each thread's allocated objects.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent implements local quality by allowing each thread to have its own local counters and data structures for tracking allocation site survival rates. Each thread independently calculates survival rates for objects it allocates, tailoring the identification process to local thread-specific patterns rather than using a one-size-fits-all global approach.

Inventive Principle:
Principle #3Local quality

3Reliability

If atomic operations or locks are used to update byte counts in multi-threaded environment, then thread safety is ensured, but performance penalties increase

Engineering Contradiction:
Improvethread safetyVSAvoidupdate performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent segments the byte count data structure into per-thread local counters, allowing each thread to update its own counters independently without requiring atomic operations or locks. This segmentation eliminates synchronization overhead while maintaining thread safety through data locality.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent extracts the counting functionality from a shared global data structure and places it in thread-local storage. By taking out the counters from the global scope and giving each thread its own local counters, the system eliminates the need for synchronization mechanisms while preserving accurate counting of allocation site bytes per thread.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS7596667B1Method and apparatus for byte allocation accounting in a system having a multi-threaded application and a generational garbage collector that dynamically pre-tenures objects
Publication Date: 2009.09.29 ORACLE AMERICAN INC
  • US7596667B1 patent drawing
  • US7596667B1 patent drawing
  • US7596667B1 patent drawing

AI summary

In a computer system having a multithreaded application and a generational garbage collector that dynamically pre-tenures objects from a predetermined number of candidate allocation sites, allocated byte accounting is performed by each application thread using an array that contains a number of entries equal to the total number of candidate sites at any given time. Each array is indexed by a site number assigned to that site and contains a bytes allocated count for that site. At compilation time, object allocation code that is generated by the compiler is modified to update an array entry associated with a site number that is assigned when the site is selected as a candidate site. Since each array is local to the thread that contains it, each thread can write into its array without using atomic operations or locks.