Optimize custom element registry lookup in HTML parser [chromium/src : main]

0 views
Skip to first unread message

Jayson Chen (Gerrit)

unread,
Apr 17, 2026, 6:41:46 PM (12 days ago) Apr 17
to Mason Freed, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Mason Freed

Jayson Chen added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Jayson Chen . resolved

Hey Mason, here's the perf improvement CL I promised :)

Open in Gerrit

Related details

Attention is currently required from:
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4f8d7775605ae27c4f0085fb44d1f0919adf98a5
Gerrit-Change-Number: 7774167
Gerrit-PatchSet: 1
Gerrit-Owner: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Fri, 17 Apr 2026 22:41:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Apr 22, 2026, 5:13:26 PM (8 days ago) Apr 22
to Jayson Chen, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Jayson Chen

Mason Freed voted and added 1 comment

Votes added by Mason Freed

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Mason Freed . resolved

I think this looks great! No notes, other than: it'd be nice to include some statistics about the performance gains you see locally when you test this patch?

Open in Gerrit

Related details

Attention is currently required from:
  • Jayson Chen
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4f8d7775605ae27c4f0085fb44d1f0919adf98a5
Gerrit-Change-Number: 7774167
Gerrit-PatchSet: 2
Gerrit-Owner: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Jayson Chen <jayso...@microsoft.com>
Gerrit-Comment-Date: Wed, 22 Apr 2026 21:13:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Jayson Chen (Gerrit)

unread,
Apr 22, 2026, 8:21:27 PM (7 days ago) Apr 22
to Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

Jayson Chen voted and added 1 comment

Votes added by Jayson Chen

Commit-Queue+2

1 comment

Patchset-level comments
Mason Freed . resolved

I think this looks great! No notes, other than: it'd be nice to include some statistics about the performance gains you see locally when you test this patch?

Jayson Chen

The stats with and without this patch are pretty similar/noisy, and I think it's somewhat expected as this is the last bit of performance regression that we're reclaiming. I'd submit this patch first and let's run another pinpoint to find out if we have mitigated the regression.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4f8d7775605ae27c4f0085fb44d1f0919adf98a5
Gerrit-Change-Number: 7774167
Gerrit-PatchSet: 4
Gerrit-Owner: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Thu, 23 Apr 2026 00:21:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Apr 22, 2026, 9:53:44 PM (7 days ago) Apr 22
to Jayson Chen, Mason Freed, chromium...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

Chromium LUCI CQ submitted the change

Unreviewed changes

2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
Optimize custom element registry lookup in HTML parser

Pre-cache the document's default CustomElementRegistry in
HTMLConstructionSite during document parsing, and gate the per-element
registry lookup in CreateElement on conditions where the registry could
actually differ from the cached value (fragment parsing or scoped
registries in use).

This avoids the repeated pointer chase through
Element::customElementRegistry() -> TreeScope -> LocalDOMWindow for
every element created during initial document parsing when scoped
registries are not in use.

Key changes:
- Thread the document's default registry from Document::CreateParser
through HTMLDocumentParser and HTMLTreeBuilder into
HTMLConstructionSite's constructor.
- In CreateElement, skip the per-element lookup when parsing a document
without scoped registries. For template content (both direct children
of <template> and deeper descendants), short-circuit to nullptr since
template content documents have no browsing context.
- Guard the customelementregistry attribute scan on registry being
non-null to skip unnecessary attribute lookups.
- Preserve the global registry on Document::Shutdown so it survives
browsing context teardown.
Bug: 481741903
Change-Id: I4f8d7775605ae27c4f0085fb44d1f0919adf98a5
Reviewed-by: Mason Freed <mas...@chromium.org>
Commit-Queue: Jayson Chen <jayso...@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1619263}
Files:
  • M third_party/blink/renderer/core/dom/document.cc
  • M third_party/blink/renderer/core/html/json_document.cc
  • M third_party/blink/renderer/core/html/parser/html_construction_site.cc
  • M third_party/blink/renderer/core/html/parser/html_document_parser.cc
  • M third_party/blink/renderer/core/html/parser/html_document_parser.h
  • M third_party/blink/renderer/core/html/parser/html_document_parser_test.cc
  • M third_party/blink/renderer/core/html/parser/html_tree_builder.cc
  • M third_party/blink/renderer/core/html/parser/html_tree_builder.h
  • M third_party/blink/renderer/core/html/parser/text_document_parser.cc
Change size: M
Delta: 9 files changed, 55 insertions(+), 16 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Mason Freed
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I4f8d7775605ae27c4f0085fb44d1f0919adf98a5
Gerrit-Change-Number: 7774167
Gerrit-PatchSet: 5
Gerrit-Owner: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Jayson Chen <jayso...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages