Skip to content

perf(runtime-tags): stop materializing branch boundary nodes - #3712

Open
DylanPiercey wants to merge 2 commits into
mainfrom
dpiercey-ws-marko-comments-optimization-lfdet4
Open

perf(runtime-tags): stop materializing branch boundary nodes#3712
DylanPiercey wants to merge 2 commits into
mainfrom
dpiercey-ws-marko-comments-optimization-lfdet4

Conversation

@DylanPiercey

@DylanPiercey DylanPiercey commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Control flow boundaries no longer leave permanent nodes behind, and countable ones stop shipping start comments entirely.

Commit 1: Client rendered templates stop padding the ends of a template or branch body whose edge is if/for/dynamic tag content, and resuming a server rendered branch adopts its real edge nodes rather than retaining the start comment and inserting a text node. A new fixBranchEdges keeps owner ranges valid by repairing their endpoints as nested content moves; debug builds assert range validity at every range read. <show>, <await> and <try> keep their own anchors — a <show> body is inlined into the enclosing scope and the others move their anchors themselves — so they repair their owner's edges rather than being repaired. Costs ~69B brotli of runtime; halves the marker nodes in a resumed page.

Commit 2: Building on that, server rendered if/for branches whose top-level content is statically countable no longer write a start comment per branch — the end marker's new BranchEndCounted symbol carries the per-branch node count and resume walks the range back from the end, generalizing the single-node encoding. An N item loop drops N start comments (~7% of a compressed list page); ~2B brotli of runtime.

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3778f47

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@marko/runtime-tags Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.35%. Comparing base (302606e) to head (3778f47).
⚠️ Report is 160 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3712      +/-   ##
==========================================
+ Coverage   90.34%   90.35%   +0.01%     
==========================================
  Files         414      414              
  Lines       19746    19833      +87     
  Branches     3615     3652      +37     
==========================================
+ Hits        17840    17921      +81     
- Misses       1367     1370       +3     
- Partials      539      542       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DylanPiercey
DylanPiercey marked this pull request as ready for review July 30, 2026 21:43
@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-comments-optimization-lfdet4 branch from e45bdf8 to 4f592ea Compare July 30, 2026 21:44
@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-comments-optimization-lfdet4 branch 2 times, most recently from 329a5d1 to 1a607af Compare July 31, 2026 16:16
Client rendered templates no longer pad the ends of a template or branch
body whose edge is `if`/`for`/dynamic tag content, and resuming a server
rendered branch adopts its real edge nodes instead of retaining the start
comment and inserting a text node. `fixBranchEdges` keeps owner ranges
valid by repairing their endpoints as nested content moves; debug builds
assert range validity at every range read so a missed repair fails loudly.

`<show>`, `<await>` and `<try>` own their anchors — a `<show>` body is
inlined into the enclosing scope and the others move their anchors
themselves — so the branch chain cannot repair their ranges. They keep
their padding and markers, and instead repair their owner's edges when
they detach, swap in a placeholder, or resolve.
@DylanPiercey
DylanPiercey force-pushed the dpiercey-ws-marko-comments-optimization-lfdet4 branch from 1a607af to fe19ed3 Compare July 31, 2026 16:33
Server rendered `if`/`for` branches whose top-level content is
statically countable (native tags, html comments, countable custom tags)
no longer write a start comment per branch: the end marker's new
`BranchEndCounted` symbol carries the per-branch node count and resume
walks the range back from the end, generalizing the single-node
encoding. An N item loop drops N start comments (~7% of a compressed
list page); costs ~2B brotli of runtime.
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