Skip to content

Implement linking optimizations - #144

Open
msujew wants to merge 2 commits into
mainfrom
msujew/linking-optimizations
Open

Implement linking optimizations#144
msujew wants to merge 2 commits into
mainfrom
msujew/linking-optimizations

Conversation

@msujew

@msujew msujew commented Aug 11, 2026

Copy link
Copy Markdown
Member

The linking phase is usually the most performance intensive phase. This is an attempt to improve its performance by reducing the amount of allocations performed during the linking.

The main improvement is concerned with the new SymbolSliceContainer. Adopters (or the generated <Language>SymbolContainer) can implement this to generate allocation free scopes.

Another major improvement is the reduction of per-reference allocations. Mainly the new context that we generate for linking. It's now a single context with a special resolutionChain attached to it that keeps track of cycles. Adds a ForEachWithSetup for this, which keeps one setup function per worker.

Then there are a few other improvements:

  1. Reduce the amount of allocations in the parser by storing the closures for reference resolving functions
  2. Store the name of a symbol on the symbol description directly. This reduces the need for interface dispatches (expensive).
  3. Reduce the amount of closures required for traversing the AST.
  4. Caches the available number of CPU cores. Calling GOMAXPROCS on every ForEach call had to acquire a lock first internally.

All of these changes together roughly double the performance of the workspace build.

@msujew
msujew force-pushed the msujew/linking-optimizations branch from 02a4819 to 9b6fed2 Compare August 22, 2026 09:59
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