Typechecker performance improvements - #521
Merged
Merged
Conversation
mbenke
approved these changes
Jul 6, 2026
mbenke
left a comment
Collaborator
There was a problem hiding this comment.
Nice work! One question: it seems that noDesugarOpt is now not used in code, is it still needed in tests?
mbenke
added a commit
that referenced
this pull request
Jul 8, 2026
Brings in main's typechecker performance work (PR #521) on top of the earlier main merge: * The double typecheck is gone: modules are inferred once, and the lambda/expected-type reconciliation the retired no-desugar pass used to provide is now folded into tcExpWithExpected' (TcStmt). The CheckedModule record loses its checkedModuleNoDesugar field and Options loses noDesugarOpt. * Assorted TcSubst/TcUnify/TcMonad/TcResolution speedups and a new Syntax/Traversal module. Auto-merged cleanly; one hand-fix was required, folded in here: * TcCacheSerialize.fromCachedModule constructs a CheckedModule and set the now-removed checkedModuleNoDesugar field to an error thunk. With the field gone the record no longer compiles, so the line is dropped (only checkedModuleInput remains an unread thunk). The serialized cache format is unaffected: that field was never persisted. Verified: native -Werror build clean; 811 unit tests pass (including the typecheck-cache dump/load round-trip); optimised web/build.sh --release green with a regenerated std-cache.bin. Assisted-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
This PR makes some changes on type inference to improve performance.
Traversal.hsSubstasData.Map:applyis nowO(log n)instead of a linear association-list scan.ordNubinfv/mv/bv: replacedO(n^2)Data.List.unionaccumulation.nameSupplymutation infreshInst;askInstEnvalpha-renames only the queried class's instances, not the whole table.
Times in seconds (minimum of several warm runs on my machine).
mainis the originaltwo-pass baseline;
optimizedis this branch.tc= "Typecheck modules" phase;wall= totalcompile time.
~5.6x faster type checking, ~5.0x faster total compile. Full unit suite (793 tests) went from
~100 s to 23.8 s; all 793 tests + 22 contest suites still pass.