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

[Tooling Optimization] Skip background type-checking on implementation files if signature files exist #10199

Merged
merged 34 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
13aa2e0
Initial work to enable FSI optimizations in tooling
TIHan Sep 28, 2020
2368052
Remove extra type-check function
TIHan Sep 28, 2020
300664c
Not working but initial work to lazily eval
TIHan Sep 30, 2020
f158eaa
some work
TIHan Sep 30, 2020
e83ebda
simplify
TIHan Sep 30, 2020
62c0519
simplify again
TIHan Sep 30, 2020
00a35bc
Using Async
TIHan Sep 30, 2020
db4f018
work
TIHan Sep 30, 2020
92c7cc8
work
TIHan Sep 30, 2020
4c3c258
builds
TIHan Sep 30, 2020
46b1117
almost there
TIHan Sep 30, 2020
33481c2
Minor change
TIHan Sep 30, 2020
315be1f
minor refactor
TIHan Sep 30, 2020
116b0b7
working, but not quite optimized
TIHan Sep 30, 2020
3fa36f6
Fix dependency files
TIHan Sep 30, 2020
79db9ed
Refactor types
TIHan Sep 30, 2020
8350e37
Added 'enableLazyTypeChecking'.
TIHan Sep 30, 2020
75f8099
Enable lazy type checking in VS
TIHan Oct 1, 2020
7be6e07
Added documentation
TIHan Oct 1, 2020
57611bc
Added SyntaxTreeAccumulator
TIHan Oct 1, 2020
29d25f2
prevent parsing impl files if possible
TIHan Oct 1, 2020
be77e72
Trying to fix tests
TIHan Oct 1, 2020
6d29b09
Refactor
TIHan Oct 1, 2020
ef9149d
Throw if enablePartialChecking and keepAssemblyContents are both enabled
TIHan Oct 1, 2020
ab54e62
minor comment update
TIHan Oct 1, 2020
8f16c45
minor refactor
TIHan Oct 1, 2020
8413844
Trying to pass tests
TIHan Oct 1, 2020
1087972
Only getting assembly data
TIHan Oct 2, 2020
c48217b
Remove unnecessary change
TIHan Oct 2, 2020
0b7ae6c
Added some documentation
TIHan Oct 2, 2020
36dcf61
Minor comment update
TIHan Oct 2, 2020
2db6f8d
Renamed quickCheck to skipImplIfSigExists
TIHan Oct 2, 2020
a72a321
Minor update
TIHan Oct 2, 2020
901712d
Feedback
TIHan Oct 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/fsharp/ParseAndCheckInputs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ type TcState =

member x.NextStateAfterIncrementalFragment tcEnvAtEndOfLastInput =
{ x with tcsTcSigEnv = tcEnvAtEndOfLastInput
tcsTcImplEnv = tcEnvAtEndOfLastInput }
tcsTcImplEnv = tcEnvAtEndOfLastInput }


/// Create the initial type checking state for compiling an assembly
Expand Down Expand Up @@ -621,7 +621,7 @@ let GetInitialTcState(m, ccuName, tcConfig: TcConfig, tcGlobals, tcImports: TcIm
tcsCcuSig = Construct.NewEmptyModuleOrNamespaceType Namespace }

/// Typecheck a single file (or interactive entry into F# Interactive)
let TypeCheckOneInputEventually (checkForErrors, tcConfig: TcConfig, tcImports: TcImports, tcGlobals, prefixPathOpt, tcSink, tcState: TcState, inp: ParsedInput) =
let TypeCheckOneInputEventually (checkForErrors, tcConfig: TcConfig, tcImports: TcImports, tcGlobals, prefixPathOpt, tcSink, tcState: TcState, inp: ParsedInput, skipImplIfSigExists: bool) =

