Skip to content

Typecheck performance optimizations round#20

Merged
wolfy-j merged 22 commits intomainfrom
perf-ops-feature
Feb 20, 2026
Merged

Typecheck performance optimizations round#20
wolfy-j merged 22 commits intomainfrom
perf-ops-feature

Conversation

@wolfy-j
Copy link
Contributor

@wolfy-j wolfy-j commented Feb 20, 2026

This pull request introduces significant performance and maintainability improvements to the control flow graph (Graph) and type inference logic in the compiler. The main focus is on optimizing symbol and version lookups by introducing dense, point-indexed data structures, and on refactoring the type inference pipeline to be more efficient and robust. Additional utility functions are added to support these changes, and the type containment logic is rewritten for correctness and recursion safety.

Control Flow Graph: Dense Lookups and API Improvements

  • Added visibleVersionByPoint and symbolScopeByPoint to Graph, providing fast, dense, point-indexed access to symbol versions and scopes, reducing map lookups during compilation.
  • Refactored construction of Graph in BuildWithBindings and BuildBlock to populate these dense structures, and introduced helper functions denseVisibleVersionByPoint and denseSymbolScopeByPoint. [1] [2]
  • Updated symbol and version lookup methods (VisibleVersion, AllVisibleVersions, SymbolAt, AllSymbolsAt) to use the new dense arrays when possible, falling back to maps for sparse points. Introduced LocalSymbolsAt and internalized point-local symbol lookup logic. [1] [2] [3] [4] [5]

Type Inference Pipeline: Efficiency and Robustness

  • Overhauled the SCC (strongly connected component) inference loop to precompute and mark assignment and call indices relevant to each SCC, reducing redundant work and improving fixpoint convergence. [1] [2] [3] [4] [5]
  • Refactored the overlay logic for synthesizing types, introducing synthWithInferenceOverlay to unify and simplify the creation of type overlays for inference, replacing repeated code. [1] [2] [3]
  • Added utility functions normalizedCallArgSymbols and callRefSymbols to robustly extract symbol IDs from call arguments and references, improving accuracy of dependency tracking in inference.

Type Containment Logic: Correctness and Recursion Safety

  • Rewrote typeContains to use a depth-first, recursion-guarded traversal (typeContainsDepth), ensuring correct handling of recursive types and annotated wrappers, and preventing infinite loops.

@wolfy-j wolfy-j merged commit 7f6d79a into main Feb 20, 2026
@wolfy-j wolfy-j deleted the perf-ops-feature branch March 3, 2026 22:15
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