I could not reproduce the same time you drift you observed on my machine, so I am guessing the time drift could be worse on certain platforms than others. I also looked into the WaitLatchUs patch proposed by Thomas in [1] and since my system does have epoll_pwait(2) available, I could not achieve the sub-millisecond wait times. A more portable approach which could be to continue using nanosleep and add checks to ensure that nanosleep exists whenever it goes past an absolute time. This was suggested by Bertrand in an offline conversation. I am not yet fully convinced of this idea, but posting the patch that implements this idea for anyone interested in looking. Since sub-millisecond sleep times are not guaranteed as suggested by the vacuum_cost_delay docs ( see below ), an alternative idea is to use clock_nanosleep for vacuum delay when it’s available, else fallback to WaitLatch. "While vacuum_cost_delay can be set to fractional-millisecond values, such delays may not be measured accurately on older platforms” Regards, Sami |
0001-vaccum_delay-with-absolute-time-nanosleep.patch
Description: Binary data