collections: design record for ArrayList, the hash tables and the tries on Buffer (step 1 of #55) #413
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 #55 (collections: rebuild
ArrayList, the hash tables and the tries onBuffer; ROADMAP "The kernel of natives", COLLECTIONS gap 6).Buffer<Item>is built (#54, #299, #300), but #55 is not one PR: the compiler namesArrayListin about 200 places (list literals, the element access and write lowering, theArrayList.*rows ofcompiler/src/backend/c/natives.trb,RuntimeKind.ListStorage),HashMapandHashSetstand onruntime/map.c(open addressing, tombstones, insertion order) which #56 is changing right now (torb_map_slot), andTrieList,TrieMapandTrieSetare today documented aliases of the flat storage, not tries. What the rebuilt types look like, in which order, and what each step must not cost is not written down. That has to be decided in writing before any native is removed. This step is documentation only.Goal
A design record
docs/design/COLLECTION-STORAGE.mdthat specifies howArrayList, the hash tables and the tries are written in TorbScript overBuffer, and cuts the work into slices, each one PR.Acceptance criteria
docs/design/COLLECTION-STORAGE.mdexists with pdisc frontmatter, a status line ("designed, not built") and an entry indocs/design/index.md; COLLECTIONS gap 6 and ROADMAP "The kernel of natives" link it;docs/regeneratesskills/(torb docs skill docs skills, a tier A gate).ArrayList: the record decides the representation (a TorbScript type holding aBuffer, or the compiler's list type staying a primitive whose members are bodies per #53) and says what happens to the three things the rewrite touches: the O(1) sharedsliceagainstBuffer.slicecopying,withCapacityas the one native the lowering answers itself, and list literals andforover a concreteArrayList(COLLECTIONS gap 9). Each is a numbered decision with its reason; a decision that costs speed names the benchmark that proves it acceptable.HashMapandHashSetas TorbScript overBuffer(entry vector, bucket array, tombstones, compaction, insertion-order iteration,entryAfteranditemAfteras the iteration contract), checked against whatruntime/map.cdoes today; how it meets #56 (the slot access ofmap[key] = value) and in which order the two land.TrieList,TrieMapandTrieSetare aliases of the flat storage today and decides whether the rewrite builds real persistent tries (COLLECTIONS 3.10 "copy on write, per structure") or keeps the aliases on the rewritten types. Either way the observable behaviour (order,Show, equality) is unchanged.benchmarks/list-index,list-iterate,array-write,buffer-write,map-count,bytes-pass, plus any new one the record names. The bound is "no slower than before" read as a ratio on the same forge CI runner (the pattern oftools/buffer-cost.sh: fastest of nine runs, measurement and not a gate). A slice whose measured ratio is worse is not landed until the record's decision for it is revisited with the numbers.ArrayList.*,HashMap.*,HashSet.*,Trie*.*rows that each slice removes from the manifest are named, with the migration order owed to the audit table of #52 (docs/design/NATIVES.md, #407, if landed; otherwise the manifest itself) and to #53 where a kernel native becomes a body.Design record point
COLLECTIONS gap 6 and 3.7 / 3.10; ROADMAP "The kernel of natives"; BACKEND 3.5 (the container natives) and 3.7 (the manifest); PERFORMANCE round P9 (#56) for the map.
Seed impact
None for this step (documentation only). The later slices add or remove natives the compiler looks up, so they fall under the two-commit rule.
Size
One PR, one Conventional Commit (
docs(collections): design record for ArrayList, the hash tables and the tries on Buffer).Out of scope
Any change to
std/,runtime/orcompiler/; running the benchmarks (the record names them and takes today's numbers from the published performance tables or states that the first implementing slice records them); the seed;BytesandWindow(done, #300 and #4).Dependencies
None hard. Read
docs/design/NATIVES.md(#407) and the record of #410 if they have landed. Part of #55; #56 changesruntime/map.cconcurrently, so the hash table section must be written against its landed shape.ArrayList, the hash tables and the tries onBuffer#55[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T10:41:00Z
forover a flat list in PERFORMANCE.md (step 1 of #58) #415forover a concrete list is a counted loop #58std/tensoron the CPU #82Buffer.holdsClose(step 2 of #55, commit 1 of 2) #468ArrayList, the hash tables and the tries onBuffer#55forpass over a flat list (step 2 of #58) #470forpass over a flat list (step 2 of #58) #470forpass over a flat list (step 2 of #58) #470forpass over a flat list (step 2 of #58) #470forpass over a flat list (step 2 of #58) #470ArrayListis a type overBuffer(step 3 of #55, commit 2 of 2) #526ArrayList, the hash tables and the tries onBuffer#55