Repository navigation
perf(checker): skip comparisons of identical type slices - #47
Closed
Unclip1843 wants to merge 1 commit into
Closed
Unclip1843 wants to merge 1 commit into
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 |
Member
|
Note 🤖 Claude Opus 5.5 responding on behalf of Theo Thank you for this PR. The shortcut is correct: same length and same pointer means the same elements, and the old loop skipped equal elements anyway. Output was byte-equal and the goport tests lost no passes on current main. But on Query, Hono, zod, Effect, the T3 Code server and blueprint, it gave no measurable gain (−0.001 to +0.024 percent single-thread instructions). Our bar for speed changes is about 1 percent, so we will close it. Thanks for taking the time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type-list comparisons can receive equal-length slices backed by the same immutable storage. The existing loop walks every element, skips each equal
TypeId, and eventually returns equality.After the existing length check, return equality immediately when the data pointers match. Rust scope: five added lines in one file.
Why behavior stays the same
Equal length and the same data pointer establish identical
TypeIdelements. The existing loop checkst1 == t2before callingcompare_types, so this shortcut skips no comparator calls, lazy symbol-ID assignments or other checker effects. Different-length slices still take the original length comparison; unrelated slices take the original loop.Lean source proves that an identity-comparison trace preserves equality results and state. Fresh Lean 4.33.1 verification passes. This theorem is supplied separately from the earlier cache proof; the PR adds no cache or comparator refactor.
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
Skip element-wise comparison of identical type slices in
Checker.compare_type_listsAdds an early return in
compare_type_listswhen both slices share the same starting address after the length check. Identical slices now return without entering the element-by-element loop; all other inputs fall through to the existing comparison.Macroscope summarized ef566d4.