Skip to content

Commit

Permalink
Allow CacheSizes to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Dec 8, 2024
1 parent c7949a8 commit 15be216
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Compiler/Service/TransparentCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ module private TypeCheckingGraphProcessing =

return finalFileResults, state
}

type CacheSizes = {
ParseFileKeepStrongly: int
ParseFileKeepWeakly: int
Expand Down Expand Up @@ -401,7 +402,6 @@ type internal TransparentCompiler
captureIdentifiersWhenParsing,
getSource: (string -> Async<ISourceText option>) option,
useChangeNotifications,
useSyntaxTreeCache,
?cacheSizes
) as self =

Expand Down
72 changes: 37 additions & 35 deletions src/Compiler/Service/TransparentCompiler.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,43 @@ type internal Extensions =
fileSnapshots: #ProjectSnapshot.IFileSnapshot list * ?extraKeyFlag: DependencyGraphType ->
ICacheKey<(DependencyGraphType option * byte array), string>

type CacheSizes = {
ParseFileKeepStrongly: int
ParseFileKeepWeakly: int
ParseFileWithoutProjectKeepStrongly: int
ParseFileWithoutProjectKeepWeakly: int
ParseAndCheckFileInProjectKeepStrongly: int
ParseAndCheckFileInProjectKeepWeakly: int
ParseAndCheckAllFilesInProjectKeepStrongly: int
ParseAndCheckAllFilesInProjectKeepWeakly: int
ParseAndCheckProjectKeepStrongly: int
ParseAndCheckProjectKeepWeakly: int
FrameworkImportsKeepStrongly: int
FrameworkImportsKeepWeakly: int
BootstrapInfoStaticKeepStrongly: int
BootstrapInfoStaticKeepWeakly: int
BootstrapInfoKeepStrongly: int
BootstrapInfoKeepWeakly: int
TcLastFileKeepStrongly: int
TcLastFileKeepWeakly: int
TcIntermediateKeepStrongly: int
TcIntermediateKeepWeakly: int
DependencyGraphKeepStrongly: int
DependencyGraphKeepWeakly: int
ProjectExtrasKeepStrongly: int
ProjectExtrasKeepWeakly: int
AssemblyDataKeepStrongly: int
AssemblyDataKeepWeakly: int
SemanticClassificationKeepStrongly: int
SemanticClassificationKeepWeakly: int
ItemKeyStoreKeepStrongly: int
ItemKeyStoreKeepWeakly: int
ScriptClosureKeepStrongly: int
ScriptClosureKeepWeakly: int
}
[<Experimental("This FCS type is experimental and will likely change or be removed in the future.")>]
type CacheSizes =
{
ParseFileKeepStrongly: int
ParseFileKeepWeakly: int
ParseFileWithoutProjectKeepStrongly: int
ParseFileWithoutProjectKeepWeakly: int
ParseAndCheckFileInProjectKeepStrongly: int
ParseAndCheckFileInProjectKeepWeakly: int
ParseAndCheckAllFilesInProjectKeepStrongly: int
ParseAndCheckAllFilesInProjectKeepWeakly: int
ParseAndCheckProjectKeepStrongly: int
ParseAndCheckProjectKeepWeakly: int
FrameworkImportsKeepStrongly: int
FrameworkImportsKeepWeakly: int
BootstrapInfoStaticKeepStrongly: int
BootstrapInfoStaticKeepWeakly: int
BootstrapInfoKeepStrongly: int
BootstrapInfoKeepWeakly: int
TcLastFileKeepStrongly: int
TcLastFileKeepWeakly: int
TcIntermediateKeepStrongly: int
TcIntermediateKeepWeakly: int
DependencyGraphKeepStrongly: int
DependencyGraphKeepWeakly: int
ProjectExtrasKeepStrongly: int
ProjectExtrasKeepWeakly: int
AssemblyDataKeepStrongly: int
AssemblyDataKeepWeakly: int
SemanticClassificationKeepStrongly: int
SemanticClassificationKeepWeakly: int
ItemKeyStoreKeepStrongly: int
ItemKeyStoreKeepWeakly: int
ScriptClosureKeepStrongly: int
ScriptClosureKeepWeakly: int
}
static member Create: sizeFactor: int -> CacheSizes

type internal CompilerCaches =

Expand Down Expand Up @@ -194,7 +197,6 @@ type internal TransparentCompiler =
captureIdentifiersWhenParsing: bool *
getSource: (string -> Async<ISourceText option>) option *
useChangeNotifications: bool *
useSyntaxTreeCache: bool *
?cacheSizes: CacheSizes ->
TransparentCompiler

Expand Down
12 changes: 8 additions & 4 deletions src/Compiler/Service/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ type FSharpChecker
captureIdentifiersWhenParsing,
getSource,
useChangeNotifications,
useTransparentCompiler
useTransparentCompiler,
?transparentCompilerCacheSizes
) =

let backgroundCompiler =
Expand All @@ -135,7 +136,8 @@ type FSharpChecker
parallelReferenceResolution,
captureIdentifiersWhenParsing,
getSource,
useChangeNotifications
useChangeNotifications,
?cacheSizes= transparentCompilerCacheSizes
)
:> IBackgroundCompiler
else
Expand Down Expand Up @@ -198,7 +200,8 @@ type FSharpChecker
?parallelReferenceResolution: bool,
?captureIdentifiersWhenParsing: bool,
?documentSource: DocumentSource,
?useTransparentCompiler: bool
?useTransparentCompiler: bool,
?transparentCompilerCacheSizes : CacheSizes
) =

use _ = Activity.startNoTags "FSharpChecker.Create"
Expand Down Expand Up @@ -247,7 +250,8 @@ type FSharpChecker
| Some(DocumentSource.Custom f) -> Some f
| _ -> None),
useChangeNotifications,
useTransparentCompiler
useTransparentCompiler,
?transparentCompilerCacheSizes = transparentCompilerCacheSizes
)

member _.UsesTransparentCompiler = useTransparentCompiler = Some true
Expand Down
5 changes: 4 additions & 1 deletion src/Compiler/Service/service.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type public FSharpChecker =
/// <param name="captureIdentifiersWhenParsing">When set to true we create a set of all identifiers for each parsed file which can be used to speed up finding references.</param>
/// <param name="documentSource">Default: FileSystem. You can use Custom source to provide a function that will return the source for a given file path instead of reading it from the file system. Note that with this option the FSharpChecker will also not monitor the file system for file changes. It will expect to be notified of changes via the NotifyFileChanged method.</param>
/// <param name="useTransparentCompiler">Default: false. Indicates whether we use a new experimental background compiler. This does not yet support all features</param>
/// <param name="transparentCompilerCacheSizes">Default: None. The cache sizes for the transparent compiler</param>
static member Create:
?projectCacheSize: int *
?keepAssemblyContents: bool *
Expand All @@ -54,7 +55,9 @@ type public FSharpChecker =
[<Experimental "This parameter is experimental and likely to be removed in the future.">] ?documentSource:
DocumentSource *
[<Experimental "This parameter is experimental and likely to be removed in the future.">] ?useTransparentCompiler:
bool ->
bool *
[<Experimental "This parameter is experimental and likely to be removed in the future.">] ?transparentCompilerCacheSizes:
CacheSizes ->
FSharpChecker

[<Experimental("This FCS API is experimental and subject to change.")>]
Expand Down

0 comments on commit 15be216

Please sign in to comment.