Closed Bug 1412319 Opened 2 years ago Closed 2 years ago
Rules Have Source slowness
Attached is a perf.html profile I recorded on a local FF58 build. In that build, I have added a custom user-timing that shows how much time the selection of a new node using the context-menu item takes. It makes it quite easy to investigate what code runs during that time and what takes the longest. Among these things, the function allRulesHaveSource seems to be taking quite a long time. Here is the function: http://searchfox.org/mozilla-central/rev/40e8eb46609dcb8780764774ec550afff1eed3a5/devtools/server/actors/stylesheets.js#219-241 Its role is to make sure all rules inside a given stylesheet actually have an authored source. This is useful to detect whether some dynamic changes to the stylesheet were done using the CSS Object-Model API. To do this, the function loops over each and every rule in the stylesheet (sheet.cssRules), and calls DOMUtils.getRelativeRuleLine on them. Let's investigate the impact this is having and how to make it faster.
Here is a test: - open www.lemonde.fr - select 10 different elements on the page - measure the time each of these take - remove the highest value - and calculate the average. On my (powerful) machine: -> 430ms on average. I then added an early `return true` at the top of the allRulesHaveSource function and re-did the same test: -> 326ms on average. So there are some wins to be have by optimizing this function.
In bug 1415940, we discovered this check no longer works correctly in Stylo mode. In Stylo, `DOMUtils.getRelativeRuleLine` can still return a value even with CSSOM changes.
Another website where allRulesHaveSource has a significant impact on the inspector initialization. url: https://www.xome.com/Listing/ListingSearch.aspx profile: https://perfht.ml/2kxHLCp
After bug 1415940, allRulesHaveSource is gone, and the new API is much faster - so this can probably be closed now.
Thanks for the ping, let's close this now that the method has been removed. Did a quick profile again on the sites mentioned here and couldn't see any significant slowdown.
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1415940
You need to log in before you can comment on or make changes to this bug.