Antoine Pitrou <pit...@free.fr> added the comment:

Regarding the calibrating loop when using ASM timestamp counters, there's one 
problem if the thread gets preempted in the middle of the loop: the calibration 
will return incorrect results. Perhaps a way of avoiding this would be to call 
nanosleep(1 ns) just before the loop, which should relinquish the current 
timeslice.

Another issue can appear when threads migrate from one CPU core to another, 
according to Wikipedia: “AMD processors up to the K8 core always incremented 
the time-stamp counter every clock cycle.[5] Thus, power management features 
were able to change the number of increments per second, and the values could 
get out of sync between different cores or processors in the same system.”

Perhaps using clock_gettime(CLOCK_REALTIME or CLOCK_MONOTONIC) is better than 
using raw ASM timestamp counters, when available.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue2281>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to