eventually {
try
Expand Down Expand Up @@ -686,11 +686,21 @@ let TypeCheckOneInputEventually (checkForErrors, tcConfig: TcConfig, tcImports:
let conditionalDefines =
if tcConfig.noConditionalErasure then None else Some (tcConfig.conditionalCompilationDefines)

let hadSig = rootSigOpt.IsSome

// Typecheck the implementation file
let! topAttrs, implFile, _implFileHiddenType, tcEnvAtEnd, createsGeneratedProvidedTypes =
TypeCheckOneImplFile (tcGlobals, tcState.tcsNiceNameGen, amap, tcState.tcsCcu, checkForErrors, conditionalDefines, tcSink, tcConfig.internalTestSpanStackReferring) tcImplEnv rootSigOpt file
let typeCheckOne =
if skipImplIfSigExists && hadSig then
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity, is hadsig the right name? It seems as if it should be hasSig.

Copy link
Contributor Author

@TIHan TIHan Oct 6, 2020

Choose a reason for hiding this comment

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

hadSig refers to if the impl file "had" a sig before we type-checked. hasSig might mean if the impl has any kind of signature, whether it be generated after a type-check or from a '.fsi' file.

Honestly, hasSig might also be correct depending on how you look at it.

The most accurate name would be hasSigFromSigFile.

let dummyExpr = ModuleOrNamespaceExprWithSig.ModuleOrNamespaceExprWithSig(rootSigOpt.Value, ModuleOrNamespaceExpr.TMDefs [], range.Zero)
let dummyImplFile = TypedImplFile.TImplFile(qualNameOfFile, [], dummyExpr, false, false, StampMap [])

(EmptyTopAttrs, dummyImplFile, Unchecked.defaultof<_>, tcImplEnv, false)
|> Eventually.Done
else
TypeCheckOneImplFile (tcGlobals, tcState.tcsNiceNameGen, amap, tcState.tcsCcu, checkForErrors, conditionalDefines, tcSink, tcConfig.internalTestSpanStackReferring) tcImplEnv rootSigOpt file

let! topAttrs, implFile, _implFileHiddenType, tcEnvAtEnd, createsGeneratedProvidedTypes = typeCheckOne

let hadSig = rootSigOpt.IsSome
let implFileSigType = SigTypeOfImplFile implFile

let rootImpls = Zset.add qualNameOfFile tcState.tcsRootImpls
Expand Down Expand Up @@ -741,7 +751,7 @@ let TypeCheckOneInput (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, pre
// 'use' ensures that the warning handler is restored at the end
use unwindEL = PushErrorLoggerPhaseUntilUnwind(fun oldLogger -> GetErrorLoggerFilteringByScopedPragmas(false, GetScopedPragmasForInput inp, oldLogger) )
use unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.TypeCheck
TypeCheckOneInputEventually (checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, inp)
TypeCheckOneInputEventually (checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, inp, false)
|> Eventually.force ctok

/// Finish checking multiple files (or one interactive entry into F# Interactive)
Expand All @@ -756,7 +766,7 @@ let TypeCheckMultipleInputsFinish(results, tcState: TcState) =
let TypeCheckOneInputAndFinishEventually(checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input) =
eventually {
Logger.LogBlockStart LogCompilerFunctionId.CompileOps_TypeCheckOneInputAndFinishEventually
let! results, tcState = TypeCheckOneInputEventually(checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input)
let! results, tcState = TypeCheckOneInputEventually(checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input, false)
let result = TypeCheckMultipleInputsFinish([results], tcState)
Logger.LogBlockStop LogCompilerFunctionId.CompileOps_TypeCheckOneInputAndFinishEventually
return result
Expand All @@ -779,4 +789,3 @@ let TypeCheckClosedInputSet (ctok, checkForErrors, tcConfig, tcImports, tcGlobal
let (tcEnvAtEndOfLastFile, topAttrs, implFiles, _), tcState = TypeCheckMultipleInputsFinish(results, tcState)
let tcState, declaredImpls = TypeCheckClosedInputSetFinish (implFiles, tcState)
tcState, topAttrs, declaredImpls, tcEnvAtEndOfLastFile

3 changes: 2 additions & 1 deletion src/fsharp/ParseAndCheckInputs.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ val TypeCheckOneInputEventually :
LongIdent option *
NameResolution.TcResultsSink *
TcState *
ParsedInput
ParsedInput *
skipImplIfSigExists: bool
-> Eventually<(TcEnv * TopAttribs * TypedImplFile option * ModuleOrNamespaceType) * TcState>

/// Finish the checking of multiple inputs
Expand Down
Loading