Tagged articles
Safepoint
12 articles · Page 1 of 1
This article explores the puzzling "prevent gc" comment in RocketMQ source code, explains how Thread.sleep(0) interacts with JVM safepoints, distinguishes counted and uncounted loops, and demonstrates practical experiments that reveal why altering loop variables can change GC behavior.
GCJVMJava
0 likes · 12 min read


ITPUBDec 30, 2024 · Fundamentals
The article investigates a mysterious "prevent gc" comment in RocketMQ's source, explains how Thread.sleep(0) forces a JVM safepoint to mitigate long GC pauses, and demonstrates that changing loop counters from int to long eliminates the need for the hack.
Counted LoopGCJVM
0 likes · 22 min read

This article explains the internal mechanisms of JVM garbage collection, covering oopMap, safepoints, saferegions, three‑color marking, memory sets, write barriers, and the design of low‑latency collectors such as Shenandoah and ZGC, and provides practical tuning advice.
JVMSafepointShenandoah
0 likes · 17 min read

This article investigates the mysterious "prevent gc" comment in RocketMQ source code, explains how Thread.sleep(0) interacts with JVM safepoints and counted loops, and demonstrates practical fixes by changing loop indices or inserting explicit safepoint calls.
GCJavaRocketMQ
0 likes · 13 min read

JVM safepoints are pause points where the VM can stop all threads for operations like garbage collection; the article shows how counted loops can prevent threads from reaching safepoints, causing unexpected long sleeps, and explains tuning flags, loop‑counter changes, and best practices to avoid STW pauses.
JVMJavaSafepoint
0 likes · 18 min read

This article explains how JIT compilation can eliminate safepoint polls in hot loops, causing unexpected thread blocking, and demonstrates how to reproduce, verify, and resolve the issue using JITWatch and JVM options.
JITJVMJava
0 likes · 20 min read

This article examines a puzzling 'prevent gc' comment in RocketMQ source, explains how inserting Thread.sleep(0) creates a JVM safepoint to avoid long GC pauses, explores counted vs uncounted loops, and demonstrates practical code modifications to improve performance.
JVMJava performanceRocketMQ
0 likes · 13 min read

This article investigates the mysterious Thread.sleep(0) call found in RocketMQ source, explaining how it interacts with JVM safepoints, why it appears in counted loops, and how changing loop indices from int to long can avoid long stop‑the‑world pauses, backed by code examples and references.
JVMJavaRocketMQ
0 likes · 12 min read

This article examines the puzzling 'prevent gc' comment and Thread.sleep(0) call in RocketMQ’s source, explains how it leverages JVM safepoint mechanics to trigger garbage collection, discusses counted vs uncounted loops, and demonstrates practical code modifications to improve performance.
GCJavaRocketMQ
0 likes · 13 min read

This article details a systematic investigation of various backend performance problems—including CMS GC delays, biased‑lock revocation, Netty worker thread blocking, and log‑framework overhead—provides root‑cause analysis, JVM tuning parameters, and practical recommendations to mitigate latency spikes in production services.
BackendJVMNetty
0 likes · 16 min read

A detailed investigation of a slow Elasticsearch cluster revealed that massive Stop‑The‑World (STW) safepoint pauses caused by a buggy ARM‑based JDK version were the root cause, and switching to a proper Kona JDK eliminated the frequent ForceSafepoint interruptions and restored performance.
ElasticsearchGCJVM
0 likes · 15 min read

After weeks of investigation, this post details how intermittent request timeouts in a high‑concurrency Java service were traced to frequent JVM stop‑the‑world pauses caused by GC, safepoint logging, biased lock revocation, and Log4j2’s synchronous logging, and outlines the steps taken to diagnose and resolve the issue.
BTraceGCJava
0 likes · 10 min read
