perf: P11 step 1 - specify the counted for over a flat list in PERFORMANCE.md (step 1 of #58) #415
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
Step 1 of #58 (perf: P11 - a
forover a concrete list is a counted loop; PERFORMANCE.md finding F5 level 2, section 5 round P11). #58 is not one PR: the round table givesir/lower/statement.trbas its only file, but the loop that matters is writtenfor value in numberswithnumbers: List<Int>(benchmarks/list-iterate), and the lowering runs beforedevirtualizeProgram, so at that point it cannot tell anArrayListfrom aListwhoseatwalks (ConsStack,BankersQueue). Where the counted loop is made, which lists qualify and what it must not change is not written down yet. That has to be decided in the design record before the code is written. This step is documentation only.Goal
A subsection "What P11 builds" in
docs/PERFORMANCE.md(after "What P7 built"), and a corrected P11 row in section 5, that specify the round precisely enough for one implementing PR (step 2, filed when this one lands).Decisions the record starts from (decided by the loop, check them against the IR excerpts of finding F5 and
compiler/src/ir/elements.trb, correct them where the code says otherwise)devirtualizeProgramandinsertOwnership, next torewriteElementPlaces(the shape of P7), not a branch oflowerForIterate. The lowering cannot see the concrete type; the devirtualization has made the cursor aRecord(ListIterator<...>)with a directnextcall by then. The P11 row's file column changes to the new pass file and the pipeline wiring.ArrayListiterator (and theTrie*aliases while they are aliases of it). ARingList,ConsStack,BankersQueue,Array, map, set,String.chars()and every userIteratekeep their cursor: an indexed read of a persistent list is not O(1), and the counted loop must never make a loop quadratic. A cursor that stayed boxed keeps its dispatch.lengthread once at loop entry, a counter, and the item read by theElementstep of P7 instead of theOptionofnext. The subject is a value held by the frame for the whole loop (the comment oflowerForIteratesays so), so the length cannot change under it and no bounds panic can occur; the record says why the panic site ofIndex.atis therefore not needed.break,continue, a tuple pattern, an item that is a counted value (retain per turn) and an empty list each get a sentence.list-iteratemust not get worse.benchmarks/list-iterateratio against its C twin falls to the level ofbenchmarks/list-indexof the same run (the table of section 4 has 39.09x against 13.25x), allocations stay 24, recorded before and after in the forge CI asbenchmarks/run.shprints it (fastest of several runs, a measurement and not a gate). The record names the number that counts as "done" and the one that counts as "it did not help".compiler/src/ir/<pass>.trb, wiring in the pipeline, an IR snapshot test of the loop, conformance programs for the cases of decision 3,list-iterate.allocationsbudget check, PERFORMANCE.md status updated. Sized for one PR of two Conventional Commits; the record says where to cut if it is more.Acceptance criteria
docs/PERFORMANCE.mdhas "What P11 builds" with numbered decisions 1 to 6 above (corrected where the code differs), each with its reason, and section 5's P11 row names the real files.for value in collectionas a whole link the subsection.torb docs check docs,torb docs index --check docsand theskills/regeneration are green in both CI tiers.Design record point
PERFORMANCE.md finding F5 (level 2), round P11, section 2 row "
for value in collectionas a whole"; COLLECTIONS gap 9; P7 (ir/elements.trb).Seed impact
None (documentation only).
Size
One PR, one Conventional Commit (
docs(performance): specify round P11, the counted for over a flat list).Out of scope
Any change to
compiler/,std/orruntime/; running the benchmarks (the record uses section 4's numbers and says the implementing step records the new ones); the seed; theOptionofgetand the bounds check ofa[index](finding 8); #56 and #59; the ArrayList-on-Buffer rewrite of #55/#413 (read the record of #413 if it has landed and align gap 9 with it, do not change it).Dependencies
None hard. Part of #58.
forover a concrete list is a counted loop #58forover a concrete list is a counted loop #58[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T11:03:00Z
[loop:torbscript] implement: PR #416 (#416) is open and mergeable; the worker ended at its run limit while forge CI was still queued on head
b5ab08b. next: waiting (CI on PR #416, then review by argus)forover a concrete list is a counted loop #58forpass over a flat list (step 2 of #58) #470forover a concrete list is a counted loop #58