Closed Bug 1839082 Opened 2 years ago Closed 2 years ago

Some more improvements for attribute selector matching

Categories

(Core :: CSS Parsing and Computation, task)

task

Tracking

()

RESOLVED FIXED
117 Branch
Tracking Status
firefox117 --- fixed

People

(Reporter: mstange, Assigned: mstange)

References

Details

(Whiteboard: [sp3])

Attachments

(4 files, 1 obsolete file)

To speed up the testcase in bug 1837673 (attachment 9338349 [details]).

This deduplicates some checks for whether attr() is None,
and avoids a flag check in the chain iterator.

On my machine, with a local macOS arm64 --enable-release non-PGO build,
this fix reduces the time spent in has_attr by 38% on the testcase
in bug 1837673.

Assignee: nobody → mstange.moz
Status: NEW → ASSIGNED

This improves the testcase in bug 1837673 by a small amount.

In this profile you can see nsAttrValue::GetStoredAtom() call BaseType(),
and then nsAttrValue::Equals(string) calls it again: https://share.firefox.dev/3p8r71q

Depends on D181346

The goal here is to inline the loop and attribute name check into the caller.
Once an attribute with a matching name is found, we do the remainder of the
checks (namespace, attribute value) with a function call.

This probably helps some cases and hurts others.

Depends on D181347

This improves the testcase in bug 1837673, because it means that we only
check attributes once. Before this patch, we would check them twice: First,
the SimpleFilter path would check for the presence of the attribute, and then
later we would enumerate attributes again to check the attribute value.
Now we don't use the SimpleFilter path anymore and go straight to attribute
enumeration.

TODO: One of the checks that this skips is a quirks mode check - what are the effects of it? Do we need to handle something about it here?

Depends on D181348

Whiteboard: [sp3]
Attachment #9339762 - Attachment description: Bug 1839082 - Inline the string case of nsAttrValue::Equals into the atom case, so that the base type is only checked once. r=emilio → Bug 1839082 - Add a fast path to nsAttrValue::Equals for comparing a string attribute to an atom value. r=emilio
Attachment #9339761 - Attachment is obsolete: true
Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/50016a097d86 Add a fast path to nsAttrValue::Equals for comparing a string attribute to an atom value. r=emilio https://hg.mozilla.org/integration/autoland/rev/ab90251925ec Remove iter_attrs. This is no longer needed, now that attributes are always a single slice. r=emilio https://hg.mozilla.org/integration/autoland/rev/5b02f6714bb7 Move attribute checking around so that the attribute name can be checked without a function call. r=emilio https://hg.mozilla.org/integration/autoland/rev/50d6377ff840 Add a fast path for non-compound attribute selectors. r=emilio
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: