Closed Bug 1904333 Opened 8 months ago Closed 7 months ago

Optimize structured cloning of strings with a StringBuffer

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
130 Branch
Tracking Status
firefox130 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(1 file)

If we're doing a same-process structured clone, it should be possible to avoid string copies for strings with a buffer, similar to the optimizations we have for (shared) array buffers.

This would make it much cheaper to pass large strings to/from DOM workers.

Severity: -- → N/A
Priority: -- → P2
Whiteboard: [sp3]

I wrote a patch for this and it seems to work.

When loading Gmail, this avoids serializing a number of JS strings of length 20k to 50k. Pretty nice.

Assignee: nobody → jdemooij
Status: NEW → ASSIGNED

If a JS string has a StringBuffer and we're doing a same-process structured clone,
pass the underlying reference instead of serializing/deserializing the string contents.
This lets us avoid copying some very large strings on websites like Gmail.

This is based on code we have for sharing the underlying buffer of a SharedArrayBuffer.

Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/95e7752918e2 Optimize structured cloning of strings with a StringBuffer. r=sfink
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch

Perfherder has detected a devtools performance change from push 95e7752918e2d7562f349350c84c718ecbe4529f.

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
3% damp custom.jsdebugger.project-search.first-search-result.DAMP linux1804-64-shippable-qr e10s fission stylo webrender 325.73 -> 314.39
3% damp custom.jsdebugger.project-search.first-search-result.DAMP linux1804-64-shippable-qr e10s fission stylo webrender 324.48 -> 313.93
3% damp custom.jsdebugger.project-search.first-search-result.DAMP windows11-64-shippable-qr e10s fission stylo webrender 254.59 -> 247.34

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a sheriff to do that for you.

You can run these tests on try with ./mach try perf --alert 1546

For more information on performance sheriffing please see our FAQ.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: