Skip to content

Reduce AST memory allocations#133

Open
msujew wants to merge 1 commit into
mainfrom
msujew/simplify-generated-types
Open

Reduce AST memory allocations#133
msujew wants to merge 1 commit into
mainfrom
msujew/simplify-generated-types

Conversation

@msujew

@msujew msujew commented Jul 24, 2026

Copy link
Copy Markdown
Member

The parser currently allocates a lot of empty arrays that aren't really necessary. For most purposes, nil and [] (empty) slices are essentially the same. This change removes all of the array initialization code, which reduces retained memory, reduces the amount of intermediate allocated memory, and improves parsing performance.

Adds a benchmark for the arithmetics language, which is affected by this change more than the statemachine language.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: e25375f Previous: d803417 Ratio
BenchmarkWorkspaceCycle (typefox.dev/fastbelt/examples/statemachine) - MB/s 14.62 MB/s 5.21 MB/s 2.81
BenchmarkParser (typefox.dev/fastbelt/examples/statemachine) - MB/s 67.79 MB/s 37.68 MB/s 1.80
BenchmarkLexerAndParser (typefox.dev/fastbelt/examples/statemachine) - MB/s 37.32 MB/s 23.82 MB/s 1.57

This comment was automatically generated by workflow using github-action-benchmark.

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