Skip to content

Reduce the amount of goroutines used for builds#126

Open
msujew wants to merge 2 commits into
mainfrom
msujew/reduce-goroutines
Open

Reduce the amount of goroutines used for builds#126
msujew wants to merge 2 commits into
mainfrom
msujew/reduce-goroutines

Conversation

@msujew

@msujew msujew commented Jul 8, 2026

Copy link
Copy Markdown
Member

Massively reduces the amount of spawned goroutines required for a workspace build. I noticed that during large workspace builds, we spawn an unreasonable number of goroutines, which (a) drags down our memory profile and (b) slows down runtime performance when multithreading (but also when single-threading!).

This change adds a new parallel.ForEachIter (iter.Seq[T]) and parallel.ForEach ([]T) for efficient chunking of data for goroutines. This is now used for both the linking and general workspace build phase (essentially all steps where we use sync.WaitGroup), which results in a total speedup of roughly 40%, and a 20% memory usage decrease.

@msujew msujew requested a review from spoenemann July 8, 2026 15:57

@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: 5b57785 Previous: d803417 Ratio
BenchmarkWorkspaceCycle (typefox.dev/fastbelt/examples/statemachine) - MB/s 13.19 MB/s 5.21 MB/s 2.53

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

@msujew

msujew commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Ignore comment above by the git-bot. It doesn't understand that 11MB/s is better than 5MB/s 🙄

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