ReviewOS

home-lang/home

perf(ts): group require binding candidates in the declaration index

#849
Closed chris opened this 8 days ago ·
8 days ago

Parent #416; profile evidence and rejected whole-path indexes #848. The retained CommonJS scale1024 sample from compiler206 shows requireSpecifierForLocal repeatedly scanning root statements while checking typed member reads. Source still scans every statement for a local name, preserving earliest same-section static require candidate before the anchor and a cross-section fallback only if preceding candidate specifiers agree. Existing local_value_decls_by_container stores first declaration/boundaries, so replacing this with a first-declaration shortcut would be incorrect for duplicate non-require/require declarations or import-equals aliases.

Candidate: lazily group require candidates by local name inside the existing per-container declaration-index ownership, retaining statement order, source spans and virtual-section data. No benchmark/name-specific branches, numeric cap, approximate type lookup or discarded diagnostics. Preserve source-index invalidation and cleanup; on allocation failure, retain the complete original scanner rather than an empty guessed result. Add equivalence controls for duplicates, before/after positions, import-equals, same/cross-section ambiguity, nonliteral/member-call lookalikes, replacement and failure. Freeze current774f72f16 baseline and use exact-parent fair A/B plus all-family warnings and independent confirmation; preserve full suites/production identities and document accepted or rejected results including README table. No speedup/fix claimed yet.

8 days ago

The grouped require-candidate draft is implemented inside existing LocalValueContainerIndex ownership, without adding a new top-level Checker field. It stores every static require/import-equals candidate in root statement order with section/span data; query preserves same-section priority, preceding-position filtering and the original cross-section fallback/conflict behavior. Index construction failures return to the retained complete scanner; cleanup and setSource invalidation share the declaration index. Equivalence controls compare old/new on every HIR node across names, duplicates, export wrappers, import-equals, virtual sections, nested roots and call lookalikes; allocation-failure/retry controls retained. Full checker 4510/4510 passed (3193 MB). Current774 parent build passed; candidate native build is still confirmed live. No timing, source push or speed claim yet. Local evidence /Users/chris/.cache/home-ts-require-index.oJrQbs.

8 days ago

Both pinned774 parent and candidate native builds completed successfully. Full checker 4510 passes, including exhaustive old/new require-candidate equivalence and allocation-failure/retry controls. Candidate frozen SHA e5d30ddd69735acece9a11a508984dcb3dcd3db83a78c9e5ea20a56a11fdedfa; parent21ba2e0076ba929758d40b886b5ce1a951e5391cfd8a60e33382c74d408eafa8. Initial screen/Program/Zod commands were refused before execution at 951 MB free (guard123, requires1024); all logs retained. Current disk1649 MB meets unchanged floor, so actual retries are live/queued without relaxing caps or removing user files. No benchmark result, source push or speed claim yet.

8 days ago

Actual retries completed after unchanged disk floor was met. Full Program241/241 passed. Complete current774-parent/candidate Zod identity multisets match (raw commands/outputs retained; no production admission). First same-input screen is inconclusive: official CommonJS medians29.727 ->29.304 ms,12/20 faster pairs,saving interval -0.064 to+1.166 ms; scale1024 medians975.232 ->944.932 ms,4/6,interval -116.246 to+243.612 ms. Large scale variance is retained, not discarded. Independent confirmation and all20-family screen now queued; no speed claim or source push. Both frozen binaries, input/harness/runner/tool hashes stayed identical before/after screen, all56 admissions passed. Initial guard123 refusals remain alongside actual retries.

8 days ago

Independent exact774-parent confirmation remains inconclusive: official CommonJS31.103 ->31.754 ms,14/30 faster pairs,saving interval -0.982 to+0.403 ms; scale1024 466.329 ->456.312 ms,7/10,-5.487 to+25.031 ms. All20-family ten-pair screen completed and no >3%-slower median selected a threshold recheck. This does not prove regression freedom or benefit. Full checker4510/4510 and Program241/241 pass; complete parent/candidate Zod multisets identical198 entries (195 TS+3 HM9002), no production admission. Both native builds pass and all56 admissions in each timing phase pass with stable fingerprints. Initial123 disk refusals and variable scale screen retained. Candidate remains uncommitted; no speedup claim or push until broader gate/cost review and evidence/docs publication. Source774 and exact patch/binary hashes retained at /Users/chris/.cache/home-ts-require-index.oJrQbs.

8 days ago

Landed on main in 74b181394.

The existing per-container declaration index now owns a flat ordered arena of static require/import-equals candidates plus per-local-name linked buckets. Queries preserve anchor ordering, same-section precedence, cross-section agreement/conflict behavior, exported declarations, nested-root exclusion, and dynamic/member-call rejection. The retained complete scanner is used on every allocation failure; source replacement releases the new state through the existing owner.

Verification:

  • exact benchmark candidate: checker 4,511/4,511, Program 242/242, driver 200/200, CLI 74/74, tsc_main 35/35
  • after clean integration with concurrent #842 work: checker 4,521/4,521
  • pinned Zod 4.5.2: identical normalized 195 TS + 3 HM9002 diagnostics across 106 production files
  • supported stripped ReleaseFast build passed; all successful work remained below the 3,840 MB guard

Exact-parent A/B against 5976d10d3 retained every sample. Official CommonJS and both 1,024-family intervals span zero and remain inconclusive. The independent 4,096-family confirmation measured parent 6,103.936 ms versus candidate 5,980.145 ms, 22/30 lower candidate pairs, paired mean saving 116.249 ms, 95% interval +23.185 to +209.313 ms. Seven independent regression rechecks all span zero.

README and the full report now state those boundaries explicitly. Raw evidence: 20261008T181346Z-require-binding-index-849.tar.gz, SHA-256 3ef88a53c0e54347e486e4d87f865dd6cccba20f688b0856e6f925c51434e9bb, 5,701 verified payload checksums. The expanded cross-compiler matrix remains separate and open under #838.

Sign in to comment on this issue.