TODO
Cleanup / symmetry items noticed during the Round-6 perf work. None are
blocking; recorded so they aren't lost. (Forward-looking perf levers —
copy-and-patch codegen, 16B Tok, the writev object-output micro-lever —
live in doc/plan/PERF.md, not here.)
Container facility symmetry
KIT_HASHSET_DEFINElacks_reserve. Round-6 addedNAME##_reserve(m, n)toKIT_HASHMAP_DEFINE(include/kit/support/hashmap.h) so a bulk insert with a known count skips the resize cascade. The hashset variant in the same file was not given the matching primitive. Mirror it (same body: growcapto holdnat the load factor, power-of-two) if/when a set needs it — don't ship it unused.SegVechas no_reserve. The object readers now pre-size theSymNameIndexhashmap (obj_reserve_symbols), but the parallelSymbols(src/obj) /LinkSyms(src/link) segvecs still grow one 64-entry segment at a time — ~16k small allocations for a 1M-symbol object. ASEGVECreserve (pre-allocate ⌈n/seg⌉ segments) would cut that alloc churn on large ingests. Touch points:src/core/segvec.h, the readers insrc/obj/*/read.c, andlink_resolve_symbols.
Linker symbol-map pre-sizing (partial)
- Only
img->globalsgotsymhash_reserve(link_resolve.c). The othersymhash_init-without-capacity maps —alias_map(link_resolve.c:~401),defined/undefs(link_resolve.c:~1139),globals_by_name(link_relocatable.c:~451) — could pre-size from a known count for consistency. Lower value (the measured resize churn wasimg->globals+ the readerSymNameIndex); do it if a profile shows them.
Object-emitter de-duplication (macho / elf / coff)
- The three
src/obj/*/emit.ccarry near-identical code: thestrtab_addlinear-dedup (flatten-to-search), the final strtab flatten+write, and the section-bytes write loop. A small sharedsrc/objhelper would de-triplicate them. NB: streaming each section'sBufchunks instead of flatten-to-onewrite()was tried and is slower (more syscalls) — keep the single big write; only the dedup is wanted here.