Repository navigation
fix(ssr): perf tune-ups plus new benchmark suite - #7062
Merged
Merged
Conversation
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
GitHub Issue Number: N/A
::partrewrites (scopeCss/expandPartSelectors) rerun for every component on every render. In scoped mode this dominated render time.findSlotFromSlottedNode>getHostSlotNodes), copying the result array at every level. A host with many slotted children costs O(children × tree).insertBeforeruns aclosest()lookup for every slotted node even when nothing uses the result.Proxytrap (in+isNaN) per property read and allocate a closure perfind.children/childElementCount/firstElementChildbuild a filtered array on every access.What is the new behavior?
Render speed. All HTML output is byte-identical to before.
WeakMap. A cached slot is reused only while it is still connected inside the host with the same name; otherwise the full search runs. The search itself appends to one array.closest()lookup ininsertBeforeonly runs whenpatchAllneeds it.Proxytrap reads the property directly; lookups use loops. The child getters loop instead of filtering.Benchmark.
test/perf/ssr-benchmarkis a 10-component, design-system-shaped app: large stylesheets,closest()context lookups, slots, shadow and scoped components. It renders fragment, list-50 and kitchen-sink pages in DSD and scoped mode.pnpm testthere reports median / p95 / first-render time, heap retained after GC and peak RSS.benchmark-codspeed.mjsruns the same six cases as CodSpeed benchmarks (@codspeed/tinybench-plugin, simulation mode).Median ms per render vs the previous build (11 interleaved rounds):
Documentation
SSR benchmark, Node's
--max-semi-space-size=16cut peak RSS by ~47% (median +6-12%, p95 -9-15%).Does this introduce a breaking change?
Testing