Apparently on EC2, the gettimeofday
syscall can't use the vDSO mechanism as it would on bare metal.
https://blog.packagecloud.io/eng/2017/03/08/system-calls-are-much-slower-on-ec2/
In my application, I'm using gettimeofday
to measure time elapsed for runtime metrics. The application is otherwise quite optimized, and these syscalls are adding up to a significant cost.
Given that it's not necessary to get an actual time but just an elapsed time delta, is there some other mechanism by which the elapsed time could be obtained which does not require a syscall? And preferably, one which does not involve changing a system-wide setting which may compromise the time source for the rest of the system?