Repository navigation
perf(checker): size declaration storage by unique entries - #46
Unclip1843 wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
|
Note 🤖 Claude Opus 5.5 responding on behalf of Theo Thank you for this PR and for the proof. The dedupe order is unchanged, and we confirmed byte-equal output and no lost goport tests on current main. But the old size hint is there for one known case. On blueprint, 42,921 calls each collect 178 unique declarations from 181. Without the hint, the table and the buffer grow step by step, and the kept buffer rounds up to 256 entries. On that project this change measured +4.4 percent instructions and +7.1 percent peak memory. On Query, Hono, zod, Effect and the T3 Code server it had no measurable effect. So we will close it. If you find a project where duplicate declarations keep a lot of slack, please share it. A shrink only in that case could be worth a look. |
create_union_or_intersection_propertyreserves declaration storage using the sum of declarations across constituent properties, before deduplication. When many constituents repeat the same declarations, the resulting symbol can retain a buffer sized for all occurrences rather than the unique list.Start the inline
SmallVecempty and pass zero as the existingDeclarationSetsize hint. Both structures grow with the collected unique declarations instead of the occurrence estimate. Rust scope: +5 / -6 lines in one file.Why behavior stays the same
The same
DeclarationSet::addcalls keep the same append-if-unique order. Its existing growth path supports underestimated hints:declaration_set_grows_past_its_hintexplicitly tests hint 0 with 300 distinct nodes, duplicates and nil entries. Nil handling and conversion to the retainedDeclarationsare unchanged. Mostly unique inputs can cause additional growth/rehashing; an isolated performance comparison is pending.Lean source proves ordered unique collection and a unique-count capacity bound in the retained-buffer model. Fresh Lean 4.33.1 verification passes. The temporary hash table can still grow on a duplicate at its load threshold; this PR does not claim zero allocation for every duplicate operation.
Validation and evidence
bf34f21ae40b221ea9def389778d2f90ec950398; changed files passrustfmtwith Rust 1.93.0. Independent static review is attached.9f6ee6d147de1f8216c967e2a966cacbac295984and included other optimizations. They are not test results for this independent PR head. No standalone speedup or memory percentage is claimed.Draft pending the light-path checks in
docs/typechecker-accountability.md: existing focused tests, protected goport comparison against the latest accepted revision with no lost passes, and byte-equal Query/Hono/zod/effect output. Exact-head Cargo build/runtime checks, clippy and CI remain pending. This follows the validation pattern in #31; the attached evidence preserves what has actually run.Note
Size
Checker::create_union_or_intersection_propertydeclaration storage by unique entriesRemoves the aggregate declaration-count calculation in checker_p24.rs that summed declaration occurrences across constituent properties. The declaration buffer now grows based on the unique-declaration collection, and
DeclarationSet::addreceives zero instead of the occurrence count. Declaration ordering and uniqueness logic is unchanged.Macroscope summarized fe33363.