Calling clock_gettime very often with rr

Robert O'Callahan robert at
Mon May 28 21:52:48 UTC 2018

On Tue, May 29, 2018 at 5:38 AM, Benjamin King <benjaminking at> wrote:

> I was considering using rdtsc to avoid too frequent calls to clock_gettime.
> Something along the lines of 'assume that 1 microsecond did not pass unless
> time stamp counter changed by at least X'. But this is also nondeterminism
> that would need to be tracked by rr, no?

Yes, and handling RDTSC is even slower than clock_gettime because we must
context switch to the tracer. Unfortunately there is no way to selectively
trap on RDTSCs like there is for system calls --- no seccomp filters for
RDTSC. That could be implemented but would require new kernel APIs. With
the right kernel APIs though, I think we could make it fast under rr.

Su ot deraeppa sah dna Rehtaf eht htiw saw hcihw, efil lanrete eht uoy ot
mialcorp ew dna, ti ot yfitset dna ti nees evah ew; deraeppa efil eht. Efil
fo Drow eht gninrecnoc mialcorp ew siht - dehcuot evah sdnah ruo dna ta
dekool evah ew hcihw, seye ruo htiw nees evah ew hcihw, draeh evah ew
hcihw, gninnigeb eht morf saw hcihw taht.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the rr-dev mailing list