Skip to content

feat: complete profiling counter core - #1955

Merged
domgan-oai merged 2 commits into
mainfrom
codex/finish-profile-counter-core
Oct 9, 2026
Merged

domgan-oai merged 2 commits into
mainfrom
codex/finish-profile-counter-core

Conversation

@trueadm

@trueadm trueadm commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Completes the remaining Phase 1 counter core from #1886. A profiling session now reports 60 engine counters, bounded accepted-root commit history through getCommits(), and exclusive component counters in summary(). Commit IDs are separate from scheduler drains; delayed effects and lifecycle actions keep the transaction that queued or published them, including retained offscreen work and staged Activity cleanup.

Adds probes for lists, effects and refs, lite/deopt/cache paths, boundary transitions, Activity, View Transitions, rollback kinds, flush priorities, host tasks, suspension strata, and layout/render replays. Session totals include discarded attempts; eviction, stop/clear behavior, unsupported counters, and units are documented. The counter schema advances to 2 with a minor changeset.

The cache-hit probe lives in the compiler's actual hit branch because compilerCacheContext also runs on misses. It calls an observer installed on the existing compilerMemoRegion helper, so optimized modules acquire no profiling-module dependency. Counter slots use strip-compatible TypeScript for direct Node server loading. Every new runtime reference remains behind the existing profiling define. An automated identity gate covers index/universal exports, five minimal fixtures, js-framework, TodoMVC, and chat in development and production, keeping identifiers stable.

Validation

  • pnpm sync; no generated changes.
  • pnpm format:files:check for all changed files.
  • Scoped pnpm typecheck:files for the runtime, profiler, host-task helper, and bundle test.
  • octane-profile: 40 integration tests, including multi-root drains, failed attempts, delayed effects, offscreen publication, staged cleanup, bounded history, and each new probe family.
  • octane: 153 tests across profiler API, auto-memo, and production-profile bundle suites; 11 development/guard/production stripping tests. Vite integration profile bundle test also passes.
  • OCTANE_PROFILE_STRIP_BASE=7bb02657b4 bundle test: code-identical against the pre-change runtime across all 20 entry/mode combinations; profiling module contributes zero bytes when off. Ordinary CI runs compare against source-level probe erasure.
  • 386 CI workflow tests, 87 playground unit tests, and all 6 direct-server preload tests across development and production.
  • node benchmarks/bundle-size/run-minimal.mjs hooks-state suspense-transition and node benchmarks/bundle-size/run.mjs octane-tsrx octane-jsx.
  • Current-head CI: repository test shards, React parity, browser/package/website integration, typecheck, lint, examples, compatibility, and package validation pass on 28bc25463c.

Perf review

node scripts/perf-review-scan.mjs reports 0 candidates, with no unresolved findings. Per-node/list/render probes (runtime.ts) increment numeric typed-array slots; transaction and component tables live in profiling.ts:428-540, outside hot renderer records. No fields are added to Block, Scope, or LiteBlock. No DOM reads/writes, render requests, or task scheduling behavior are added. The emitted cache probe (compile.js:27204) and all runtime probes disappear under the off define, verified against the pinned base.

Each retained transaction/component counter table holds 60 doubles (480 bytes); commit/component retention is independently bounded by bufferSize. Weak maps attach pending work to existing objects. Exported records copy numeric/string metadata and retain no application objects.

node benchmarks/js-framework/profile-overhead.mjs 9 compares the same profile-compiled program with counter work disabled, global counters only, and full attribution. Component timing stays on and timeline output stays off. Darwin arm64, Chromium 149.0.7827.55, 3 warmups and 9 samples per operation with rotating lane order and DOM-result verification:

Operation Counters off (ms) Global (ms) Attributed (ms)
run 2.1 2.1 2.2
replace 4.9 4.9 5.0
add 1.8 1.8 1.9
update 0.3 0.3 0.4
select 0.3 0.2 0.2
swap 0.2 0.3 0.3
remove 0.3 0.3 0.3
runlots 17.5 17.6 17.7
select_lots 0.7 0.7 0.7
clear 27.3 27.7 27.3

These are measured medians, not speedup claims; small differences and sub-millisecond ratios are inconclusive at this timer resolution. This run measures counters/attribution; timeline cost is unchanged and was not measured.

The current-head PR benchmark passes: all 64 production work counters and all 60 application bundle-size values are unchanged, and all 20 timings are within noise. All reachability raw sizes are unchanged; binding gzip/Brotli changes range from −17 to +69 bytes. The stable-identifier gate above checks code identity independently of minifier naming.

concise-code: shipped source +599/−50 (client runtime +195/−7). Extends the existing recorder and transaction/effect queues; no new runtime module, option, or renderer field. New subpath types describe commit history; numeric probe/attribution helpers serve the runtime and compiler. The only new executable file is the repeatable overhead benchmark. Rejected event-derived detail (roughly 60 lines, loses counters after eviction and misses non-component work) and drain-ID grouping (roughly 40 lines, merges separate roots and misattributes delayed effects). Normal bundles are code-identical with profiling off. Local minimal gzip: hooks-state 25,174 bytes; suspense-transition 42,798 bytes. CI byte reports remain authoritative.

