Re:A 40-line fix eliminated a 400x performance gap
by higherhalf on Tuesday January 13, 2026 @07:41PM
(#46610784)
clock_gettime() goes through vDSO, avoiding a context switch. It shows up on the flamegraph as well.
[ Parent
| on HN ]
Re:A 40-line fix eliminated a 400x performance gap
by jerrinot on Tuesday January 13, 2026 @07:47PM
(#46610840)
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.
Re:A 40-line fix eliminated a 400x performance gap
by higherhalf on Tuesday January 13, 2026 @08:32PM
(#46611200)
Thanks, I really should've looked deeper than that.
Re:A 40-line fix eliminated a 400x performance gap
by jerrinot on Tuesday January 13, 2026 @08:35PM
(#46611228)
no problem at all, I was confused too when I saw the profile for the first time.
Re:A 40-line fix eliminated a 400x performance gap
by touisteur on Wednesday January 14, 2026 @02:48AM
(#46613421)
Oh for some time after its introduction, CLOCK_MONOTONIC_RAW wasn't vDSO'd and it took some time and syscall profiling ('huh, why do I see these as syscalls in perf record -e syscalls' ...) to understand what was going on.
Re:A 40-line fix eliminated a 400x performance gap
by ot on Tuesday January 13, 2026 @07:48PM
(#46610846)
If you look below the vDSO frame, there is still a syscall. I think that the vDSO implementation is missing a fast path for this particular clock id (it could be implemented though).
Re:A 40-line fix eliminated a 400x performance gap
by jerrinot on Tuesday January 13, 2026 @07:49PM
(#46610854)
Exactly this.
Re:A 40-line fix eliminated a 400x performance gap
by a-dub on Tuesday January 13, 2026 @07:47PM
(#46610835)
edit: agh, no. CLOCK_THREAD_CPUTIME_ID falls through the vdso to the kernel which makes sense as it would likely need to look at the task struct.
here it gets the task struct: https://elixir.bootlin.com/linux/v6.18.5/source/kernel/time/... and here https://elixir.bootlin.com/linux/v6.18.5/source/kernel/time/... to here where it actually pulls the value out: https://elixir.bootlin.com/linux/v6.18.5/source/kernel/sched...
where here is the vdso clock pick logic https://elixir.bootlin.com/linux/v6.18.5/source/lib/vdso/get... and here is the fallback to the syscall if it's not a vdso clock https://elixir.bootlin.com/linux/v6.18.5/source/lib/vdso/get...