Performance audit

From octanejs/octane · View interactive version

Performance audit is an AI agent skill from the GitHub repository octanejs/octane. Audit or defend Octane performance. Use when a change can affect per-render, per-node, scheduling, compiler-output, SSR, hydration, or bundle cost, or when asked whether something is fast enough. Holds the V8-shape, DOM, and scheduling rules hot-path code must follow.

How to use this skill

Skill file

Skill: Octane performance audit

Use this to investigate performance regressions, benchmark results, scheduler/reconciler overhead, compiler output quality, or ecosystem binding perf.

Read first

V8 shapes and allocation,

DOM work, and

scheduling

Hot-path discipline

These rules apply to code that runs per render, node, item, event, signal

notification, or server request. Each reference cites the runtime code that

already follows the rule.

every field present, in a fixed order, as BlockImpl and the bagN factories

do. No delete, conditional keys, runtime class fields on hot classes, or

per-instance freezing. Keep call sites and return shapes monomorphic, numeric

fields integral, and arrays packed. Do not allocate closures, literals, rest

arrays, or iterators per item.

feature-only code behind the capability or driver that owns it.

hot code and emitted JS. Prefer a local const for a stable value used more

than once; follow Reuse stable member reads.

interleaved with writes in a loop. Insert built subtrees once. Keep events

native and delegated. Write from resize callbacks only through

createResizeObserver.

requestAnimationFrame is not a yield. Do not add a render or commit per

microtask hop. Coalesce first, then yield by posting a task through an existing

poster. Leave the documented scheduler contract to issue #1864.

Run the perf-review skill on the diff before handoff. It applies these rules

to the change and lists the evidence each finding needs.

Workflow

  1. Define target

proves both candidates perform the same work.

  1. Choose harness

Common ones are js-framework, dbmon, news, recursive-context,

signal-favoring, and todomvc.

family with %HaveSameMap. Tier and deopt traces:

benchmarks/client-hot-paths/functions.mjs.

effect-scheduling, and the marker-task commit count in

scheduling.

  1. Run baseline and candidate

a quick smoke result with a full result.

and deterministic counters when wall-clock noise is larger than the claim.

mutations per operation against the merge commit's first parent: any

increase fails it. Wall time there is a paired report, called slower or

faster only when its 95% interval lies beyond ±3%.

  1. Diagnose
  1. Patch or report
  1. Challenge the conclusion

garbage collection, or a less visible branch rather than removed.

it does not, look for a harness or measurement error.

intermediate measurement as the final result.

Reuse stable member reads

Repeated node.firstChild, node.nextSibling, record.field, or object[key]

reads can repeat accessor work and duplicate property names in emitted code.

Cache a reused value in a local declaration at its first needed read, in the

smallest scope covering its uses. Prefer this simple reuse over a persistent

cache or a new helper abstraction; do not alias every one-off property read.

For a native DOM node with no intervening tree mutation:

// Before: read the same first child up to three times.
if (node.firstChild !== null && node.firstChild.nodeType === 3) {
  return node.firstChild;
}

// After: read once and reuse the result.
const firstChild = node.firstChild;
if (firstChild !== null && firstChild.nodeType === 3) {
  return firstChild;
}

getter or proxy may have observable effects or return a different value on

each read; evaluating the receiver or coercing the key can also have effects.

Reducing these evaluations is not automatically equivalent.

hoist a read onto a path that previously skipped it or before its guard.

await/yield boundaries that can invalidate the value. In loops, cache per

iteration unless stability across iterations is established; a removal loop

must observe the new firstChild after each removal.

getNextSibling, or staged DOM views, reuse that result instead of switching

to a raw native read. Compiled template walks can reuse stable chain prefixes

without routing every access through a shared helper.

claiming a size win. A local declaration can cost more than it saves, and a

JIT or minifier may already eliminate some repeated reads. Use the owning

benchmark for runtime claims and relevant correctness checks when changing

code; fewer source-level reads alone do not establish a speedup.

Bundle bytes

request benchmark report lists every byte change; read the rows your change

moved and justify any growth in the pull request description.

capability that owns it. Judge growth by raw and gzip; brotli can grow when

code is removed.

[scenario...] and node benchmarks/bundle-size/run.mjs octane-tsrx

octane-jsx`.

Evidence required for hot-path changes

| Change | Evidence |

| --- | --- |

| Any runtime, compiler-output, or binding hot path | The pull request benchmark report (.github/workflows/pr-bench.yml): byte changes, reported only, and js-framework production calls and DOM mutations per operation, where any increase fails. |

| Bundle bytes | node benchmarks/bundle-size/run-minimal.mjs <scenario> and run.mjs octane-tsrx octane-jsx while iterating. CI's report rows are authoritative: brotli, and occasionally gzip or raw for path-dependent scenarios, can differ locally. |

| A hot record's shape | %HaveSameMap across every construction mode, as benchmarks/runtime-object-shapes does, and perf-review-scan clean. |

| Allocation or tiering | A scratch harness on the production bundle: pinned semi-space for bytes per call, %GetOptimizationStatus and --trace-deopt for tiers. |

| Scheduling, commits, or effect timing | The marker-task commit count from scheduling, plus the relevant scheduling suite. |

| User-visible latency claims | Event Timing in Chromium, maximum duration per interactionId, against React on the same app. Long-task entries are not evidence. |

| Optimization claims in general | node benchmarks/bench.mjs <suite> --ratios for the suite that owns the scenario. |

Run locally only the suite or scratch probe that owns the scenario, one suite at

a time (--quick while iterating). Leave wide runs to CI: the full pnpm test,

the full benchmark sweep, and end-to-end or browser suites. Parallel agent

sessions share one machine, and a wide local run makes every timing on it

noise.

Streamed interactions

Measure from trusted input through request dispatch, the first read containing

content, the first DOM update containing that text, and the first frame that

shows it. Record which control records arrived with the content. Earlier delivery

of controls can move work outside the interval being compared.

For a slow dispatch, trace the work awaited before the request. For slow text

publication, count the view revisions triggered by each record. Hold the

renderer fixed and remove one unnecessary wait or publication at a time. A

renderer sample shows where the CPU ran. Inspect its caller to see what

requested that work.

When skipping an equal-value update, replace the owner while an acknowledgment

is pending. Check that the replacement adopts the live value even if its initial

markup contains the same text. When preloading an adapter, verify the original

consumer still owns initialization, cancellation, and error delivery.

Report template

## Performance audit
- Target: ...
- Baseline command/result: ...
- Candidate command/result: ...
- Delta: ...

## Findings
- ...
- `perf-review` result: ...

## Recommendation
- ...

## Validation
- ...

## Confidence and residual risk
- Noise/variance: ...
- Modes not measured: ...
- Alternative explanation considered: ...

Common pitfalls

operation, and still add a commit per hop under a burst. Count commits before

a marker task.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.