perf: P12 - F13 again on the code P5 to P7 leave behind #59
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
PERFORMANCE.md finding F13 measured that making
torb_retain,torb_releaseandtorb_make_uniquestatic inlineinruntime/include/torb.hwas worth up to 14% and cost up to 9%, depending on the loop, and left it "a measurement to redo once findings 2 to 5 have removed" the indirect calls and copies. Rounds P5 to P7 landed (section 5: done), and the bytecode back end and the VM exist, so the condition of the round table ("after the VM", "two back ends to answer to") is met. This round redoes the measurement on the code they leave behind and keeps the change only if the numbers say so.Source
runtime/memory.c(torb_retain,torb_release,torb_make_unique),runtime/include/torb.hGoal
Measure the three fast paths inline against the runtime as it is, on the benchmark table of today's
main, and land the variant (if any) that wins. The fast paths have grown since F13 was written (immortal blocks, the shared-count bit andtorb_pool_threaded, the release depth bound), so "inline" means the header holds the common case and the rest stays a call.Acceptance criteria
main'smemory.csemantics: (A) as is; (B)torb_retaininline; (C)torb_retainand the unique test oftorb_make_uniqueinline; (D) all three. Inline code holds only the common case (non-NULL, not immortal, not shared/threaded for retain; count above one and not shared/threaded for release); every other case calls the out-of-line function, so panics, the release depth bound, the atomic path and the immortal rule stay inmemory.cunchanged.benchmarks/run.sh --allocationswithRUNS=9, fastest of nine. A temporary measurement job on the PR branch is fine and is removed before the last commit; no new gate. The full table (all rows of section 4 that exist inbenchmarks/) goes into the PR description, and the rowslist-iterate,pipeline,record-write,list-index,map-count,binary-trees(game) are named.docs/PERFORMANCE.mdonly, with the numbers; that is a valid outcome of the round, not a failure.runtime/include/torb.h,runtime/memory.cwhere a function becomes the slow path), the runtime tests (runtime/tests) are green in both CI tiers, the VM's kernel (machine.c) still reaches the same out-of-line entry points, and an-O2object size delta of the emittedprogram.coflist-iterateis recorded (code size is the cost of inlining).docs/PERFORMANCE.md: F13 gets the new table and the verdict; section 5 row P12 is marked done and the status line at the top no longer lists P12 as waiting; the stale "after the VM" wording of the row is corrected;torb docs check docs,torb docs index --check docsand theskills/regeneration are green.Design record point
PERFORMANCE.md F13 and round P12 (section 5). BACKEND 6.3 (
-fltois unusable with this toolchain, which is why the fast paths are not inlined across units today; if-fltoworks on the CI runner's gcc now, record it in F13 and do not make it part of this round).Seed impact
None expected: a header-only change to the runtime, no syntax, no native, no name looked up by string. The seed is not touched.
Size
One PR. One commit if the PR only records the numbers; two Conventional Commits if a variant lands (
perf(runtime): inline the fast path of torb_retain ...anddocs(performance): redo finding 13 on the code P5 to P7 leave behind).Out of scope
P9 (#56) and P11 (#58, #415): their passes change the IR, not these functions, and this round measures
mainas it stands when the PR runs (re-measure if one lands while the PR is open). Atomic reference counts or the pool's threaded mode. Any change to the C that the back end emits.-flto. The seed.Dependencies
None.
Moved from the planning lists of the docs; the design record stays the specification.
[loop:torbscript] intake: in scope (author orion, label loop), source PERFORMANCE.md round P12, not a duplicate. Follows the rounds P5 to P7; refine checks whether they landed. next: waiting (rounds P5 to P7 and ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z
TakeOut/PutBackon the map #56forover a flat list in PERFORMANCE.md (step 1 of #58) #415forover a concrete list is a counted loop #58[loop:torbscript] claim refine by session:loop-torbscript-20261023 until 2026-10-23T08:16:00Z
[loop:torbscript] refine: ready, next: implement (one PR, oldest-first once WIP is free).
Findings.
runtime/include/torb.h.torb_retain/torb_releasenow also handle the immortal count, the shared-count bit withtorb_pool_threaded, and the release depth bound. So "inline all three" can no longer be a copy of the old experiment; only the common case can be inline.Decided by the loop (performance, measurable, internal; no owner question).
benchmarks/run.sh --allocations, RUNS=9, fastest of nine.memory.c, so panics, the atomic path, the depth bound and the immortal rule do not change.Size. One PR: one commit (numbers only) or two (inline change + PERFORMANCE.md). Header and
memory.conly. Not an epic, so no split.Seed impact. None expected (header-only runtime change, no syntax, native or looked-up name). The issue body now holds the sharpened goal, criteria, scope, out-of-scope and size.
Tokens for this refine run: roughly 45k (read-only repo check).
[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T12:26:00Z
[loop:torbscript] release implement: lease expired 2026-10-23T12:26Z with no live worker and no result comment; branch loop/59-inline-refcount-fastpath holds 3 temporary measurement commits (last 08:20Z), no PR yet. next: fresh implement worker continues from that branch
[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T18:30Z
[loop:torbscript] release implement: lease expired 2026-10-23T18:30Z with no live worker (dispatch.liveWorkers 0) and no result comment; branch loop/59-inline-refcount-fastpath kept. next: fresh implement worker
[loop:torbscript] claim implement by session:loop-torbscript-20261024 until 2026-10-24T04:30Z
[loop:torbscript] implement: variant D landed. The measurement job from the earlier branch (one runner, RUNS=9, passes A B C D and D C B A) gave list-iterate -26.0%, pipeline -23.8%, map-count -8.9%, binary-trees -8.3% with the three fast paths inline; slowest named rows list-index +2.4%, record-write +1.9% (B and C failed the 3% rule on record-write). Allocations identical in every row. Measurement scaffolding is not in the PR; the history is three commits (fix(benchmarks) so --allocations links runtime/os, perf(runtime), docs(performance) with the full table, verdict, code-size delta and the P12 row done). PR #444, forge CI green on all required jobs, approved and merged by argus (rebase), so the review stage is done; next: close (main CI on the landed commit
7d4fe624). Claim by session:loop-torbscript-20261024 released. Tokens for this run: roughly 180k (estimate).forpass over a flat list (step 2 of #58) #470