Plugin makes 6 extra syscalls for every "gettimeofday" call #3227
Labels
Tag: Performance
Related to improving shadow's run-time
Type: Enhancement
New functionality or improved design
Whenever glibc tries to get the time, it seems to try to get timezone information first. It does this by reading "/etc/localtime", and in Shadow we handle this as a special-case that returns data from "/usr/share/zoneinfo/UTC" instead. This results in a lot of unnecessary extra syscalls. Every
gettimeofday()
call (which tor makes a lot of) results in several syscalls trying to mmap this file. All of the syscalls below (including thereadlink
) are related to the followinggettimeofday
sycall. These same syscalls are repeated every time that the plugin gets the current time.On my local machine, this only happens in tgen processes and not tor processes. On the benchmark runner, it seems to also happen for tor processes.
A workaround is to set the
TZ=:/usr/share/zoneinfo/UTC
environment variable for all processes. See https://blog.packagecloud.io/set-environment-variable-save-thousands-of-system-calls/. Then we get only:without any of the other syscalls above.
I'm not sure why glibc is doing all of this extra work, and how we can properly avoid it without requiring the user to configure an environment variable. We could maybe add the environment variable automatically, but that's not really a nice solution.
The text was updated successfully, but these errors were encountered: