Repository navigation
perf: avoid cycle set for primitive transport props - #1004
Merged
domgan-oai merged 1 commit intoSep 8, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 8, 2026 21:47
Closed
68 of 84 tasks
14 of 21 tasks
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.
Summary
WeakSetis created.Why
The universal renderer clones every transported host prop. The default argument to
cloneSerializableValueallocated aWeakSeteven when a value wasnull,undefined, a string, number, bigint, or boolean. This is the primitive-allocation part of #981.Changes
finallystill removes each visited object.octanepatch changeset.Validation
pnpm format:files:check packages/octane/src/universal-core.ts packages/octane/tests/universal-transport.test.ts .changeset/lazy-transport-cycle-tracking.mdpnpm typecheck(passed locally)pnpm test(full suite left to CI)pnpm exec vitest run packages/octane/tests/universal-transport.test.ts packages/octane/tests/universal-renderer.test.ts --reporter=dot— 266 passed across development and production projects.pnpm typecheck:files packages/octane/src/universal-core.ts;pnpm sync;git diff --check.Production source-bundle ABBA probe on Node 26.4.0/V8 (baseline
ab3236409, same build inputs): an exact-source serializer probe over 15 rounds × 250,000 primitive calls measured median 0.01773 → 0.00882 µs/call, with nonoverlapping observed ranges. The object-valued control ranges overlapped. Instrumentation counted 256 → 0WeakSetallocations for a 256-primitive-prop transported prepare; object props remained 256 → 256 and local props 0 → 0. Across nine paired public-renderer runs × 700 prepares, the 256-primitive-prop median was 0.06491 → 0.06122 ms, but ranges overlapped, so the end-to-end timing is inconclusive. Command SHA-256 hashes matched for all three workloads; nested clones remained distinct and frozen.Current-head CI passed all 26 jobs on attempt 2 at
da4c63803985b09be7e26b21e94601a88e958b92, including parity, package validation, browser integration, and provenance. Attempt 1 could not run a Base UI drawer test file in the broad parity shard; that file passed all 16 tests in a focused adapted-project run, and the same-head parity shard passed on retry. Cursor Bugbot passed without comments.Risk / follow-ups
The change only affects transported serialization. Object cycle and sharing semantics remain protected by the same recursion set; the test covers both codec modes and rejected updates. The #981 item also calls out the codec context object and closure per prop; that part remains for a separate measured change.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Serialization behavior for objects is unchanged; only avoids allocations on the primitive fast path, with new transport tests covering both codec modes.
Overview
Lazy cycle tracking for universal host values sent across a transport:
cloneSerializableValueno longer creates aWeakSeton every call—primitives (null,undefined, strings, numbers, bigints, booleans) return immediately, and the set is created only when cloning object graphs (same sharing/cycle rules as before).Adds a transport test (codec on/off) that exercises mixed primitives, nested shared references, frozen clone isolation, and cycle rejection. Includes an
octanepatch changeset.Reviewed by Cursor Bugbot for commit da4c638. Bugbot is set up for automated code reviews on this repo. Configure here.