docs(performance): specify round P11, the counted for over a flat list #416

Merged
argus merged 1 commit from loop/415-p11-counted-for-spec into main 2026-10-23 06:22:08 +00:00
Collaborator

Closes #415

Step 1 of epic #58 (P11). Documentation only: nothing in compiler/, std/, runtime/ or seed/ changes.

docs/PERFORMANCE.md gets section 5.1 "What P11 builds" with decisions 1 to 6, each with its reason:

  1. Where: a new IR pass ir/counted.trb, wired in finishLowering between rewriteElementPlaces and dropProvableChecks; not a branch of lowerForIterate, which runs before the devirtualization and cannot tell the lists apart.
  2. Which lists: the cursors ListIterator, TrieListIterator (std/collections) and BufferIterator (std/core), matched by shape: the same get/index + 1 twenty lines over the IR type Runtime(ListStorage, Item). Everything else keeps its Option.
  3. What the loop becomes: length once, a counter, an unchecked Element read; the increment sits at the top of the body so continue and break keep their edges. Why no bounds panic can occur, and a sentence each for break, continue, tuple pattern, counted item, empty list.
  4. Both back ends: what C (torb_list_item) and the VM (ListItemAddress) execute, and the VM condition.
  5. Measurement: done = list-iterate ratio at most 10% above list-index of the same run, allocations stay 24; did not help = time above two thirds of the main time in the same run. Before numbers are section 4's.
  6. Seed: none expected.

Also: the P11 row names the real files, the status line and the "after the VM" paragraph are updated (the VM exists; P11 still waits for its implementing step), and finding 5's "what is left" and the zero-cost row link the subsection. The step 2 outline is two commits with a cut by cursor.

Where the code differs from the issue's starting decisions (corrected in the record):

  • ConsStack and BankersQueue are a Stack and a Queue, not a List, and have their own cursors; the risk of a quadratic loop is a user List, and RingList (iterates through a pipeline over a range).
  • TrieList is a native type of its own with its own TrieListIterator, not an alias at the type level; it is the same IR type (ListStorage), so it qualifies. BufferIterator qualifies too.
  • list-iterate is a benchmark, not a conformance program, so its allocation check is the --allocations column of benchmarks/run.sh, not an .allocations file.
  • ir/bounds.trb does not apply to list-index (its limit is a constant, not length()), which is why 13.25x is still the right reference.
  • #414 (record for #413, open) keeps a Buffer-window cursor; the record says step 2 re-reads the cursor shape if it lands first.

Seen, not changed (out of scope): finding 5 says torb_list_get is cross-unit, but it is static inline in torb.h; the paragraph "What is left of P8" still says the bounds check is missing while finding 8 and ir/bounds.trb have it; the F5 excerpt names ..._ArrayList_iterator__... where the member is iterate. Step 2 re-reads all three from torb ir.

Test: python3 tools/pdisc/scripts/pdisc.py check ok, tools/check-commits.sh origin/main ok. Not run locally: torb docs check docs, torb docs index --check docs, torb docs skill docs skills --check (no torb binary in the sandbox); forge CI runs them. skills/ does not mirror PERFORMANCE.md.

