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

Generate signature files for resource files #15176

Merged
merged 7 commits into from
May 5, 2023
Merged

Conversation

nojaf
Copy link
Contributor

@nojaf nojaf commented May 3, 2023

As signature files can benefit the graph type-checking, I'd like to generate them as well for all *.txt files that are transformed to SR code.

image

There are around 70 links in the Compiler project that reference FSComp.fsi

flowchart RL
    0["C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Compiler.Service\Release\netstandard2.0\FSComp.fsi"]
    1["C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Compiler.Service\Release\netstandard2.0\FSComp.fs"]
    52["Facilities\LanguageFeatures.fs"]
    58["Facilities\DiagnosticsLogger.fs"]
    86["AbstractIL\ilsign.fs"]
    88["AbstractIL\ilnativeres.fs"]
    94["AbstractIL\ilread.fs"]
    98["AbstractIL\ilwrite.fs"]
    100["AbstractIL\ilreflect.fs"]
    102["SyntaxTree\PrettyNaming.fs"]
    106["SyntaxTree\XmlDoc.fs"]
    112["SyntaxTree\SyntaxTreeOps.fs"]
    114["SyntaxTree\ParseHelpers.fs"]
    115["C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Compiler.Service\Release\netstandard2.0\pppars.fs"]
    116["C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Compiler.Service\Release\netstandard2.0\pars.fs"]
    118["SyntaxTree\LexHelpers.fs"]
    119["C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Compiler.Service\Release\netstandard2.0\pplex.fs"]
    120["C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Compiler.Service\Release\netstandard2.0\\lex.fs"]
    122["SyntaxTree\LexFilter.fs"]
    124["TypedTree\tainted.fs"]
    126["TypedTree\TypeProviders.fs"]
    132["TypedTree\TypedTree.fs"]
    135["TypedTree\TcGlobals.fs"]
    137["TypedTree\TypedTreeOps.fs"]
    139["TypedTree\TypedTreePickle.fs"]
    143["Checking\import.fs"]
    145["Checking\TypeHierarchy.fs"]
    147["Checking\infos.fs"]
    149["Checking\AccessibilityLogic.fs"]
    151["Checking\AttributeChecking.fs"]
    153["Checking\TypeRelations.fs"]
    155["Checking\InfoReader.fs"]
    157["Checking\NicePrint.fs"]
    159["Checking\AugmentWithHashCompare.fs"]
    161["Checking\NameResolution.fs"]
    163["Checking\SignatureConformance.fs"]
    165["Checking\MethodOverrides.fs"]
    167["Checking\MethodCalls.fs"]
    169["Checking\PatternMatchCompilation.fs"]
    171["Checking\ConstraintSolver.fs"]
    173["Checking\CheckFormatStrings.fs"]
    177["Checking\QuotationTranslator.fs"]
    179["Checking\PostInferenceChecks.fs"]
    185["Checking\CheckExpressions.fs"]
    187["Checking\CheckPatterns.fs"]
    189["Checking\CheckComputationExpressions.fs"]
    191["Checking\CheckIncrementalClasses.fs"]
    193["Checking\CheckDeclarations.fs"]
    195["Optimize\Optimizer.fs"]
    199["Optimize\InnerLambdasToTopLevelFuncs.fs"]
    205["Optimize\LowerComputedCollections.fs"]
    207["Optimize\LowerStateMachines.fs"]
    209["Optimize\LowerLocalMutables.fs"]
    217["CodeGen\IlxGen.fs"]
    219["Driver\FxResolver.fs"]
    225["DependencyManager/DependencyProvider.fs"]
    227["Driver\CompilerConfig.fs"]
    229["Driver\CompilerImports.fs"]
    231["Driver\CompilerDiagnostics.fs"]
    249["Driver\ParseAndCheckInputs.fs"]
    251["Driver\ScriptClosure.fs"]
    253["Driver\CompilerOptions.fs"]
    257["Driver\XmlDocFileWriter.fs"]
    261["Driver\StaticLinking.fs"]
    263["Driver\CreateILModule.fs"]
    265["Driver\fsc.fs"]
    269["Symbols\SymbolHelpers.fs"]
    287["Service\ServiceCompilerDiagnostics.fs"]
    290["Service\ServiceDeclarationLists.fs"]
    325["Interactive\fsi.fs"]
    1 --> 0
    52 --> 0
    58 --> 0
    86 --> 0
    88 --> 0
    94 --> 0
    98 --> 0
    100 --> 0
    102 --> 0
    106 --> 0
    112 --> 0
    114 --> 0
    115 --> 0
    116 --> 0
    118 --> 0
    119 --> 0
    120 --> 0
    122 --> 0
    124 --> 0
    126 --> 0
    132 --> 0
    135 --> 0
    137 --> 0
    139 --> 0
    143 --> 0
    145 --> 0
    147 --> 0
    149 --> 0
    151 --> 0
    153 --> 0
    155 --> 0
    157 --> 0
    159 --> 0
    161 --> 0
    163 --> 0
    165 --> 0
    167 --> 0
    169 --> 0
    171 --> 0
    173 --> 0
    177 --> 0
    179 --> 0
    185 --> 0
    187 --> 0
    189 --> 0
    191 --> 0
    193 --> 0
    195 --> 0
    199 --> 0
    205 --> 0
    207 --> 0
    209 --> 0
    217 --> 0
    219 --> 0
    225 --> 0
    227 --> 0
    229 --> 0
    231 --> 0
    249 --> 0
    251 --> 0
    253 --> 0
    257 --> 0
    261 --> 0
    263 --> 0
    265 --> 0
    269 --> 0
    287 --> 0
    290 --> 0
    325 --> 0
Loading

So this is a really good candidate to have a signature file.

@nojaf nojaf requested a review from a team as a code owner May 3, 2023 08:50
@T-Gro
Copy link
Member

T-Gro commented May 4, 2023

Good idea @nojaf .
Just to catch any gasps in my understanding of the implications, this brings:

  • One more large file to parse (but multithreaded, that is the 1 more thread we can see in the --times report I guess)
  • We still have to wait to typecheck .fsi sequentially
  • As a benefit, .fs can be typechecked in parallel

So the important metrics should be:

  • Difference in time to typecheck FsComp as .fs vs as .fsi
  • The additional overhead for one more file generation+filesystem loading+parsing

If using --times also to .csv, it can show the detailed times for each file being processed.
(but its more of personal interest to see the difference between typechecking a big but straightforward file as .fs versus as .fsi)

@KevinRansom KevinRansom merged commit 1d819b9 into dotnet:main May 5, 2023
@nojaf
Copy link
Contributor Author

nojaf commented May 5, 2023

Hi @T-Gro,

  • One more large file to parse

Not really, there is one larger file yes (FSComp.fsi which contains 5000 lines of code) but the parsing and type-checking of a signature file really doesn't take long:

image

We still have to wait to typecheck .fsi sequentially

Yes, but once the fsi file is processed, all those 70 links are no longer waiting for FSComp.fs to be processed. So the signature file offloads the heavy file and unblocks all those who are dependent on it.

As a benefit, .fs can be typechecked in parallel

Yup!

@nojaf
Copy link
Contributor Author

nojaf commented May 5, 2023

Oh and of course this is also useful when the enablePartialTypeChecking is true for the FSharpChecker in your IDE.

@T-Gro
Copy link
Member

T-Gro commented May 5, 2023

@nojaf : This is great, I was especially after the difference between sig time (0.12s+0.15s) and impl file (0.18s+1.22s) - bigger than I expected given the simplicity of the generated file.

Thanks for measuring this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants