collections: win back the allocations of ArrayList over Buffer, and its cost table (follow-up of #526) #566
Labels
No labels
loop
queue/failed
queue/queued
ready
status/parked
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
torbscript/language#566
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
Follow-up of #526 (PR #529, step 3 of #55; it is step 3b of the epic's checklist).
ArrayListoverBufferraises the allocation budget (.allocations) of 156 conformance programs by +8514 blocks in total: PR #529 records old and new counts per program in its body and raises the budgets as a deliberate cost of slice 1. The four largest rises arenetwork-lookup+2106,parallel-ordered+2041,parallel-texts+1003 andparallel-sources+781 (together 5931, 70 % of the total); the other 152 programs rise by 1 to 229 blocks each, most of them by under 10. #526's acceptance asked that no budget rises and that the PR prints thetools/collection-cost.shtable (record section 6, "no slower than before"); neither is met by #529.What is already known, from
std/collections/src/list.trbanddocs/PERFORMANCE.mdsection 1.1:ArrayListrecord is three words (items: Buffer,start,count, 24 bytes), so it isInline(at most 32 bytes): the record itself is not a block. The extra blocks come from somewhere else, and nobody has measured where. Candidate sources, to be confirmed or dropped by measurement and not assumed: the adoption of runtime lists throughArrayList.over(what the natives ofnetwork-lookupandparallel-*hand over), a window made bysliceand then rebased byown()on the next write (items.slice(...)is a copy),window()inreplace/compact, theListIteratorof a loop that is not counted (it holds the whole record, 32 bytes, on the edge of the inline limit), and a list that stays shared with a live iterator or slice when it is written (Buffer.appendandBuffer.setcopy while the storage has a second owner).a[i][j] = vanda[i].f = von anArrayListtakes the read-modify-write round trip until #565 lands, which copies the inner value once per write; the rises ofnested-write,list-update-nested,array-matrix,counted-for-write-to-listandcollection-placesmay be that and not this issue's.Goal
The extra blocks of the record over
Bufferare attributed per source, every source the lowering or the std bodies can avoid is removed, every budget that drops is lowered, and the cost of slice 1 is measured and printed.Design record point
docs/design/COLLECTION-STORAGE.mdsection 6 ("no slower than before", the allocation count of a program must not rise, the table of benchmarks), decisions 1 to 5 (the record, the shared slice and its rebase, literals andfor), section 8 slice 1 (done by #526; this finishes its cost clause). Epic #55, step 3b;docs/ROADMAP.mdnames the epic's criterion "Benchmarks no slower than before", which rests on this issue.Requirements
ArrayList.over, rebase of a window, iterator record, shared storage copied on a write, round trip of an element write), with the blocks per occurrence and the programs affected, measured in the forge CI (tier B conformance counts,sh benchmarks/run.sh --allocationsfor the benchmarks) and not guessed; the table is in the PR body.network-lookup,parallel-ordered,parallel-texts,parallel-sources) and one small program of each family among the rest (a literal, a slice, a nested write, an iterator), so the long tail of small rises is explained by the same sources.std/collections/src/list.trbor in the lowering (ir/lower/collection.trb, the counted loopir/counted.trb,ir/instantiate.trb) without a new native, a new syntax form or a new name the compiler looks up by string, the PR shall remove it; the observable behaviour (record section 2, rule 1) shall not change.decided by the loopparagraph with its blocks per occurrence and the budgets that keep it, and shall file aloopissue for any avoidable remainder that needs about 1 h or more..allocationsfile to the count CI measures (sh tools/conformance.sh --update-budgetsis the author's tool; the worker reads the counts from the tier B log, whose closing note names every program under its budget, and writes the numbers, never runs the suite locally).tools/collection-cost.shtable of tier B (fastest of nine runs, merge base against branch, the same job) forlist-index,list-iterate,array-write,buffer-write,bytes-pass,list-slice,list-write-shared,list-literal, with the baselines of #468 as reference; a row worse than 1.00 plus the script's own run-to-run noise shall be fixed or decided with the numbers in COLLECTION-STORAGE.md, as record section 6 says.docs/design/COLLECTION-STORAGE.mdshall be updated: the status line (its element steps and its allocations are open) and section 6 shall say what was measured and what remains.Acceptance criteria
network-lookup+2106 down toencoding-decode-problems+115) is removed or recorded under R4; the sum of the remaining rises against the pre-#529 budgets is stated in the PR, and it is smaller than +8514 by every block removed..allocationsfiles of every program whose count dropped are lowered to the counts of the tier B log; no budget is above the value #529 set; the conformance gate (.allocationsexact or below) is green.list-slicefor a type without a destructor still equals the shared form, andlist-literalstill allocates once per literal.slice-close-genericanddestructor-slice-concrete(theClose-item programs of #468) still pass; the conformance programs and doc tests run unchanged, and thetorb run --vmresults oflist-indexandlist-iterateare reported and not wider than onmain(#482 stays its own issue).std/collectionschanged, the regenerateddocs/standard-librarypages andskills/(torb docs skill docs skills).Seed
No expected: the work uses forms the seed already reads (bodies in
std/collections, recognition by shape incompiler/src/ir). If a source can only be removed with a new native, a syntax form or a name the compiler looks up by string, that part is not in this PR: record it under R4 and file it as its ownloopissue (two-commit rule, seed refresh stays Torben's).Size
One PR, one or two Conventional Commits:
perf(collections): ...orperf(ir): ...for the removals with the lowered budgets and the doc update, and the cost table in the PR body (no code). Attribution happens first, on the PR branch opened as a draft, read from the CI logs; the removals follow in the same PR. The worker never runs the bootstrap, the gates or a LTO build in its own exec (CI only); locally onlytorb format --checkon touched files.Dependencies
compiler/src/ir/elements.trb,ir/explain-copies.trb,ir/counted.trb,compiler/tests/harness.trb,tests/command-line/copiesand the status line of COLLECTION-STORAGE.md, and it removes the round trip of an element write on anArrayList, which may by itself lower the budgets of the nested-write programs. Consequences for the work: (a) start frommainas it is then; if #838 has merged, rebase on it and take the attribution on top of it, so its share is not counted as this issue's; (b) if #838 is still open when the work starts, do the attribution of R1 and R2 on a branch offmain, do not edit the files #838 touches, and if a removal needs one of them, commentwaiting (PR #838)instead of stacking on its branch or duplicating its change; (c) rebase over #838 before the budgets are written, because both PRs edit.allocationsfiles and the COLLECTION-STORAGE.md status line.list-iterate) is related, not a blocker.Out of scope
TrieListand the other slices of #55 (slices 2 to 7), rewriting the five bulkBufferrows, #482, the seed refresh, any change that moves observable behaviour or a documented cost.Decided by the loop
loopissues (R4).[loop:orion] labelled
loop: live-design follow-up of #526 / PR #529 (epic #55), filed by an interactive session without the label. Not superseded; no retirement.[loop:torbscript] intake: in scope (author orion, label loop), measurement and allocation follow-up of #526 (epic #55); not a duplicate (#565 is the element-step/--explain-copies half), no collision with a design record (COLLECTION-STORAGE.md is the spec). No seed impact expected. next: refine (queued, dependency #526 / PR #529 landed)
ArrayList, the hash tables and the tries onBuffer#55ArrayList, the hash tables and the tries onBuffer#55ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] refine: next: waiting (the ready buffer is full, 12 ready of 4; refinement resumes when it drains)
ArrayList, the hash tables and the tries onBuffer#55ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] claim refine by session:loop-torbscript-566-refine until 2026-11-16T17:00:00Z
Reason: the ready buffer fell to 3 of 4 (#836, #565, #365) and #566 was starved (deferred 3 times); one refine fits.
whereclause with a concrete subject, andinto()under anIntobound #748[loop:torbscript] decided by the loop: #566 is performance work with a measurable outcome, so no owner question. The body now has EARS requirements R1 to R7, acceptance criteria that CI can check, the seed answer (no) and one PR as its size. The attribution of the +8514 blocks is measured in forge CI first (the record is an inline 24-byte struct, so the extra blocks are not the record itself), removals follow in the same PR, what cannot be removed is recorded with its numbers in COLLECTION-STORAGE.md. Dependency made explicit: PR #838 (#565) is open and not merged; it edits
ir/elements.trb,ir/explain-copies.trb,ir/counted.trb, the harness and the same.allocations/ status-line files, so the worker rebases on it if it has landed, and otherwise does not edit those files and waits on it instead of stacking.[loop:torbscript] release by session:loop-torbscript-566-refine
refine: #566 brought to the definition of ready (goal, EARS requirements, checkable acceptance criteria, design record points, seed: no, size: one PR, dependency on PR #838 explicit) and labelled
ready. next: ready[loop:torbscript] implement: held until PR #838 (#565) is merged, because both change the ArrayList element-step passes and this issue builds on them; implementation starts on the merged main. next: waiting (PR #838 merge gate)
?in a body whose result type is inferred #747[loop:torbscript] claim implement by session:loop-torbscript-566-impl until 2026-11-17T01:30:00Z Reason: PR #838 (#565) is merged and main is fixed by #840 (main CI running); one worker slot free, ready issue. The worker implements on current main in one PR.
[loop:torbscript] release by session:loop-torbscript-566-impl implement: the worker ran into its 3 h limit while PR #841 (head
928f4256, draft, measurement probe at inline limit 48) was waiting on tier B of the forge CI; the PR is open and still WIP, the attribution and cost tables are not written yet, next: implement (fresh worker continues on PR #841)[loop:torbscript] claim implement by session:loop-torbscript-566-impl2 until 2026-11-17T05:30:00Z Reason: PR #841 is open as a draft with a pending forge CI; a fresh worker continues on the same branch: reads the tier B log, writes the attribution and cost tables (R1, R2, R6), lowers the budgets and takes the PR out of WIP.
[loop:torbscript] release by session:loop-torbscript-566-impl2 implement: PR #841 is complete and out of draft (head
dfe1a61a, rebased onto main7e267913), but the forge CI has not finished: gates, tier A, tier B, pack the seed and archives were still pending after about 60 minutes (the runs waited about 40 minutes for a runner). Left: wait for green CI ondfe1a61a, in particular tier B, because the budget of the newphp-listsprogram has not been measured at inline limit 48 and a budget that does not match fails conformance; then request Argus's review. What changed this round: the cost table (R6) and the noise decision are indocs/design/COLLECTION-STORAGE.mdsection 6 and in the PR body, with the attribution table (R1/R2);network-lookupis a sixth program above its #529 value (46742 against 46213, 623 under main) and joins #842. next: ci-wait on PR #841, then review