gfxContext constructor does always an extra heap allocation for mStateStack
Categories
(Core :: Graphics, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox113 | --- | fixed |
People
(Reporter: smaug, Assigned: jfkthame)
References
(Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Attachments
(1 file)
https://searchfox.org/mozilla-central/rev/2ede53e39955988f98db4369f7ce09614b22104a/gfx/thebes/gfxContext.cpp#55,62
The allocation tends to show up in React-Stockcharts profiles, at least in the ZoomTheChart-sync part.
Could AutoTArray be used in gfxContext?
Reporter | ||
Updated•2 years ago
|
Reporter | ||
Comment 1•2 years ago
|
||
Looks like we recently fixed similar bug 1812729 and bug 1812774.
Assignee | ||
Comment 2•2 years ago
|
||
Yes, I think this would be reasonable. Many of our gfxContexts are short-lived, stack-allocated instances and don't do any Save/Restore operations, so a single-element auto-array would avoid a separate allocation for these.
Actually, on further consideration I think we can do a bit better. We're constantly accessing CurrentState(), which with the existing array implementation (whether the existing nsTArray or an AutoTArray) involves looking up the current array length, and then indexing by mLength-1 to read the last element. We can streamline all these accesses by storing the current AzureState directly in gfxContext, and only pushing it to an array when we do a Save() operation.
This will optimize all the routine access to elements of the state; the one thing that becomes slightly trickier is when we need to iterate over all the clips in the entire state stack, as that'll need to consider both the stack of saved states (if any) and the separately-stored current state.
I'll put up a patch after some local testing.
Assignee | ||
Comment 3•2 years ago
|
||
Comment 5•2 years ago
|
||
Backed out for causing bustages at gfxContext.h.
Backout link: https://hg.mozilla.org/integration/autoland/rev/7ea8042eaf1d0c5f78ccce2e79e3e13f73526c64
Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception%2Cretry%2Cusercancel&revision=689b845c477e76d6f3ef8fa21ef354e86606f75c
Failure log: https://treeherder.mozilla.org/logviewer?job_id=408760067&repo=autoland&lineNumber=5809
Comment 7•2 years ago
|
||
Backout merged to central: https://hg.mozilla.org/mozilla-central/rev/7ea8042eaf1d
Comment 8•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Updated•2 years ago
|
Description
•