Commit 9e6fdd0
huangjun
[bvar] fix sampler interval after switch to cpuwide_time_ns
Commit 12fb539 ("Use monotonic time instead of wall time", #3268)
switched the three time-source calls in
SamplerCollector::run() from gettimeofday_us() (microseconds) to
cpuwide_time_ns() (nanoseconds), but left the 1-second offset constant
and the usleep() call untouched. As a result:
- abstime += 1000000L now adds 1 ms instead of 1 s, so the sampler
spins at ~1 kHz instead of 1 Hz;
- usleep(abstime - now) is passed a nanosecond delta that usleep()
interprets as microseconds, which further distorts the sleep.
Fix by using a 1-second offset expressed in nanoseconds and by
converting the nanosecond delta to microseconds before handing it to
usleep().
Fixes #3277.1 parent 35682ff commit 9e6fdd0
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
0 commit comments