Repository navigation
perf: reuse universal codec resource-handle factory - #1005
Merged
domgan-oai merged 1 commit intoSep 8, 2026
Merged
domgan-oai merged 1 commit into
domgan-oai merged 1 commit into
Conversation
Closed
68 of 84 tasks
domgan-oai
marked this pull request as ready for review
September 8, 2026 22:28
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
Reuse one root-bound resource-handle factory across universal host prop codec calls. A codec installed after root creation still works, and each call receives a fresh, retainable context snapshot. This is the callback portion of #981's universal transport allocation item.
Why
The transport encoder created a new resource-handle closure for every coded host prop, even though its only captured state belongs to the root. A codec may retain its context or borrow the factory after the encode call, so the factory must remain bound to the originating root.
Changes
octanepatch changeset.Validation
pnpm format:check(not run; changed-file check below)pnpm typecheckpnpm test(not run; targeted suites below)pnpm exec vitest run packages/octane/tests/universal-transport.test.ts packages/octane/tests/universal-renderer.test.ts --reporter=dot(268/268 in development and production); transport-only rerun after the factory identity assertions (54/54)pnpm format:files:check packages/octane/src/universal-core.ts packages/octane/tests/universal-transport.test.ts .changeset/reuse-universal-codec-handle.md;git diff --check;pnpm syncOn the same production source-bundle harness, 256 coded props produced 256 distinct factories per prepare on merged
mainand one on this branch (one across two prepares). No-codec controls produced zero in both; wire hashes, frozen resource handles, and root stamps matched across five workloads. The full production bundle changed by +68 bytes (797,033 to 797,101). Nine rounds of 400 publicroot.prepare()calls in both bundle orders gave conflicting timing directions, including in no-codec controls, so no end-to-end throughput gain is claimed.Risk / follow-ups
This adds one cached callback per codec-using root. The public codec context object remains fresh per prop because codecs may retain its value, host type, and name. Reusing that object would require a separate observable-contract decision; the #981 checklist item stays open.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Behavioral contract is unchanged aside from stable factory identity per root; validation and wire encoding paths are covered by expanded transport regression tests.
Overview
Reuses one root-bound
createResourceHandlefactory for universal host prop codec encoding instead of allocating a new closure on every coded prop.On first
encodeHostPropwith a custom codec, the root lazily caches the factory (codecResourceHandle); later encodes pass that same function while each codec call still gets a fresh context snapshot (value, host type, name). That keeps late-installed codecs and codecs that retain context or borrow the factory after encode aligned with the originating root.Transport tests now cover shared factory identity across props/re-renders, stable retained contexts, borrowed handles, rejection of handles from another root, and recovery on a foreign root.
Reviewed by Cursor Bugbot for commit c0ec99c. Bugbot is set up for automated code reviews on this repo. Configure here.