Per-Thread Garbage Collection with No-Read-No-Write Safepoints
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing garbage collection methods require all application threads to suspend during the stop-the-world phase, even if some threads do not interact with the memory heap, leading to performance bottlenecks in applications like microservices.
Innovation Solution
Implementing a static compiler to identify code regions that do not read or write to the memory heap and transition these threads to a no-read-no-write state, allowing them to continue execution during garbage collection, while suspending threads that do interact with the heap.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If all threads are suspended during stop-the-world garbage collection, then memory heap integrity is ensured, but application performance deteriorates due to unnecessary suspension of threads that do not interact with the heap
Solution Approach 1:
The patent segments threads into two categories: those that interact with the memory heap and those that do not. By dividing the thread set based on their memory access patterns, the system can apply different suspension policies to different segments, allowing non-heap-interacting threads to continue execution while heap-interacting threads are suspended for garbage collection.
Solution Approach 2:
The patent applies different quality states to different threads based on their local characteristics (whether they interact with the memory heap). Threads are marked with quality indicators that reflect their memory access behavior, enabling the garbage collection mechanism to selectively suspend only those threads with heap interaction, thereby maintaining heap integrity while preserving performance of non-interacting threads.
2Productivity
If thread state tracking and classification mechanisms are implemented, then selective thread suspension during garbage collection is enabled, but system complexity increases due to additional bookkeeping requirements
Solution Approach 1:
The patent performs preliminary classification of threads into heap-interacting and non-heap-interacting categories before garbage collection begins. By pre-marking threads with quality indicators that reflect their memory access patterns, the system prepares the thread state information in advance, eliminating the need for complex real-time analysis during garbage collection and reducing overall system complexity.
Data Source
AI summary
Managing per-thread stop-the-world garbage collection is provided. A set of threads of a plurality of threads is transitioned from a normal thread state to a no-read-no-write thread state at a first safepoint of a pair of contiguous safepoints using a first set of thread transition code inserted in program code of an application at the first safepoint. Execution of any remaining threads of the plurality of threads having a normal thread state is suspended at the first safepoint. Stop-the-world garbage collection of a memory heap dedicated to the application is performed while allowing the set of threads of the plurality of threads having the no-read-no-write thread state to continue execution in a region within the program code between the pair of contiguous safepoints based on a special status tag of the first safepoint of the pair of contiguous safepoints.


