Bug 1546513 Comment 7 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Notes from my analysis:

tldr: `mozSetImageElement` might not be a good way to draw the waterfall lines, due to the expensive teardown (or it can be optimized).

Rapid closing and opening With mozSetImageElement reset: https://perfht.ml/2ZRalTe and without: https://perfht.ml/2UYMAFb

Patterns are pretty similar and I can not see any leakage – because the second set of profiles show that the expensive `nsINode::RemoveMutationObserver` is executed no matter what as it is part of the document teardown: Closing a long list with reset: https://perfht.ml/2ZU62GO and without: https://perfht.ml/2ZR8AFw (both 2s+)

What would be using mutation observers – DevTools does not depend on them. `mozSetImageElement` seems to add mutation observers to the element and/or the canvas, as closing without use of that method is instant: https://perfht.ml/2ZTdJg3
Notes from my analysis:

tldr: `mozSetImageElement` might not be a good way to draw the waterfall lines, due to the expensive teardown (or it can be optimized).

Rapid closing and opening With mozSetImageElement reset: https://perfht.ml/2ZRalTe and without: https://perfht.ml/2UYMAFb

Patterns are pretty similar and I can not see any leakage – because the second set of profiles show that the expensive `nsINode::RemoveMutationObserver` is executed no matter what as it is part of the document teardown: Closing a long list with reset: https://perfht.ml/2ZU62GO and without: https://perfht.ml/2ZR8AFw (both 2s+)

What would be using mutation observers – DevTools does not depend on them. `mozSetImageElement` seems to add mutation observers to the element and/or the canvas, as closing without use of that method is instant: https://perfht.ml/2ZTdJg3

–––

Performance panel uses the same `-moz-element` technique but does not re-use the same `Canvas` instance, creating a new instance for every background update: https://searchfox.org/mozilla-central/source/devtools/client/performance/modules/waterfall-ticks.js#59

This spreads a massive overhead of `RemoveMutationObserver` across every update when used in the Network panel: https://perfht.ml/2ZOr7lK . Strangely enough, `RemoveMutationObserver` does not show up when profiling the *Performance* panel: https://perfht.ml/2ZQJRRw .

The different is that the `-moz-element` CSS is applied to *every* resource row with the `requests-list-waterfall` class; so every element gets an observer. In the Performance panel on the other side, the styling is applied to an infinite scrolling table, and only ever uses and recycles a few dozen rows.

Back to Bug 1546513 Comment 7