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

Reduced memory consumption of autocompletion cache #1077

Merged
merged 2 commits into from
Mar 14, 2023

Conversation

TheAngryByrd
Copy link
Member

Previously, on save, we would cache all typechecks. This could cause large solutions to use a lot of memory for no real purpose. This lets the caller of ParseAndCheckFileInProject determine if it should cache type checks for autocompletions. Typically we don't want to store them for anything other the already open files.

@@ -36,7 +36,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers) =
// This is used to hold previous check results for autocompletion.
// We can't seem to rely on the checker for previous cached versions
let memoryCache () =
new MemoryCache(MemoryCacheOptions(SizeLimit = Nullable<_>(2000L)))
new MemoryCache(MemoryCacheOptions(SizeLimit = Nullable<_>(200L)))
Copy link
Member Author

Choose a reason for hiding this comment

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

200 might still be too much. Someone could edit 200 files within 5 minutes and want autocompletions for them all but seems unlikely.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit - surface as a config option? maybe something like FSharp.fsac.cachedTypeCheckCount?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

src/FsAutoComplete.Core/CompilerServiceInterface.fs Outdated Show resolved Hide resolved
This lets the caller of ParseAndCheckFileInProject determine if it should cache type checks for autocompletions.  Typically we don't want to store them for anything other the already open files.
@@ -36,7 +36,7 @@ type FSharpCompilerServiceChecker(hasAnalyzers) =
// This is used to hold previous check results for autocompletion.
// We can't seem to rely on the checker for previous cached versions
let memoryCache () =
new MemoryCache(MemoryCacheOptions(SizeLimit = Nullable<_>(2000L)))
new MemoryCache(MemoryCacheOptions(SizeLimit = Nullable<_>(200L)))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - surface as a config option? maybe something like FSharp.fsac.cachedTypeCheckCount?

@baronfel
Copy link
Contributor

Thank you!

@baronfel baronfel merged commit a80fdd5 into ionide:main Mar 14, 2023
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