Risk / follow-ups

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches commit/effect scheduling and root transaction paths across the DOM runtime with many new guarded probes; profiling-off identity is tested but the surface area in runtime.ts is large.

Overview
Finishes the Phase 1 profiling counter core: counter schema 2 with 60 engine counters (lists, effects/refs, boundaries, Activity, scheduler/flushes, rollbacks, etc.), all behind existing __OCTANE_PROFILE_ENABLED__ guards.

Profiler APIs: getCommits() returns bounded accepted-root commit history (separate from drain IDs) with per-commit counters; delayed effects/refs attribute back to the transaction that queued them. summary() adds exclusive per-component counters and truncated when detail is evicted. bufferSize now caps events, commits, and component counter rows together.

Instrumentation: runtime.ts and host-task.ts wire probes through __profileCount / transaction helpers; the compiler emits block.cacheHit on memo region cache hits via compilerMemoRegion.__profileHit.

Tooling & docs: New profile-overhead.mjs benchmark; expanded profiling/devtools docs; integration tests for attribution and probes; production bundle tests assert profiling-off builds stay code-identical (optional OCTANE_PROFILE_STRIP_BASE baseline).

Reviewed by Cursor Bugbot for commit 28bc254. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Oct 9, 2026
@trueadm
trueadm marked this pull request as ready for review October 9, 2026 21:46
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website 28bc254 Commit Preview URL

Branch Preview URL
Oct 09 2026, 10:00 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
octane-website-mcp 28bc254 Commit Preview URL

Branch Preview URL
Oct 09 2026, 10:03 PM

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-reachability: 7 value(s) increased

Compares 7bb02657b, the merge commit's first parent with 6164d2723 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.550 3.833 −0.0% −8.5% … +7.5% ⚪ within noise
octane-tsrx replace 10.533 11.100 −2.0% −9.5% … +18.0% ⚪ within noise
octane-tsrx add 3.408 3.558 +1.2% −4.9% … +7.9% ⚪ within noise
octane-tsrx update 0.173 0.163 +0.7% −8.2% … +6.9% ⚪ within noise
octane-tsrx select 0.008 0.007 −6.3% −17.6% … −0.7% ⚪ within noise
octane-tsrx swap 0.025 0.025 +0.2% −5.1% … +9.4% ⚪ within noise
octane-tsrx remove 0.024 0.024 −3.1% −9.3% … +12.0% ⚪ within noise
octane-tsrx runlots 37.858 35.783 −3.8% −16.2% … +2.1% ⚪ within noise
octane-tsrx select_lots 0.007 0.008 +2.1% −0.7% … +4.0% ⚪ within noise
octane-tsrx clear 52.933 52.175 +1.2% −0.3% … +3.1% ⚪ within noise
octane-jsx run 4.608 4.567 −4.5% −9.3% … +2.6% ⚪ within noise
octane-jsx replace 9.317 9.050 +3.2% −3.6% … +7.5% ⚪ within noise
octane-jsx add 3.858 3.858 −0.0% −7.1% … +4.8% ⚪ within noise
octane-jsx update 0.286 0.292 +1.8% −1.9% … +5.6% ⚪ within noise
octane-jsx select 0.146 0.155 +1.9% ±0.0% … +3.9% ⚪ within noise
octane-jsx swap 0.198 0.209 +1.4% −0.3% … +2.3% ⚪ within noise
octane-jsx remove 0.192 0.193 +0.3% −0.5% … +0.5% ⚪ within noise
octane-jsx runlots 32.108 32.067 −1.8% −4.0% … −0.3% ⚪ within noise
octane-jsx select_lots 1.821 1.834 +0.0% −3.7% … +2.8% ⚪ within noise
octane-jsx clear 56.558 61.858 +2.6% −0.7% … +5.1% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

target metric base head Δ
binding-base-ui-esbuild brotli 61,517 61,526 +9 (+0.0%) 🔴
binding-aria-esbuild gzip 3,331 3,332 +1 (+0.0%) 🔴
binding-aria-esbuild brotli 2,981 2,982 +1 (+0.0%) 🔴
binding-radix-esbuild gzip 71,430 71,413 −17 (−0.0%) 🟢
binding-radix-esbuild brotli 62,089 62,073 −16 (−0.0%) 🟢
binding-mantine-hooks-esbuild gzip 30,464 30,466 +2 (+0.0%) 🔴
binding-mantine-hooks-esbuild brotli 27,185 27,188 +3 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 117,220 117,219 −1 (−0.0%) 🟢
binding-apollo-client-esbuild brotli 102,301 102,370 +69 (+0.1%) 🔴
binding-usehooks-ts-esbuild brotli 27,386 27,401 +15 (+0.1%) 🔴

101 other measured values are unchanged.

@domgan-oai
domgan-oai merged commit 974a3a6 into main Oct 9, 2026
35 checks passed
@domgan-oai
domgan-oai deleted the codex/finish-profile-counter-core branch October 9, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants