Skip to content

perf(checker): skip comparisons of identical type slices - #47

Closed
Unclip1843 wants to merge 1 commit into
pingdotgg:mainfrom
Unclip1843:perf-identical-type-slices
Closed

Unclip1843 wants to merge 1 commit into
pingdotgg:mainfrom
Unclip1843:perf-identical-type-slices

Conversation

@Unclip1843

@Unclip1843 Unclip1843 commented Oct 11, 2026 •

Copy link
Copy Markdown

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 TypeId elements. The existing loop checks t1 == t2 before calling compare_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

  • Applied independently to bf34f21ae40b221ea9def389778d2f90ec950398; changed files pass rustfmt with Rust 1.93.0. Independent static review is attached.
  • Evidence package, review, and audit, with source/binary hashes and complete per-case results.
  • Historical combined candidate: 133,390 compiler/conformance checks passed; 1,728 explicit skips. The default suite had 1,529 passes plus two API-session failures that passed on the same binary after a macOS socket-path correction. npm: 879 passes on each side. Workspace: 629 passes and one unchanged watch failure. Original failures and skips remain in the attached records.
  • Those results used the earlier parent 9f6ee6d147de1f8216c967e2a966cacbac295984 and 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_lists

Adds an early return in compare_type_lists when 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.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@t3dotgg

t3dotgg commented Oct 11, 2026

Copy link
Copy Markdown
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.

@t3dotgg t3dotgg closed this Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants