Do less copying when external strings are passed back into the DOM
Categories
(Core :: DOM: Bindings (WebIDL), task, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox72 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
(Regressed 1 open bug)
Details
Attachments
(3 files)
Consider the attached testcase, which passes a long string through Web IDL to a callee that does almost nothing with it. The string originally came out of Web IDL bindings, and hence is an external stringbuffer-backed string. With our current setup, that causes a copy on the callee side, and copying a long string takes a while. The testcase outputs the average time per call, in ns.
In an unmodified build I see times on the order of 600 us (600,000 ns) per call. With my changes I see times on the order of 100ns per call, at the iteration count in the testcase; it gets even faster (~30-40ns) with more iterations and better JIT-compilation.
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Comment 1•6 years ago
|
||
| Assignee | ||
Comment 2•6 years ago
|
||
The codesize impact is approximately 0 (actually positive by a a few KB),
because AssignJSString is not inlined.
If we were to force-inline AssignJSString, that would actually save ~115KB
based on bloaty measurements for linux64 shippable opt builds (so with LTO),
because then ConvertJSValueToString stops being inlined in bindings.
Given that ConvertJSValueToString pretty much always calls AssignJSString, so
there is no slowdown from changing which of them is inlined, this is really
tempting to do, but I don't want to mess with compiler inlining heuristics...
Inlining both AssignJSString and ConvertJSValueToString increases codesize by
~2MB, so that's definitely not desirable.
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Comment 3•6 years ago
|
||
It already is in the nsAString case; we just ignore the failure if it happens!
Updated•6 years ago
|
Comment 5•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/dd64db27cdb8
https://hg.mozilla.org/mozilla-central/rev/72dac552b387
Comment 6•6 years ago
|
||
| bugherder landing | ||
Description
•