Skip to content

Use FxHash for the type checker's internal maps and sets - #295

Merged
Rigidity merged 2 commits into
mainfrom
rigidity/fx-hash-types
Nov 14, 2026
Merged

Rigidity merged 2 commits into
mainfrom
rigidity/fx-hash-types

Conversation

@Rigidity

@Rigidity Rigidity commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

The type checker's comparison, intersection, substitution and memoization keep their maps and sets keyed by small integer IDs, and hashing those with SipHash was a large part of their run time. This switches them to FxHash (rustc-hash 2).

Changes

  • Added rue-types/src/hash.rs, which re-exports FxHashMap and FxHashSet and defines the FxIndexMap and FxIndexSet aliases.
  • memo.rs, compare.rs (the ComparisonContext stack, bindings, references, rigid and monotone sets), intersect.rs, substitute.rs (the stack, memo and renames) and check.rs (the check memo and the overlap stack) use them.
  • The HashMap<TypeId, TypeId> taken by the public substitute_with_mappings is left as it is.
  • Nothing in the public API changes.

Timings

These are debug builds, compared against 65b2f24d:

Test Before After
test_memo_differential 18.7s 13.2s
test_check_property 7.4s 6.2s
test_check_property_generics 7.7s 6.4s

Together with #294, the CPU time of the rue-tests snapshot suite went from 37.2s to 24.8s.

The ignored test_memo_differential_large still passes, taking about 5.5 min in release.

@Rigidity
Rigidity enabled auto-merge November 14, 2026 23:12
@Rigidity
Rigidity merged commit 96e6b2e into main Nov 14, 2026
3 checks passed
@Rigidity
Rigidity deleted the rigidity/fx-hash-types branch November 14, 2026 23:14
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.

1 participant