A lot of time is spent in AddRef / Release during button.click() / checkbox.click(), especially when clearing the event target chain
Categories
(Core :: DOM: Events, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox120 | --- | fixed |
People
(Reporter: mstange, Assigned: smaug)
References
(Blocks 2 open bugs)
Details
(Keywords: perf-alert, Whiteboard: [sp3])
Attachments
(7 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
The testcases in bug 1834003 spend a fair amount of time calling AddRef and Release on cycle collected objects. https://share.firefox.dev/3DaKDxI
The biggest offender is nsTArray<EventTargetChainItem>::ClearAndRetainStorage. This function is called four times in total per call to .click(), probably with identical event target chains: For click, DOMActivate, input and change. It spends all its time calling virtual Release methods which spend their time in nsCycleCollectingAutoRefCnt::decr.
Updated•2 years ago
|
| Assignee | ||
Comment 1•2 years ago
|
||
Yes. We need to keep the event targets alive, so the chain must have strong references. And yes, in these particular test cases the chain might be the same but in general it isn't. The spec requires us to have separate event path (== chain) for each event.
But we should make AddRef/Release non-virtual in this case. Non-trivial change, since it requires moving refcnt to EventTarget, and some EventTargets use mRefCnt.incr/decr<NS_CycleCollectorSuspectUsingNursery>, and some mRefCt.incr/decr<NS_CycleCollectorSuspect3>.
The nursery is available on the main thread only currently, because accessing it was tried to be as fast as possible.
Another thing we could do in these nested events case is that there could be a flag (there should be space for one flag in nsWrapperCache's flags) whether the target is currently part of an event chain, and if so, we can use raw pointers in the nested chains. Not sure if that would help much though if we make AddRef/Release non-virtual.
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 2•2 years ago
|
||
The preliminary results look quite good
https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=try&newProject=try&newRevision=2cfd6144f271283f6a6964bcf50efcd7770a3d11&originalSignature=4586009&newSignature=4586009&framework=13&application=firefox&originalRevision=17fc117158fff8225831b449e60c3308c5c69951&page=1&showOnlyConfident=1
Svelte test for example spends lots of time in event dispatch
| Assignee | ||
Comment 3•2 years ago
|
||
| Assignee | ||
Comment 4•2 years ago
|
||
Depends on D187146
| Assignee | ||
Comment 5•2 years ago
|
||
Depends on D187147
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 7•2 years ago
|
||
Hopefully this doesn't regress anything too badly. Should help especially event dispatch. The tls access (which happens once per refcnt-changed-object between forgetSkippable/CC) is annoying. I tested keeping the old main thread only nursery and use a bit from mRefCnt to tell which Suspect() to use, but that did regress perf quite badly.
Comment 9•2 years ago
|
||
Backed out for causing hazards failures on TelemetryFixture.cpp
Failure log: https://treeherder.mozilla.org/logviewer?job_id=428449725&repo=autoland
Backout link: https://hg.mozilla.org/integration/autoland/rev/a18a71ffe10b102e0f00f92b1a8d442fabcf0583
| Assignee | ||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Comment 10•2 years ago
|
||
Depends on D187148
| Assignee | ||
Comment 11•2 years ago
|
||
This could be done in various ways, the taken approach is just trying to avoid too many changes
Depends on D188958
| Assignee | ||
Comment 12•2 years ago
|
||
Depends on D188959
Updated•2 years ago
|
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
Backed out for causing hazards failures.
Failure log: https://treeherder.mozilla.org/logviewer?job_id=430299593&repo=autoland
Backout link: https://hg.mozilla.org/integration/autoland/rev/39dc607f61623c82e70f4982272959e0625d52ae
| Assignee | ||
Comment 15•2 years ago
|
||
Depends on D188960
| Assignee | ||
Comment 16•2 years ago
|
||
Filed https://bugzilla.mozilla.org/show_bug.cgi?id=1855201 to tweak the rooting hazard annotations.
Comment 17•2 years ago
|
||
Comment 18•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/10edcb4b807f
https://hg.mozilla.org/mozilla-central/rev/5d9a36ae5068
https://hg.mozilla.org/mozilla-central/rev/a122b7314f12
https://hg.mozilla.org/mozilla-central/rev/7ad8d4a2d153
https://hg.mozilla.org/mozilla-central/rev/3ed02194e51d
https://hg.mozilla.org/mozilla-central/rev/4ceeaf14d6cf
https://hg.mozilla.org/mozilla-central/rev/90fecbcb1a40
Comment 19•2 years ago
|
||
(In reply to Cosmin Sabou [:CosminS] from comment #14)
Backed out for causing hazards failures.
Failure log: https://treeherder.mozilla.org/logviewer?job_id=430299593&repo=autoland
Backout link: https://hg.mozilla.org/integration/autoland/rev/39dc607f61623c82e70f4982272959e0625d52ae
== Change summary for alert #39683 (as of Thu, 28 Sep 2023 04:58:14 GMT) ==
Regressions:
| Ratio | Test | Platform | Options | Absolute values (old vs new) |
|---|---|---|---|---|
| 5% | perf_reftest_singletons parent-basic-singleton.html | linux1804-64-shippable-qr | e10s fission stylo webrender | 99.88 -> 105.25 |
Improvements:
| Ratio | Test | Platform | Options | Absolute values (old vs new) |
|---|---|---|---|---|
| 6% | perf_reftest_singletons window-named-property-get.html | linux1804-64-shippable-qr | e10s fission stylo webrender | 652.60 -> 612.93 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=39683
Updated•2 years ago
|
Description
•