Closes #415 Step 1 of epic #58 (P11). Documentation only: nothing in `compiler/`, `std/`, `runtime/` or `seed/` changes. `docs/PERFORMANCE.md` gets section 5.1 "What P11 builds" with decisions 1 to 6, each with its reason: 1. **Where:** a new IR pass `ir/counted.trb`, wired in `finishLowering` between `rewriteElementPlaces` and `dropProvableChecks`; not a branch of `lowerForIterate`, which runs before the devirtualization and cannot tell the lists apart. 2. **Which lists:** the cursors `ListIterator`, `TrieListIterator` (`std/collections`) and `BufferIterator` (`std/core`), matched by shape: the same `get`/`index + 1` twenty lines over the IR type `Runtime(ListStorage, Item)`. Everything else keeps its `Option`. 3. **What the loop becomes:** `length` once, a counter, an unchecked `Element` read; the increment sits at the top of the body so `continue` and `break` keep their edges. Why no bounds panic can occur, and a sentence each for `break`, `continue`, tuple pattern, counted item, empty list. 4. **Both back ends:** what C (`torb_list_item`) and the VM (`ListItemAddress`) execute, and the VM condition. 5. **Measurement:** done = `list-iterate` ratio at most 10% above `list-index` of the same run, allocations stay 24; did not help = time above two thirds of the `main` time in the same run. Before numbers are section 4's. 6. **Seed:** none expected. Also: the P11 row names the real files, the status line and the "after the VM" paragraph are updated (the VM exists; P11 still waits for its implementing step), and finding 5's "what is left" and the zero-cost row link the subsection. The step 2 outline is two commits with a cut by cursor. **Where the code differs from the issue's starting decisions (corrected in the record):** - `ConsStack` and `BankersQueue` are a `Stack` and a `Queue`, not a `List`, and have their own cursors; the risk of a quadratic loop is a user `List`, and `RingList` (iterates through a pipeline over a range). - `TrieList` is a `native type` of its own with its own `TrieListIterator`, not an alias at the type level; it is the same IR type (`ListStorage`), so it qualifies. `BufferIterator` qualifies too. - `list-iterate` is a benchmark, not a conformance program, so its allocation check is the `--allocations` column of `benchmarks/run.sh`, not an `.allocations` file. - `ir/bounds.trb` does not apply to `list-index` (its limit is a constant, not `length()`), which is why 13.25x is still the right reference. - #414 (record for #413, open) keeps a `Buffer`-window cursor; the record says step 2 re-reads the cursor shape if it lands first. Seen, not changed (out of scope): finding 5 says `torb_list_get` is cross-unit, but it is `static inline` in `torb.h`; the paragraph "What is left of P8" still says the bounds check is missing while finding 8 and `ir/bounds.trb` have it; the F5 excerpt names `..._ArrayList_iterator__...` where the member is `iterate`. Step 2 re-reads all three from `torb ir`. Test: `python3 tools/pdisc/scripts/pdisc.py check` ok, `tools/check-commits.sh origin/main` ok. Not run locally: `torb docs check docs`, `torb docs index --check docs`, `torb docs skill docs skills --check` (no torb binary in the sandbox); forge CI runs them. `skills/` does not mirror PERFORMANCE.md.
docs(performance): specify round P11, the counted for over a flat list
All checks were successful
pdisc / pdisc (pull_request) Successful in 10s
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
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 16s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
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 / every host emits the same C (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / tier A (linux-x64) (pull_request) Successful in 6m10s
ci / pack the seed (pull_request) Successful in 10s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
b5ab08bd9d
Adds section 5.1, What P11 builds: the pass sits between rewriteElementPlaces and dropProvableChecks in finishLowering, takes the cursors of the flat runtime list by shape, writes length once, a counter and an unchecked Element read, and names the done and did-not-help numbers from section 4. Corrects the P11 row and the stale after-the-VM wording; links the subsection from finding 5 and the zero-cost contract.

Refs #415, #58
argus approved these changes 2026-10-23 06:21:59 +00:00
argus left a comment

Approved. Checklist for head b5ab08b:

  • Tests/CI: docs-only change; combined status success (pdisc, commit messages, gates, tier A, bootstrap linux-x64). Skipped jobs are path-filtered.
  • Scope: one file, docs/PERFORMANCE.md, exactly the acceptance criteria of #415 (section 5.1 with decisions 1-6, P11 row, F5 "what is left" and zero-cost row links, status line, "after the VM" sentence). Nothing in compiler/, std/, runtime/, seed/.
  • Correctness: spot-checked against the repo at this head. finishLowering runs devirtualizeProgram, rewriteElementPlaces, dropProvableChecks, dropUncalledMembers in the order the record relies on. ir/elements.trb, ir/bounds.trb and tests/conformance/list-bounds-proven.trb exist. ir/counted.trb is correctly described as new. Deviations from the issue (ConsStack/BankersQueue, TrieList, benchmark vs conformance allocations) are stated openly.
  • Security/data/architecture: n/a (docs only; no new boundary). No invented numbers: the before figures are section 4s.
  • Docs: frontmatter/pdisc check green; step 2 outline and the cut by cursor are given. Release/after-merge: none.

Non-blocking: none.

Approved. Checklist for head b5ab08b: - Tests/CI: docs-only change; combined status success (pdisc, commit messages, gates, tier A, bootstrap linux-x64). Skipped jobs are path-filtered. - Scope: one file, `docs/PERFORMANCE.md`, exactly the acceptance criteria of #415 (section 5.1 with decisions 1-6, P11 row, F5 "what is left" and zero-cost row links, status line, "after the VM" sentence). Nothing in `compiler/`, `std/`, `runtime/`, `seed/`. - Correctness: spot-checked against the repo at this head. `finishLowering` runs `devirtualizeProgram`, `rewriteElementPlaces`, `dropProvableChecks`, `dropUncalledMembers` in the order the record relies on. `ir/elements.trb`, `ir/bounds.trb` and `tests/conformance/list-bounds-proven.trb` exist. `ir/counted.trb` is correctly described as new. Deviations from the issue (ConsStack/BankersQueue, TrieList, benchmark vs conformance allocations) are stated openly. - Security/data/architecture: n/a (docs only; no new boundary). No invented numbers: the before figures are section 4s. - Docs: frontmatter/pdisc check green; step 2 outline and the cut by cursor are given. Release/after-merge: none. Non-blocking: none.
argus merged commit 301f2149eb into main 2026-10-23 06:22:08 +00:00
argus deleted branch loop/415-p11-counted-for-spec 2026-10-23 06:22:08 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
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!416
No description provided.