Closed Bug 1497018 Opened 6 years ago Closed 6 years ago

Tracelogger: use a monotonic clock to record timestamps

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox64 --- wontfix
firefox65 --- fixed

People

(Reporter: denispal, Assigned: denispal)

References

Details

Attachments

(1 file, 1 obsolete file)

Tracelogger currently uses rdtsc whenever possible. However, this records cycles which can vary from machine to machine and is also susceptible to being throttled. The timestamps need to be recorded using a monotonic clock so that they can line up properly with the profiler samples and markers.
Priority: -- → P2
Blocks: 1501377
Attached file Use a monotonic clock for tracelogger timestamps (obsolete) (deleted) —
Tracelogger events need to be timestamped by a monotonic clock so that these events can line up with the gecko profiler start time. The idea here is to continue using rdtsc if the CPU supports an invariant TSC (which is true for most modern x86 processors), and interpolate these values to the values from mozilla::TimeStamp. If the CPU does not support an invariant TSC, then just fall back to mozilla::TimeStamp for timekeeping.
Attachment #9019563 - Attachment is obsolete: true
I think the best approach right now is to use mozilla::TimeStamp for timing in the tracelogger. This already uses nanosecond timing on OSX, Linux, and Windows through mach_absolute_time, clock_gettime, and QueryPerformanceCounter respectively, and in practice is actually quite fast. The biggest overhead is on Windows of about 3-4%. For Linux, it is around 2%. Ultimately, we should use redesign this so that we're using rdtscp whenever an invariant TSC is supported. However, I need to test this thoroughly on all 3 platforms so I would prefer to defer that in a follow up bug once the new tracelogger implementation is landed for use.
Switch over to mozilla::TimeStamp for timing. This should use clock_gettime, mach_absolute_time, ,and QueryPerformanceCounter timing implementations on Linux, OSX, and Windows which are all very efficient. It increases overhead a little bit, but allows for synchronization across cores and the profiler, and is portable. Longer term solution should be to move over to rdtscp for timing.
Keywords: checkin-needed
Pushed by apavel@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/713199b324b4 Use mozilla::TimeStamp for tracelogger timing r=sfink
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: