Skip to content
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

Merged
merged 6 commits into from
Oct 21, 2024
Merged

Conversation

chsienki
Copy link
Contributor

@chsienki chsienki commented Jul 17, 2024

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)

chsienki added 2 commits July 17, 2024 15:50
- Increase driver cache max size to 100
- Only cache a project if it actually produced generated documents
chsienki added 2 commits July 19, 2024 14:29
- Make cache size configurable
@chsienki chsienki marked this pull request as ready for review July 23, 2024 18:47
@chsienki chsienki requested a review from a team as a code owner July 23, 2024 18:47
@chsienki
Copy link
Contributor Author

@dotnet/roslyn-compiler @jaredpar for review please :)

src/Compilers/Core/Portable/CommandLine/CommonCompiler.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())
Copy link
Member

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?

Copy link
Member

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?

Copy link
Contributor Author

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.

@chsienki chsienki enabled auto-merge (squash) October 21, 2024 18:00
@chsienki chsienki merged commit b9cf91f into dotnet:main Oct 21, 2024
28 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 21, 2024
@akhera99 akhera99 modified the milestones: Next, 17.13 P1 Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants