Closed Bug 1688169 Opened 4 years ago Closed 4 years ago

DAMP profiler marker durations are incorrect

Categories

(DevTools :: Framework, defect, P3)

defect

Tracking

(firefox-esr78 unaffected, firefox84 unaffected, firefox85 unaffected, firefox86 wontfix, firefox87 fixed)

RESOLVED FIXED
87 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox84 --- unaffected
firefox85 --- unaffected
firefox86 --- wontfix
firefox87 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

When we started loading damp.js using the BrowserLoader, the performance global in damp.js is no longer in sync with what ChromeUtils.addProfilerMarker uses to compute its duration. This lead to incorrect marker durations in profiles.

We should use Cu.now instead for now.

Florian: In devtools codebase we sometimes get performance globals which are coming a window global, and in that case, the start time we provide seems out of sync with whatever addProfilerMarker uses. Typically, I get around 1 second of extra duration on those markers.

The workaround is easy, we just have to use Cu.now() instead, but it's easy to miss.

I'm not sure what we could do about this? Some ideas:

  • optionally allow the caller to pass the "current time", so that addProfilerMarker can compute the offset
  • split the API in two, with a startMarker and endMarker or something similar?
  • find a way to enforce passing valid (as in, "in sync with Cu.now") timestamps

Not expecting an action for this bug, just wanted to let you know about this small issue with the marker API.

Flags: needinfo?(florian)

Using performance.now will generate incorrect markers because the timestamps are not in sync with the ones used internally by the ChromeUtils.addProfilerMarker API.

(In reply to Julian Descottes [:jdescottes] from comment #1)

Florian: In devtools codebase we sometimes get performance globals which are coming a window global, and in that case, the start time we provide seems out of sync with whatever addProfilerMarker uses.

addProfilerMarker uses a reference for the startTime that depends on the global on which addProfilerMarker was used. When calling from a jsm, Cu.now is correct, when calling addProfilerMarker from a window or worker context, performance.now from the same window global is what should be used.
This is more complicated than I would like, but Cu.now isn't accessible in worker contexts. I was almost tempted to introduce a ChromeUtils.now that would be the same everywhere, but I was afraid introducing yet another 'now' method would cause even more confusion.

Flags: needinfo?(florian)

Thanks for the info!

Set release status flags based on info from the regressing bug 1678550

Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/be98edd5e549 [devtools] Use Cu.now to generate marker timestamps in DAMP r=ladybenko,perftest-reviewers
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch

The patch landed in nightly and beta is affected.
:jdescottes, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(jdescottes)

Only useful for development, wontfix on beta.

Flags: needinfo?(jdescottes)
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: