Skip to content

perf: reduce hydration target traversal overhead - #7685

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

perf: reduce hydration target traversal overhead#7685
Jane Chu (janechu) wants to merge 3 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
@janechu
Jane Chu (janechu) requested a balanced review from Copilot September 1, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes FAST Element hydration target discovery while preserving marker and mutation behavior.

Changes:

  • Adds bounded TreeWalker traversal with live-Range mutation fallback.
  • Adds comprehensive cross-browser traversal tests.
  • Updates bundle sizes and release metadata.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/fast-element/test/main.ts Exposes the target builder to browser tests.
packages/fast-element/src/hydration/target-builder.ts Implements optimized hydration traversal.
packages/fast-element/src/hydration/target-builder.pw.spec.ts Covers boundaries, mutations, markers, and performance.
packages/fast-element/SIZES.md Records updated bundle sizes.
change/@microsoft-fast-element-893a7afa-7056-4d39-9257-150cb9bf26f8.json Adds the patch release note.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants