Index operation inputs once during IR validation #52
Labels
No labels
area/cli
area/core
area/database
area/indexing
area/query
type/epic
type/feature
type/foundation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
JayKobe6k/ClariTree#52
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?
Problem
IR validation at
TranslationUnitBuilder::finishrepeatedly scans every operation input for each operation and again for each definition site. On large generated C translation units this creates avoidable parser work even though each input already identifies its consumingOperationId.Baseline
5f33e130a596e98453380dc92fdfd92e6e41acd6:validate_operation_relationshipsfilters the fulloperation_inputsvector once per operation.validate_definition_sitesrebuilds operation/reference indexes and delegates tohas_definition_input, which scans the full input vector for each definition site.cpu_core/cyclesself samples tovalidate_operation_relationships.Environment and workload
5f33e130a596e98453380dc92fdfd92e6e41acd6.melee-event-matchat6b6f8a8a987c2e871b8b96baa863aaa99e406f33.compile_commands.jsonSHA-256:0c025066b2f5ed7940a668d4fc97b912d8eb5d467fb7bb33ba0e72ab7d50ea16.MemoryMax=8G,MemorySwapMax=0,RuntimeMaxSec=240.c2a52ce75663200b3d92a4f4df94f681ed1a54fc4aaf132bd11fb9c646d786cd.c144f530bce4296ed4544ffda40ee12a6735c520f64083f9c9f486ccd781b8a4.49bf027d3d6f8e1bc290e621c82520a5862730583f2eb367ce20b44d108ea44f.Reproduction command shape:
Baseline and profiling evidence
Three interleaved non-profiled first-200-TU runs:
Two matched first-200-TU counter pairs, run in both orders:
The final post-lint-refactor artifact was confirmed in an additional baseline/candidate pair: parse 42.476 s to 40.430 s (-4.82%), task clock 67,215.58 ms to 64,611.12 ms (-3.87%), cycles 186,291,406,084 to 178,898,630,407 (-3.97%), and instructions 621,141,527,610 to 605,026,869,043 (-2.59%).
Every run preserved exact parser facts, 377,067 lineage definitions, 412,330 uses, and 801,507 relationships. Peak memory remained 3.9 GiB with zero cgroup swap.
The candidate profile still reports
validate_operation_relationshipsat 2.07% self. That percentage is not compared directly because the baseline and candidate profiles used materially different hybrid-PMU sample counts; controlled timings and counters are the acceptance evidence.Root cause
For
Ooperations,Iinputs, andDdefinition sites, shape and definition-target validation performs approximatelyO*I + D*Iinput examinations. The relationships are already keyed byOperationId, so this work can be grouped once in input order and reused.Proposed implementation
HashMap<OperationId, Vec<&OperationInput>>during the existing ordered input-validation pass.Alternatives considered:
Expected effect and risks
HashMap/per-operationVecoverhead.Acceptance criteria
operation_inputsvector per operation/site.cargo fmt --all -- --check,cargo lint,cargo test --all-targets --all-features,cargo doc --no-deps --all-features, and Windows GNU all-target/all-feature checking pass throughnix develop.Rollback
Revert the validation-local input index and helper plumbing. No persisted data or external contract requires migration.
Implemented and pushed to
main:20f617e618c7e3d3ba7cc3a6ba23dbacbf67a340ed84e8aa7b6f8d182ae2a37ffc415ead1beaaa30Verified result: first-200-TU parse median improved 2.54% and retired instructions improved 2.54% in both execution orders, with exact parser/lineage aggregate parity, unchanged 3.9 GiB peak memory, and zero cgroup swap. The final artifact confirmation reduced instructions 2.59%. Whole-run task-clock/cycle medians remain qualified as neutral because of semantic-analysis noise.
Full Nix validation passed: formatting, lint, 286 unit tests plus all integration/end-to-end suites, rustdoc, and Windows GNU all-target/all-feature cross-compilation. Local
main,origin/main, and the remote branch all resolve toed84e8aa7b6f8d182ae2a37ffc415ead1beaaa30.Final remote-verification record pushed as
5d04beabeb4bcd00d27e69dd318e5834b097cf30. Localmain,origin/main, and the canonical remote branch are synchronized at that commit. Issue #52 remains open because closure was not included in the authorization.Closing as delivered and remotely verified on
mainat5d04beabeb4bcd00d27e69dd318e5834b097cf30. Implementation:20f617e618c7e3d3ba7cc3a6ba23dbacbf67a340.JayKobe6k referenced this issue2026-09-12 18:18:23 +00:00
JayKobe6k referenced this issue2026-09-12 18:18:27 +00:00