Skip to content

Optimize linking using buckets#62

Merged
msujew merged 6 commits intomainfrom
msujew/optimize-linking
Apr 27, 2026
Merged

Optimize linking using buckets#62
msujew merged 6 commits intomainfrom
msujew/optimize-linking

Conversation

@msujew
Copy link
Copy Markdown
Member

@msujew msujew commented Apr 13, 2026

Improves our linking infrastructure (through the board, i.e. both local symbols and exported/imported symbols) by using a generated type-optimized SymbolContainer. It stores types (only those actually required, not all!) in buckets, which are then merged on demand.

Since everything in the linking system has become Symbol... or ...Symbols, I've chosen to rename AstNodeDescription to SymbolDescription. I believe this makes all of this a bit more coherent.

Performance improvements are clearly visible when looking at our statemachine benchmark. The overall build performance has increase by roughly ~20%. Linking by itself is now faster by 30%.

@msujew msujew requested a review from spoenemann April 13, 2026 14:09
Copy link
Copy Markdown
Member

@spoenemann spoenemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement!

Comment thread generated/services.go
type GeneratedSrv struct {
Lexer lexer.Lexer
Parser parser.Parser
SymbolContainers core.SymbolContainers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be just a function instead of an interface with a method?

Comparison:

srv.Generated().SymbolContainers.New()

vs.

srv.Generated().NewSymbolContainer()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like the interface more - but is just a preference. I feel like the system is a bit more coherent, if everything has a dedicated interface and we don't mix interfaces and factory function types within the service containers.

Comment thread symbols.go Outdated
var TypeFor_Command = reflect.TypeFor[Command]()

func (sc *StatemachineModelSymbolContainer) ForType(t reflect.Type) core.SymbolSeq {
switch t {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the type switch also work for subtypes (e.g. an interface embedding the super-interface)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what the topological sorting is for. It's a bit cumbersome, but you can test it out by changing the grammar.

@msujew msujew merged commit 5c14cc6 into main Apr 27, 2026
4 checks passed
@msujew msujew deleted the msujew/optimize-linking branch April 27, 2026 10:47
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