Optimize KeyboardEvent_Binding::_constructor
Categories
(Core :: DOM: Events, enhancement)
Tracking
()
People
(Reporter: mstange, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Profile: https://share.firefox.dev/45RsilM
0.5% of the measured time on Speedometer 3 is spent inside KeyboardEvent_Binding::_constructor
.
We should see if we can optimize it some more.
Updated•10 months ago
|
Reporter | ||
Comment 1•10 months ago
|
||
One thing I noticed: for eventDict.key
, we convert the key JSString*
to an nsString
and then to a KeyNameIndex
. The nsString
in the middle wastes an alloc+free.
Reporter | ||
Comment 2•10 months ago
|
||
And we QI the global object twice: First to EventTarget
and then to nsPIDOMWindowInner
.
Reporter | ||
Comment 3•10 months ago
|
||
Event_Binding::_constructor
, which we spend 0.2% of sp3 in, looks similar: https://share.firefox.dev/3R0pkHr
Comment 4•10 months ago
•
|
||
This is one case which is totally unrealistic in sp3. Web pages don't in general create their own events (nor do they dispatch many events).
But sure, we should optimize this.
I wonder if codegenerator should use nsAutoString for dictionaries, that would at least help with the alloc/free.
Or even faster would be some way more complicated setup where bindings layer would pass JSString value when available to the dictionary and only if JSString wasn't passed, but some other type, then conversion would happen (I think that would be still working per webidl spec).
Reporter | ||
Comment 5•10 months ago
|
||
Chrome appears to avoid the string allocation by only doing it once for this JS string. The JS string is "externalized" the first time it gets converted. This means that its internal storage is replaced with their version of the refcounted nsStringBuffer
(blink::StringImpl
).
They can do this because blink::StringImpl
supports both one-byte and two-byte strings, and even atom strings (even static atoms).
Comment 6•10 months ago
|
||
I wonder if it helped if we changed the contents of a JSString to external nsStringBuffer in case we allocate such, and JSString itself is either a rope or linear.
Reporter | ||
Comment 7•10 months ago
|
||
Updated profile: https://share.firefox.dev/3rfo9t3 (5% fewer samples than comment 0)
Description
•