Volatile vs Atomic vs Synchronized #1856
-
|
Q: Compare their CPU-level behavior and memory barriers. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
G1 Garbage Collector Uses STW + concurrent phases Z Garbage Collector Fully concurrent, pause ≈ minimal Shenandoah GC Concurrent evacuation Parallel GC Mostly stop-the-world TL;DR: More concurrency → more barriers & CPU cost |
Beta Was this translation helpful? Give feedback.
G1 Garbage Collector
Uses STW + concurrent phases
Heavy write barriers (card marking)
Relies on memory fences for region tracking
Moderate CPU overhead, predictable pauses
Z Garbage Collector
Fully concurrent, pause ≈ minimal
Uses colored pointers + load barriers
Fewer global fences, more per-access checks
Higher CPU cost, super low latency
Shenandoah GC
Concurrent evacuation
Read + write barriers (brooks pointer)
More barrier hits → higher CPU overhead
Low pauses, slightly heavier than ZGC
Parallel GC
Mostly stop-the-world
Minimal barriers (simple write barrier)
Less fence complexity
Best CPU efficiency, worst latency
TL;DR:
More concurrency → more barriers & CPU cost
Less latency → more…