Skip to content

perf: reduce hydration target traversal overhead - #7685

Draft
Jane Chu (janechu) wants to merge 2 commits into
microsoft:mainfrom
janechu:users/janechu/hydration-target-walker
Draft

perf: reduce hydration target traversal overhead#7685
Jane Chu (janechu) wants to merge 2 commits into
microsoft:mainfrom
janechu:users/janechu/hydration-target-walker

Conversation

@janechu

@janechu Jane Chu (janechu) commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

📖 Description

Hydration target discovery currently checks every TreeWalker candidate against a DOM Range. This change replaces that per-node Range membership work with a bounded traversal and uses the live Range only when synchronous custom-element reactions mutate the traversal boundaries.

  • Preserves existing hydration marker behavior, mismatch diagnostics, and mutation compatibility.
  • Does not change public APIs, marker formats, or default hydration behavior.
  • Removes redundant content-node snapshots and traversal state.
  • Reduces every affected minified bundle by 129–144 bytes compared with main; Brotli output changes by +40–79 bytes.

👩‍💻 Reviewer Notes

Please focus on the boundary-mutation fallback in target-builder.ts. The normal path performs zero NodeFilter callbacks and zero Range.comparePoint() calls for 107 traversal candidates; the mutation fixture uses two live-Range checks and is bounded to five in the covered scenarios.

📑 Test Plan

  • 63 focused target-builder tests across Chromium, Firefox, and WebKit.
  • 319 Chromium hydration and repeat tests.
  • 199 Chromium declarative tests.
  • FAST Element TypeScript build, Biome/lint, aggregate package build, 34 export checks, API Extractor checks, Beachball validation, and git diff --check.

✅ Checklist

General

  • I have included a change request file using $ npm run change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Agents

  • I have linked to an existing issue in this project that this change addresses
  • I have read the skills
  • I have read the DESIGN.md file(s) in packages relevant to my changes
  • I have updated the DESIGN.md file(s) in packages relevant to my changes

Jane Chu (janechu) and others added 2 commits August 28, 2026 13:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu Jane Chu (janechu) changed the title perf: optimize hydration target traversal perf: reduce hydration target traversal overhead Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant