Repository navigation
perf(runtime): skip the cleanups array for two-ref mergeRefs mounts - #112
Conversation
|
@jonkwheeler is attempting to deploy a commit to the Ripple Team Team on Vercel. A member of the Team first needs to authorize it. |
|
The two failing |
|
is this pr and findings still valid, given that #116 was merged? |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 291db0f. Configure here.

mergeRefs(a, b)still allocates a cleanup array on every mount after #116. This change selects a specialized two-ref callback at merge time and records its two cleanup steps directly, reducing allocations and mount/cleanup CPU time. Other arities keep the existing general loop.The branch now includes current
main(bfb03731). Both object-ref slots call the existingref_object_prop, preserving #116's single-pass classification. The obsoleteref_write_key/ removedis_ref_objectdependency is gone. Ref shapes are still read at mount time, and cleanup state remains separate for each mount.Performance against current main
Measured locally before committing, using a local benchmark harness on Node 24.18.0. Nine adjacent A/B pairs in fresh processes, alternating A/B order; four warmup repetitions, seven measured repetitions of 300,032 mount/cleanup cycles per process. CPU time comes from
process.cpuUsage(). Each batch retains 64 cleanups until all mounts finish, so cleanup allocations escape the mount call.Times below are medians of process medians; percentages are medians of the paired percentage reductions, so they need not equal the ratio of the two time columns. Positive percentages mean less CPU time.
All eight two-ref workloads improved in all nine pairs. An independent preliminary five-pair run of this implementation also improved every two-ref pair. Three-ref controls showed no substantial change in the final run; mixed arities measured 2.0% slower (versus 0.5% faster in the preliminary run). A nine-pair baseline-vs-baseline three-current control measured an apparent 1.3% improvement. Small general-path costs cannot be ruled out; this is a targeted two-ref optimization.
These are runtime-helper microbenchmarks, not application rendering or browser benchmarks. Single-ref elements bypass this helper; current compiler-generated uses include composed spread refs. No claim is made that two refs dominate actual applications. The earlier PR's allocation/GC percentages have not been remeasured and are superseded by the measurements above.
Validation
tsrx-utilsand the React, Preact, Solid, Vue, and Hono runtime projects.pnpm exec tsgo --noEmit -p packages/tsrx-runtime/tsconfig.jsonpassed.pnpm exec tsgo --noEmit -p packages/tsrx/tsconfig.jsonpassed.pnpm changeset:check, andgit diff --checkpassed.Coverage includes both ref positions, callback and cleanup order, null mounts, current/value precedence, unsupported shapes, mount-time classification, exception ordering, primitive-ref errors, single-pass Proxy trap sequences, independent cleanup state across repeated mounts, and public function arity. Includes a patch changeset for
@tsrx/runtime.Maintenance tradeoff
The two-ref mount and cleanup logic is intentionally duplicated to avoid per-ref allocations and dispatch in the hot path. Future changes to ref semantics must update both the specialized and general paths; object classification remains shared.
Agent disclosure
The original implementation was authored with Devin. The current-main port, local benchmarking, additional tests, and verification were performed with Codex.
Note
Medium Risk
Hot-path ref merging semantics are duplicated between specialized and general paths, so any future ref behavior change must stay in sync; regressions would affect composed/spread refs at runtime rather than compile time.
Overview
mergeRefs(a, b)now takes a dedicated code path at merge time: on each mount/cleanup it records the two ref steps in scalar slots (returned cleanup,REINVOKE_REFfor bare callbacks, or'current'/'value'keys) instead of allocating the general path’scleanupsarray. Object refs still go throughref_object_propat mount time; mount order, cleanup order, null mounts, errors, and ignored shapes stay aligned with the existing loop.All other arities keep the unchanged general
mergeRefsimplementation. A patch changeset for@tsrx/runtimedocuments the optimization, andref-runtime.test.jsgains broad characterization coverage for the two-ref path (including parity with the general path’s Proxy traps and separate cleanup state per mount).Reviewed by Cursor Bugbot for commit 0da9330. Bugbot is set up for automated code reviews on this repo. Configure here.