-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase driver cache size #74431
Increase driver cache size #74431
Conversation
- Increase driver cache max size to 100 - Only cache a project if it actually produced generated documents
@dotnet/roslyn-compiler @jaredpar for review please :) |
src/Compilers/Core/Portable/SourceGeneration/GeneratorDriverCache.cs
Outdated
Show resolved
Hide resolved
// to calculate that nothing needed to be generated, real world usage has found that generators are generally only | ||
// expensive when actually producing source. By only caching those with results, we help to keep memory usage down | ||
// when it probably wouldn't improve the performance anyway. | ||
if (!disableCache && driver.GetRunResult().GeneratedTrees.Any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about this - caching empty results increases memory usage? Shouldn't empty results be small?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the ballpark for how much the cache costs in terms of memory usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver holds onto copies of things like the Compilation, as well as all the intermediate nodes + state tables. So even if it doesn't produce anything, with enough files it can be a non-trivial amount of state.
This ups the size of the generator cache based on observed 'big' projects in the wild. We also only cache a generator driver if it actually produced any results, based on observations that its generally fast to produce nothing.
Also updates the replay tool to support multiple iterations for testing scenarios like this (second commit)