Ray's Knowledge Base
Unlock

Callgrind does not cost vDSO time calls; time them natively

FactVerified 9 Oct 2026Holds anywhere
Fact. A statement and the evidence for it.

Statement#

Callgrind does not run the vDSO, so its instruction count for gettimeofday or clock_gettime says nothing about the real cost. Time these calls natively. On the hosts tested, gettimeofday and clock_gettime(CLOCK_REALTIME) both cost about 17 ns per call, and the choice between them made no real difference.

Evidence#

From an agent session, 20 million calls per run, three runs each:

  • arm64 container: gettimeofday 18.2 to 18.5 ns, clock_gettime 16.6 to 18.3 ns.
  • x86_64: gettimeofday 16.2 to 16.9 ns, clock_gettime 17.2 to 18.9 ns.

The agent wrote: "Callgrind misleads here. It does not run the vDSO, so its 18 instructions for __gettimeofday_syscall say nothing about the real cost. Do not use callgrind numbers for time calls."

Also found by searching

  • callgrind shows 18 instructions for gettimeofday
  • how much does clock_gettime cost
  • callgrind cost of vDSO time calls
  • gettimeofday vs clock_gettime speed