Uppsats

Optimising Weak Reference Processing in HotSpot's Z Garbage Collector : Reference Pipeline Optimisations and an Exploratory Weak-Field Mechanism for HotSpot

Yrkesexamen på avancerad nivå

Uppsala universitet/Datalogi

Publicerad: 2026

Språk: Engelska

Sammanfattning

In Java, weak references are a non-trivial source of garbage collection overhead in workloads where objects frequently become weakly reachable. In the Z Garbage Collector (ZGC), all discovered weak references follow the same processing pipeline regardless of whether they are associated with a ReferenceQueue. For references that are never registered with a queue this leads to unnecessary pending-list and enqueue-path work. This thesis investigates whether targeted modifications to ZGC's reference-processing pipeline can reduce this overhead, and whether representing weak semantics directly in object fields rather than through separate WeakReference objects can reduce overhead further. Three orthogonal pipeline optimisations for queue-less WeakReference processing were implemented in an OpenJDK research fork: a skip-enqueue separation that routes queue-less weak references to a separate discovered list, bypassing the pending list entirely, a dynamic-array representation that replaces the intrusive linked list used during reference discovery to improve traversal locality, and a specialised clear path that removes unnecessary per-reference CAS operations. In addition, an exploratory weak-field mechanism was implemented through a Java field annotation and corresponding ZGC VM support, enabling a representation-level comparison under the same experimental setup. The implementations were evaluated using synthetic microbenchmarks executed on a supercomputer cluster with 250 repeated runs per variant. Two benchmark designs were used: a single-object stress benchmark that concentrates the entire weak-reference load into one GC cycle, and a multi-object benchmark that releases references gradually across five GC cycles. The results show that combining the specialised clear path with the dynamic array is the most effective pipeline configuration. In the single-object benchmark, this combination reduces median non-strong reference-processing time by 81% and median major-collection time by 8%. In the multi-object benchmark, the non-strong subphase reduction is 57%, while the end-to-end major-collection gain is 1.1%. Dynamic-array variants incur substantially higher auxiliary garbage collector (GCr) memory than the linked-list baseline. The combination of all three optimisations together, skip-enqueue separation, dynamic array, and specialised clear path, offers the best balance: it matches the same 81% reduction in non-strong processing time whilst consuming approximately 30% less auxiliary GCr memory than the clear-path-plus-array pair alone. The weak-field mechanism achieves substantially lower major-collection times than all WeakReference pipeline variants, with reductions of 41% in the single-object benchmark and 28% in the multi-object benchmark relative to the baseline. Its advantage is structural: by eliminating WeakReference wrapper objects from the heap entirely, it reduces the total volume of GC work across all phases of the collection cycle, not only during reference processing. This comes at a significant implementation cost: the weak-field prototype spans 27 files across the compiler, class-file parser, interpreter, JIT compilers, JVMTI, and GCr subsystems. Together, the results suggest that, within the evaluation setting of queue-less synthetic workloads on a single hardware platform, the choice of how weak semantics is represented in the language has a larger impact on total GC cost than pipeline-level optimisations. These findings indicate that meaningful improvements in workloads of this kind may require reconsidering how weak semantics is encoded in the language rather than only refining the processing pipeline, though how this conclusion generalises to production workloads with diverse reference patterns and multiple hardware platforms remains an open question.

Information

Lärosäte / institution
Uppsala universitet/Datalogi
Publiceringsdatum
2026
Uppsatstyp
Yrkesexamen på avancerad nivå
Språk
Engelska

Utforska vidare

Liknande uppsatser

Uppsatser med liknande ämnen och nyckelord.