Performance.mark/measure/clearMarks take a long time to execute
Categories
(Core :: DOM: Performance APIs, defect)
Tracking
()
People
(Reporter: henry.fai.hang.chan, Assigned: alexical)
References
(Depends on 1 open bug)
Details
Attachments
(4 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0
Steps to reproduce:
Performance.mark/measure takes a long time to execute. Profiling shows that it takes up to 50% of the whole re-render when using vue with performance tracking turned on.
| Reporter | ||
Comment 1•2 years ago
|
||
| Reporter | ||
Comment 2•2 years ago
|
||
As per the marker chart, even though a large amount of markers are being set and unuset, it appears there are only 7 markers active at one point in time. Since vue is one of the more popular frameworks used by websites, it may be worth optimizing for it.
Comment 3•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Performance' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•2 years ago
|
Comment 4•2 years ago
|
||
The severity field is not set for this bug.
:fdoty, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 5•2 years ago
|
||
Placing this bug into triage prior to setting severity
Comment 6•2 years ago
|
||
The severity field is not set for this bug.
:fdoty, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 7•2 years ago
|
||
It would be great if you could upload the actual profile and put a link here! That will allow us to investigate more easily. As well as allow us to see the c++ portions of the stacks here.
Comment 8•2 years ago
|
||
Awaiting a profile to review before setting severity
| Assignee | ||
Comment 9•2 years ago
|
||
Closing as inactive waiting for profile.
| Reporter | ||
Comment 10•2 years ago
|
||
The profile I've taken may have some sensitive info. Is there someone I can directly mail this file to?
Updated•2 years ago
|
| Assignee | ||
Comment 11•1 year ago
|
||
Sorry for the delay! henryfhchan, could you email this to dothayer@mozilla.com?
Updated•1 year ago
|
| Assignee | ||
Comment 13•1 year ago
|
||
Basically we were falling off a cliff where if we had a bunch of marks recorded
with a particular name, when trying to measure we would fill an array with all
of them only to return the last one. This just replaces that by iterating in
reverse and returning the first matching mark. Arguably we should be using a
hashmap or something here, but this is a quick and trivial improvement that I
think will resolve the reported issue.
Updated•1 year ago
|
Comment 14•1 year ago
|
||
Comment 15•1 year ago
|
||
| bugherder | ||
| Assignee | ||
Comment 16•1 year ago
|
||
Henry, could you give this a try on the latest version of Nightly? I'm not sure if the patch resolved the performance problem you observed since I don't have a specific example page, but based on your profile I think it should.
| Reporter | ||
Comment 17•1 year ago
|
||
I'm still seeing clearPerformanceMark take a huge chunk of time on 124.0a1 (2024-01-26) (64-bit) (a412d893c38f632f34b44a9c5b3fd8cc30bb87be). I'll send you the updated stack trace.
| Reporter | ||
Comment 18•1 year ago
|
||
- Performance.measure() has a drastic improvement such that it no longer appears in the profile. However, Performance.clearMarks() still takes up quite a significant chunk of time. This was tested on 124.0a1 (2024-01-26) (64-bit) on macOS mbp with commit a412d893c38f632f34b44a9c5b3fd8cc30bb87be.
An updated profile has been sent. Many thanks for your assistance!
| Assignee | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 19•1 year ago
•
|
||
Hi Alex -- YouTube seems to be running into this in ESR 115, possibly due to a recent change on their side to use the associated APIs more aggressively (or with redundant names?). They might work around it, but for now this is pretty painful for ESR users.
Here are two profiles that I just captured in ESR115, which show massive time (40 seconds / 85 seconds respectively) spent in Performance.measure():
https://share.firefox.dev/3AIlAUQ
https://share.firefox.dev/3AEXrOV
...vs. Firefox 128 release which spends barely any time (228 samples i.e. 0.228 seconds, over the whole profile) in Performance.measure
https://share.firefox.dev/3T3kHwr
Given how targeted the patch is and the potential perf wins, maybe worth nominating for uplifting to ESR?
Comment 20•1 year ago
|
||
(We've got word from YouTube folks that they're rolling back the change that made them trip over this, so that reduces the pressure here a bit, but still worth considering for uplift if it's a safe change that avoids a pitfall that sites are sometimes tripping over.)
| Assignee | ||
Comment 21•1 year ago
|
||
Comment on attachment 9376160 [details]
Bug 1811750 - Eliminate redundant array filling in performance.measure r?baku
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: This was producing substantial slowdowns on YouTube with a recent change they made. They rolled back their change, but this could be affecting other sites similarly.
- User impact if declined: Slowness on sites which make heavy use of
performance.measure - Fix Landed on Version: 124
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): It's an incredibly small patch which has been live for many months now, and all it does is remove purely redundant work which makes no behavioral difference other than slowing the browser down.
| Assignee | ||
Comment 22•1 year ago
|
||
Resolving the bug and creating follow-ups for additional work, to simplify tracking.
Updated•1 year ago
|
Comment 23•1 year ago
|
||
Comment on attachment 9376160 [details]
Bug 1811750 - Eliminate redundant array filling in performance.measure r?baku
Uplift approved for ESR 115. I am checking with QA if we have time to respin and revalidate our 115.15.0 build with this patch before we ship it next Tuesday.
Comment 24•1 year ago
|
||
| uplift | ||
Description
•