jerrinot
jerrinot on Hacker News
Posted by
jerrinot on Thursday October 08, 2026 @10:52AM
from the 0xax.dev dept.
Posted by
jerrinot on Friday May 08, 2026 @03:23AM
from the research.swtch.com dept.
clock_gettime() goes through the vDSO shim, but whether it avoids a syscall depends on the clock ID and (in some cases) the clock source. For thread-specific CPU user time, the vDSO shim cannot resolve the request in user space and must transit into the kernel. In this specific case, there is absolutely a syscall.
You raise a fair point about the percentiles. Those are reported as point estimates without confidence intervals and the implied precision overstates what system clock can deliver.
The mean does get proper statistical treatment (t-distribution confidence interval), but you're right that JMH doesn't compute confidence intervals for percentiles. Reporting p0.00 with three significant figures is ... optimistic.
That said I think the core finding survives this critique. The improvement shows up consistently across ~11 million samples at every percentile from p0.50 through p0.999.
Hi Jonas, thanks for the work on OpenJDK and the post! I swear I hadn't seen your blog :) I finished my draft around Christmas and it’s been in the queue since. Great minds think alike, I guess.
edit: I just read your blog in full and I have to say I like it more than mine. You put a lot more rigor into it. I’m just peeking into things.
In a system with green threads, you typically want the CPU time of the fiber or tasklet rather than the carrier thread. In that case, you have to ask the scheduler, not the kernel.
Courtesy of Brendan Gregg and his flamegraph.pl scripts:
https://github.com/brendangregg/FlameGraphNormally, I use the generator included in async-profiler. It produces interactive HTML. But for this post, I used Brendan’s tool specifically to have a single, interactive SVG.
no problem at all, I was confused too when I saw the profile for the first time.
That's a brilliant trick. The setup overhead and permission requirements for perf_event might be heavy for arbitrary threads, but for long-lived threads it looks pretty awesome! Thanks for sharing!
Only for some clocks (CLOCK_MONOTONIC, etc) and some clock sources. For VIRT/SCHED, the vDSO shim still has to invoke the actual syscall. You can't avoid the kernel transition when you need per-thread accounting.
I was unsure whether to post it or not so I am glad you found it useful!
Fair point. These were run on a standard dev workstation under load, which may account for the noise. I haven't done a deep dive into the outliers yet, but the distribution definitely warrants a more isolated look.
Author here. After my last post about kernel bugs, I spent some time looking at how the JVM reports its own thread activity. It turns out that "What is the CPU time of this thread?" is/was a much more expensive question than it should be.
I have no practical experience with bpftrace, so it did not occur to me. I'll give it a try and perhaps there's gonna be a 2nd part of this investigation.
Wow, someone is actually reading the article in detail, that's a good feeling!
In C, the != operator has higher precedence than the || operator. That said, extra parentheses never hurt readability.
Thanks for the kind words!
Heatmaps are amazing for pattern spotting. I also use them when hunting irregular hiccups or outliers. More people should know about this feature.
Author here. I've always been kernel-curious despite never having worked on one myself. Consider this either a collection of impractical party tricks or a hands-on way to get a feel for kernel internals.
Snowflake did not acquire RP after all.
Posted by
jerrinot on Thursday October 02, 2025 @06:13PM
from the blog.stuffedcow.net dept.
I expect candidates to suggest similar optimisations, but I felt it was unnecessary for the article itself.
That’s a neat trick, albeit with limited applicability given the very narrow range. Thanks for sharing!
That's a very good question. A proper compiler engineer would know, but I will do my best to find something and report back.
Edit: I could not find any pass with a pattern matching to replace CAS loops. The closest thing I could find is this pass: https://github.com/llvm/llvm-project/blob/06fb26c3a4ede66755... I reckon one could write a similar pass to recognize CAS idioms, but its usefulness would be probably rather limited and not worth the effort/risks.
Hi, author here. My superpower is spending unreasonable amounts of time researching things with no practical purpose. Occasionally I blog about it - as a warning to others.
Posted by
jerrinot on Tuesday August 05, 2025 @03:37PM
from the db-grill.com dept.
Posted by
jerrinot on Thursday April 10, 2025 @05:07AM
from the redpanda.com dept.
Posted by
jerrinot on Monday March 24, 2025 @05:43AM
from the vgatherps.github.io dept.
Posted by
jerrinot on Thursday January 11, 2024 @06:42AM
from the werat.dev dept.
Posted by
jerrinot on Wednesday January 10, 2024 @12:10PM
from the google.github.io dept.