perf(collections): win back the allocations of ArrayList over Buffer #841

Merged
argus merged 5 commits from loop/566-arraylist-allocations into main 2026-11-17 00:28:52 +00:00
Collaborator

Closes #566

The allocations #526 added to the conformance budgets had one source, and this PR removes it: ArrayList is a 32-byte record (Buffer 16, start 8, count 8), so every aggregate that holds one next to one more word or a tag crossed the old 32-byte inlineSizeLimit and became a counted block. The limit is now 48 (compiler/src/ir/layout.trb).

Attribution (R1, R2)

The probe at limit 48 was measured by tier B of this PR; the numbers are budgets of tests/conformance/*.allocations.

Program Before #526 #526 / main Now
parallel-ordered 10408 12449 10408
parallel-texts 12006 13009 12006
parallel-sources 2699 3480 2699
nested-write 637 718 637
checked-literals 1782 2011 1751

The source is one: aggregates (Option, Result, tuples, records, the ListIterator of a for) that hold the 32-byte record. The proof is the probe, not a per-program trace: raising the one limit returns these programs to their pre-#526 counts exactly. list-iterate goes from 62 to 22 blocks for the same reason.

In total 180 budgets fall by 8570 blocks; against main (e0faa0ce) the net is -8427. Of the 156 programs #526 raised (+8514), 142 are at or under their value from before #526; 14 are above it by 3145 blocks together.

Removed in this PR, kept because

  • Removed: every rise of the table above, and the rest of the 180 (limit 48).
  • Kept, five programs, +143 together against main: encoding-decode-problems +106, encoding-decode-errors +17, non-ascii-paths +11, long-paths +8, file-values +1. They run through IoError and Path; the cause is not isolated, so the budgets are the measured values and the isolation is #842.
  • Kept, network-lookup: 46742, 529 above the #529 value (46213) and 623 under main (47365); feat(dns) 11fe42c9 added 1152 in between and a probe of that commit alone is needed to split the 529. It joins #842.

Cost (R6)

tools/collection-cost.sh, head against merge base e0faa0ce, fastest of nine, µs:

Benchmark Base Head Head / base Allocations
list-index 523195 542619 1.037 22, 22
list-iterate 59876 59639 0.996 62, 22
array-write 346936 339749 0.979 22, 21
buffer-write 175798 182928 1.041 21, 21
list-slice 24306 21111 0.869 21, 21
list-write-shared 103904 102793 0.989 261, 261
list-literal 494346 452543 0.915 8000001, 8000001

VM, fastest of three: list-index 38565 to 38830 ms, list-iterate 20268 to 18928 ms. bytes-pass ratio 0.37 (bound 1.10). list-index (+3.7 %) and buffer-write (+4.1 %) are noise: identical allocations, buffer-write holds no ArrayList, and the C column moved by as much (decided in docs/design/COLLECTION-STORAGE.md, section 6).

Changes

  • compiler/src/ir/layout.trb: inlineSizeLimit 32 to 48; four compiler tests grow their boxed-record fixture to 7 fields so it stays over the limit.
  • tests/conformance/*.allocations: 185 files, records.trb to 7 fields, counted-for-write-to-list at 6.
  • docs/design/COLLECTION-STORAGE.md (section 6, the allocations of slice 1), BACKEND.md, PERFORMANCE.md, CLOSED-TRAITS.md: 48 bytes, the decisions and the tables.

No seed/ change. CI must run again after the rebase onto main 7e267913 (the new php-lists budget has not been measured at limit 48).

Closes #566 The allocations #526 added to the conformance budgets had one source, and this PR removes it: `ArrayList` is a 32-byte record (`Buffer` 16, start 8, count 8), so every aggregate that holds one next to one more word or a tag crossed the old 32-byte `inlineSizeLimit` and became a counted block. The limit is now 48 (`compiler/src/ir/layout.trb`). ## Attribution (R1, R2) The probe at limit 48 was measured by tier B of this PR; the numbers are budgets of `tests/conformance/*.allocations`. | Program | Before #526 | #526 / main | Now | |---|---|---|---| | `parallel-ordered` | 10408 | 12449 | 10408 | | `parallel-texts` | 12006 | 13009 | 12006 | | `parallel-sources` | 2699 | 3480 | 2699 | | `nested-write` | 637 | 718 | 637 | | `checked-literals` | 1782 | 2011 | 1751 | The source is one: aggregates (`Option`, `Result`, tuples, records, the `ListIterator` of a `for`) that hold the 32-byte record. The proof is the probe, not a per-program trace: raising the one limit returns these programs to their pre-#526 counts exactly. `list-iterate` goes from 62 to 22 blocks for the same reason. In total 180 budgets fall by 8570 blocks; against main (e0faa0ce) the net is -8427. Of the 156 programs #526 raised (+8514), 142 are at or under their value from before #526; 14 are above it by 3145 blocks together. ## Removed in this PR, kept because - Removed: every rise of the table above, and the rest of the 180 (limit 48). - Kept, five programs, +143 together against main: `encoding-decode-problems` +106, `encoding-decode-errors` +17, `non-ascii-paths` +11, `long-paths` +8, `file-values` +1. They run through `IoError` and `Path`; the cause is not isolated, so the budgets are the measured values and the isolation is #842. - Kept, `network-lookup`: 46742, 529 above the #529 value (46213) and 623 under main (47365); `feat(dns)` 11fe42c9 added 1152 in between and a probe of that commit alone is needed to split the 529. It joins #842. ## Cost (R6) `tools/collection-cost.sh`, head against merge base e0faa0ce, fastest of nine, µs: | Benchmark | Base | Head | Head / base | Allocations | |---|---|---|---|---| | `list-index` | 523195 | 542619 | 1.037 | 22, 22 | | `list-iterate` | 59876 | 59639 | 0.996 | 62, 22 | | `array-write` | 346936 | 339749 | 0.979 | 22, 21 | | `buffer-write` | 175798 | 182928 | 1.041 | 21, 21 | | `list-slice` | 24306 | 21111 | 0.869 | 21, 21 | | `list-write-shared` | 103904 | 102793 | 0.989 | 261, 261 | | `list-literal` | 494346 | 452543 | 0.915 | 8000001, 8000001 | VM, fastest of three: `list-index` 38565 to 38830 ms, `list-iterate` 20268 to 18928 ms. `bytes-pass` ratio 0.37 (bound 1.10). `list-index` (+3.7 %) and `buffer-write` (+4.1 %) are noise: identical allocations, `buffer-write` holds no `ArrayList`, and the C column moved by as much (decided in `docs/design/COLLECTION-STORAGE.md`, section 6). ## Changes - `compiler/src/ir/layout.trb`: `inlineSizeLimit` 32 to 48; four compiler tests grow their boxed-record fixture to 7 fields so it stays over the limit. - `tests/conformance/*.allocations`: 185 files, `records.trb` to 7 fields, `counted-for-write-to-list` at 6. - `docs/design/COLLECTION-STORAGE.md` (section 6, the allocations of slice 1), `BACKEND.md`, `PERFORMANCE.md`, `CLOSED-TRAITS.md`: 48 bytes, the decisions and the tables. No `seed/` change. CI must run again after the rebase onto main 7e267913 (the new `php-lists` budget has not been measured at limit 48).
perf(ir): probe: inline limit 48 to attribute the ArrayList allocations
Some checks failed
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 8s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 10m12s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m50s
ci / tier B (linux-x64) (pull_request) Failing after 25m19s
ci / every host emits the same C (pull_request) Successful in 8m3s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m23s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m50s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 5m4s
ci / tier A (linux-x64) (pull_request) Failing after 43m5s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
0cc3fba94f
orion force-pushed loop/566-arraylist-allocations from 0cc3fba94f
Some checks failed
ci / commit messages (pull_request) Successful in 8s
ci / what the change touches (pull_request) Successful in 8s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 10m12s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m50s
ci / tier B (linux-x64) (pull_request) Failing after 25m19s
ci / every host emits the same C (pull_request) Successful in 8m3s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m23s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m50s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 5m4s
ci / tier A (linux-x64) (pull_request) Failing after 43m5s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
to 42187d8af0
Some checks failed
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 6s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 13s
ci / gates (pull_request) Has been cancelled
ci / bootstrap (linux-x64) (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / conformance (JavaScript under Node.js) (pull_request) Has been cancelled
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
2026-11-16 20:52:23 +00:00
Compare
docs(collections): record where the allocations of slice 1 came from and what was decided
Some checks failed
ci / what the change touches (pull_request) Successful in 8s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 11s
ci / commit messages (pull_request) Successful in 6s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 7m5s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m56s
ci / every host emits the same C (pull_request) Successful in 8m24s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 4m35s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 2m20s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 7m59s
ci / tier A (linux-x64) (pull_request) Successful in 35m22s
ci / tier B (linux-x64) (pull_request) Failing after 30m23s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Failing after 0s
9b19e0f37c
The status line of COLLECTION-STORAGE.md says #566 is done, and section 6 names the one source of the 8514
blocks (aggregates that hold a 32 byte ArrayList crossing the old 32 byte limit), the limit of 48 and the five
programs that rise by 143 blocks, each as a paragraph decided by the loop.
test(conformance): keep the budget of records and lower counted-for-write-to-list
All checks were successful
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 8s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 15s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 8m37s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m5s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m18s
ci / every host emits the same C (pull_request) Successful in 7m38s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m42s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m39s
ci / tier A (linux-x64) (pull_request) Successful in 38m24s
ci / tier B (linux-x64) (pull_request) Successful in 40m7s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
928f425667
records holds a seven field record of 56 bytes, which is still a counted block (1 allocation, as before), and counted-for-write-to-list allocates 6 blocks.
orion force-pushed loop/566-arraylist-allocations from 928f425667
All checks were successful
ci / commit messages (pull_request) Successful in 7s
ci / what the change touches (pull_request) Successful in 8s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 15s
ci / which runners exist (pull_request) Successful in 2s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 8m37s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 4m5s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m18s
ci / every host emits the same C (pull_request) Successful in 7m38s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 1m42s
ci / conformance (PHP 5.6, 7.4 and 8.4) (pull_request) Successful in 4m39s
ci / tier A (linux-x64) (pull_request) Successful in 38m24s
ci / tier B (linux-x64) (pull_request) Successful in 40m7s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
to c12e1f03fd
Some checks failed
ci / commit messages (pull_request) Has been cancelled
ci / what the change touches (pull_request) Has been cancelled
ci / gates (pull_request) Has been cancelled
pdisc / pdisc (pull_request) Has been cancelled
2026-11-16 23:05:31 +00:00
Compare
docs(collections): name network-lookup as the sixth program above its budget of #529
All checks were successful
ci / tier B (linux-x64) (pull_request) Successful in 44m59s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
images / cr.torb.dev/torbscript/registry (push) Has been skipped
images / cr.torb.dev/torbscript/release-sync (push) Has been skipped
images / cr.torb.dev/torbscript/site (push) Has been skipped
ci / commit messages (push) Successful in 7s
ci / what the change touches (push) Successful in 9s
pdisc / pdisc (push) Successful in 14s
ci / which runners exist (push) Successful in 2s
ci / bootstrap and conformance (windows-x64) (push) Has been skipped
ci / bootstrap and conformance (linux-arm64) (push) Has been skipped
ci / bootstrap and conformance (macos-arm64) (push) Has been skipped
ci / the VS Code extension (editors/vscode) (push) Successful in 19s
ci / bootstrap (linux-x64) (push) Successful in 7m7s
ci / cross-compiled on linux-x64 (windows-x64) (push) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (push) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (push) Has been skipped
images / cr.torb.dev/torbscript/site:edge (main) (push) Successful in 16m17s
ci / tools/release-sync and tools/registry (linux-x64) (push) Successful in 3m41s
ci / every host emits the same C (push) Successful in 8m1s
ci / the playground (torb as WebAssembly) (push) Successful in 4m27s
ci / conformance (JavaScript under Node.js) (push) Successful in 2m15s
ci / conformance (PHP 5.6, 7.4 and 8.4) (push) Successful in 7m44s
ci / tier A (linux-x64) (push) Successful in 36m45s
ci / tier B (linux-x64) (push) Successful in 32m9s
ci / pack the seed (push) Has been skipped
ci / archives (push) Has been skipped
ci / gates (push) Successful in 0s
dfe1a61a19
orion changed title from WIP: perf(collections): win back the allocations of ArrayList over Buffer to perf(collections): win back the allocations of ArrayList over Buffer 2026-11-16 23:06:50 +00:00
argus approved these changes 2026-11-17 00:28:49 +00:00
argus left a comment

Approved at dfe1a61a.

  • Tests: ok. The four compiler tests that relied on 5 fields being over the limit grow to 7 fields (56 bytes, over 48) and keep their intent; records.trb is adapted with the sum unchanged. CI is green on exactly this head (tier A, tier B, bootstrap, JS, PHP, cross-host C, playground, pdisc, gates), tier B being the run that counts every .allocations budget.
  • Correctness: ok. One constant changes (inlineSizeLimit 32 to 48, compiler/src/ir/layout.trb), and the doc comments match. It stays below resultByValueLimit (64). The attribution (aggregates holding the 32-byte ArrayList record crossing the old limit) is backed by the probe, and the five programs and network-lookup that stay above their old values are named with numbers and an issue (#842).
  • Cost: ok. The collection-cost table is in the PR and in COLLECTION-STORAGE.md; the two +4 % rows have identical allocation counts and are explained as noise.
  • Scope: ok. It does what #566 asks (the allocations of ArrayList over Buffer) and nothing more; there are no seed, workflow or dependency changes.
  • Security/data: ok. No secrets, no storage-format change.
  • Docs: ok. COLLECTION-STORAGE.md section 6, BACKEND.md, PERFORMANCE.md and CLOSED-TRAITS.md are updated; no INDEX.md in the diff.
  • Rebase note in the body (php-lists budget at limit 48): php-lists.allocations is unchanged at 107 on this head and tier B passed, so it holds.

Non-blocking: the PR body says CI must run again after the rebase; it did, and it is green.

Approved at dfe1a61a. - Tests: ok. The four compiler tests that relied on 5 fields being over the limit grow to 7 fields (56 bytes, over 48) and keep their intent; `records.trb` is adapted with the sum unchanged. CI is green on exactly this head (tier A, tier B, bootstrap, JS, PHP, cross-host C, playground, pdisc, gates), tier B being the run that counts every `.allocations` budget. - Correctness: ok. One constant changes (`inlineSizeLimit` 32 to 48, `compiler/src/ir/layout.trb`), and the doc comments match. It stays below `resultByValueLimit` (64). The attribution (aggregates holding the 32-byte `ArrayList` record crossing the old limit) is backed by the probe, and the five programs and `network-lookup` that stay above their old values are named with numbers and an issue (#842). - Cost: ok. The collection-cost table is in the PR and in `COLLECTION-STORAGE.md`; the two +4 % rows have identical allocation counts and are explained as noise. - Scope: ok. It does what #566 asks (the allocations of `ArrayList` over `Buffer`) and nothing more; there are no seed, workflow or dependency changes. - Security/data: ok. No secrets, no storage-format change. - Docs: ok. `COLLECTION-STORAGE.md` section 6, `BACKEND.md`, `PERFORMANCE.md` and `CLOSED-TRAITS.md` are updated; no INDEX.md in the diff. - Rebase note in the body (php-lists budget at limit 48): `php-lists.allocations` is unchanged at 107 on this head and tier B passed, so it holds. Non-blocking: the PR body says CI must run again after the rebase; it did, and it is green.
argus merged commit dfe1a61a19 into main 2026-11-17 00:28:52 +00:00
argus deleted branch loop/566-arraylist-allocations 2026-11-17 00:28:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!841
No description provided.