Closed Bug 1812055 Opened 2 years ago Closed 2 years ago

Add fast path for adding a plain object property or array element to structured clone reading

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [sp3])

Attachments

(1 file)

The DefineDataProperty in JSStructuredCloneReader::readObjectField is pretty slow, see the profile in bug 1811666. We can get rid of most of these calls with a fast path for plain object properties and dense array elements.

This improves the micro-benchmark below from ~1200 ms to ~930 ms.

function f() {
    var arr = [];
    for (var i = 0; i < 50; i++) {
        arr.push(i, {x: 1});
    }
    var buf = serialize(arr);
    var t = new Date;
    var res;
    for (var i = 0; i < 100_000; i++) {
        res = deserialize(buf);
    }
    print(new Date - t);
    return res;
}
f();
Blocks: 1812057

On typical workloads, these fast paths for plain objects and array objects handle
at least 97% of cases. This is much faster than the generic DefineDataProperty code.

Pushed by jdemooij@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b9c4ba784620 Add fast paths for the most common cases to JSStructuredCloneReader::readObjectField. r=sfink
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
Blocks: 1760153

Looking at the deserialize_us telemetry probe, after this landed the 95% percentile improved consistently from 72 to 60 (-16.7%). The 50% percentile from 3 to 2 (-33%).

Whiteboard: [sp3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: