Skip to content

Keep the successful render path synchronous and allocation-light - #1556

Merged
ricardo-devis-agullo merged 1 commit into
masterfrom
advisor/006-synchronous-render-lane
Aug 23, 2026
Merged

Keep the successful render path synchronous and allocation-light#1556
ricardo-devis-agullo merged 1 commit into
masterfrom
advisor/006-synchronous-render-lane

Conversation

@ricardo-devis-agullo

Copy link
Copy Markdown
Collaborator

Summary

  • make warm environment cache hits synchronous (lookupEnv tri-state callback) so cached renders stop suspending through a discarded promise/microtask
  • hoist stable callback adapters per registry render service: repository getComponent, nested renderer bound to the registry conf, and fromPromise adapters for renderComponent/renderComponents
  • build component-retrieved telemetry only at completion when a listener exists (one scalar hrtime.bigint() start timestamp; no payload allocation, end-clock read, or fire when unobserved), preserving mid-flight listener add/remove semantics
  • remove the top-level async from the callback renderer and make normal returnComponent completion synchronous; move local source-map/stack enrichment into a cold async helper that still finishes enrichment before the public callback and falls back to the original stack on failure
  • delete the now-unused get-component-retrieving-info.ts; add frame?: string to the response details type to match runtime behavior

Preserved invariants: exact-once completion, timeout cleanup before event/callback, Domain execution, ENV_RESOLVING_ERROR / DATA_RESOLVING_ERROR behavior, single-flight storage reads, and renderer-return → provider → event → callback ordering. The only timing change is removal of an internal warm-env microtask.

Benchmarks (same machine, clean-tree baseline vs this branch)

  • burst: deterministic storage work counts unchanged (1 read each for package/env/provider/template at N=50 and N=200); CPU user time 17ms→17ms (N=50) and ~30ms (N=200)
  • quick: local-memory 6286→7166 rps (+14%), p95 20.1→17.9ms; storage-simulated +14%; batch-storage 1040→1265 rps (+22%), p95 103→86ms
  • high-load: high-load-local 6050→7119 rps (+18%), p95 38.4→32.2ms; high-load-storage 5651→6363 rps (+13%), p95 40.0→35.7ms
  • gates: exit 0 with --max-rps-regression-percent=5 --max-p95-regression-percent=5 --expect-success-rate=1

Test plan

  • new characterization suite registry-routes-helpers-get-component-timing.js: renderer-return-before-callback trace with microtask sentinel, repo→env→provider gating, sync throw / async success-failure / double-callback exact-once, timeout cleanup ordering, retrieval payload key parity (success + error), local enrichment ordering and fallback, warm env hit without a second repository env lookup, real-events-handler mid-flight listener add/remove
  • existing helper suites updated for the hasListeners contract
  • npm --workspace packages/oc run build
  • npm --workspace packages/oc run test-silent (1052 passing)
  • npm --workspace packages/oc run bench:burst
  • quick and high-load comparison commands against same-machine baselines

Closes plan 006 in plans/README.md.

@ricardo-devis-agullo
ricardo-devis-agullo merged commit f145324 into master Aug 23, 2026
3 checks passed
@ricardo-devis-agullo
ricardo-devis-agullo deleted the advisor/006-synchronous-render-lane branch August 23, 2026 14:32
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