handystats
handystats copied to clipboard
Handystats cannot be run under strace
Hi,
In order to investigate an issue with some program of ours, we recently had to run "strace" to find out which syscalls were issued. It happens that this is not possible (or not always possible) with a program linking against handystats, because of the initial code which tries to guess the clock speed. More precisely, we do infinite loop here: https://github.com/yandex/handystats/blob/master/src/chrono/tsc_clock.cpp#L159
Strangely, this happens only with strace, not with other "slow" programs like gdb or valgrind. Anyway, this might be an issue in case of investigation. I saw in the git history that you regularly increase this value of CYCLES_DELTA. I am not sure to fully understand the the real logic behind CYCLES_DELTA, but can we implement same kind of maximum try logic ? Something like:
const int CYCLE_DELTA_MAX_RETRY = 10;
//...
for (int i = 1; i <= CYCLE_DELTA_MAX_RETRY; ++i) {
uint64_t tsc1 = get_cycles_count();
*nanoseconds = get_nanoseconds();
uint64_t tsc2 = get_cycles_count();
if (tsc2 - tsc1 < CYCLES_DELTA || i == CYCLE_DELTA_TRESHOLD_MAX_RETRY) {
*cycles_count = tsc1 + (tsc2 - tsc1) / 2;
break;
}
}
Or remove entirely this CYCLE_DELTA logic and always use tsc1 + (tsc2 - tsc1) / 2
?
Cheers, Romain