base: fdReady(): Improve accuracy an simplify code.

Authored by nh2 on Sep 14 2017, 8:48 AM.



This is done by reusing the existing cross-platform
getProcessElapsedTime() function, which already provides
nanosecond monotonic clocks, and fallback for platforms that
don't have those.

To do this, getProcessElapsedTime() had to be moved from
a private RTS symbol into the public interface.

Accuracy is improved in 2 ways:

  • Use of the monotonic clock where available
  • Measuring the total time spent waiting instead of a sum of intervals (between which there are small gaps)

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
nh2 created this revision.Sep 14 2017, 8:48 AM
bgamari requested changes to this revision.EditedSep 14 2017, 9:27 AM

What happens in the case of wrap-around? A comment is probably in order here.

This revision now requires changes to proceed.Sep 14 2017, 9:27 AM
nh2 added a comment.Sep 14 2017, 12:02 PM

What happens in the case of wrap-around? A comment is probably in order here.

A 49-day wraparound cannot happen (this one we are talking about) because the code path that enabled that in the past is dead, because it could only happen on Windows older than XP and we don't even support XP any more.

I have filed to remove the code path in question, and added a commit via before this commit that explains this in the code of getMonotonicNSec().

bgamari accepted this revision.Sep 19 2017, 2:07 PM

Alright, with the wraparound issue taken care of I think this is fine.

This revision is now accepted and ready to land.Sep 19 2017, 2:07 PM
bgamari added inline comments.Sep 19 2017, 2:55 PM

In general when you export a symbol from the RTS you need to add it to the list in rts/RtsSymbols.c. I'll do this for you when I merge.

This revision was automatically updated to reflect the committed changes.