Closed Bug 1499684 Opened 7 years ago Closed 2 months ago

Accelerate text node and attribute value serialization using SIMD

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
146 Branch
Tracking Status
firefox146 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

(Keywords: perf)

Attachments

(1 file)

When we serialize an attribute value in the innerHTML getter, we skip past Latin1 or UTF-16 code units that aren't any of ", & or the no-break space. When we serialize a text node, we skip past code units other than <, >, & and the no-break space. We should add a SIMD code paths for skipping over code points except the above 3 or 4, both as 8-bit units and as 16-bit units. The code paths should probably use the pcmpestri instruction when SSE 4.2 is available. (See https://github.com/BurntSushi/rust-memchr/blob/master/src/x86/sse42.rs for inspiration. Per https://github.com/BurntSushi/rust-memchr/issues/38, adding all the variants we need is out of scope for the memchr crate itself.)
Keywords: perf
Component: DOM → DOM: Core & HTML
Severity: normal → S3

The code added in bug 1499682 has the right shape for this.

Depends on: 1499682
Assignee: nobody → hsivonen
Status: NEW → ASSIGNED

Days since char being signed caused a bug: 0

Let's try again:
https://treeherder.mozilla.org/jobs?repo=try&landoCommitID=162307

See Also: → 1998374

On Skylake, I see a 23% reduction in execution time for attribute value or text node that does not need any escapes and a 41% reduction in execution time for an attribute value or text node that needs one escape.

Attachment #9524637 - Attachment description: WIP: Bug 1499684 - Accelerate text node and attribute value serialization using SIMD. → Bug 1499684 - Accelerate text node and attribute value serialization using SIMD.

NOTE TO SHERIFF: This landing may change the exact error message for x86 Windows noopt linking failure that's bug 1998532. I'll fix that in bug 1998532.

Regressions: 1998532

M3 Pro
Attribute value or Unicode text node without escape: 13% reduction
Latin1 text node without escape: 24% reduction
Attribute value with single escape: 59% reduction
Text node with single escape: 63% reduction

Might be worthwhile to complicate the counting loop on aarch64 by reducing on every 15th iteration (to avoid overflow) instead of reducing on every iteration.

Blocks: 1998635

(In reply to Henri Sivonen (:hsivonen) from comment #10)

Might be worthwhile to complicate the counting loop on aarch64 by reducing on every 15th iteration (to avoid overflow) instead of reducing on every iteration.

Bug 1998635.

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
QA Whiteboard: [qa-triage-done-c147/b146]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: