Closed UndefinedSy closed 8 months ago
not sure if this is by-designed
fast
won't be accurate. IIRC, its difference is unpredictable. And yes, this may lead a problem when consider TTL if it use the fast
function.
Years ago, I had noticed this buggy problem but didn't dive into it, and never have reproduced it ever since.
Yeah you are right. The so called fast version of WallClock is kind of not predictable because of how it works when converting the CPU ticks to realtime duration. It's subject to many aspects including the rdtsc instruction itself, accuracy of the system timer and even system load during caliberation.
So we discourage to use it in some critical situations.
If you are interesting in this issue, you could try out to utilize this kernel module to make the conversion mentioned above more accurate and eliminate the caliberation process.
thx for the prompt reply.
Describe the bug (required) the deviation of the time::WallClock::fastNowInSec() is unpredictable.
I've noticed that on my different machines, the timepoint generated by fastNowInSec is unpredictable. some of the results show that the fastNowInSec is always consistent with the slowNowInSec, the others show that the differences between the two continue to widen. I'm not sure if this will lead to a buggy behavior on the scenario that requires two timepoints to cal the duration. (like TTL or something)
Your Environments (required)
uname -a
g++ --version
orclang++ --version
lscpu
a3ffc7d8
)How To Reproduce(required)
Steps to reproduce the behavior:
running the above code for a period of time, got the following result.
Expected behavior the fast one can be not so precise but the differences should be limited to a predictable range.