1

Github [Tooling Optimization] Skip background type-checking on implementation fi...

 3 years ago
source link: https://github.com/dotnet/fsharp/pull/10199
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

TIHan commented on Sep 28, 2020

edited

Well over a year ago, I experimented with an optimization trick that sped up tooling significantly. Here, I'm trying to see if it's worth actually getting it in.

When editing then saving files, we always have to re-type-check everything - sometimes entire project(s) even on a single file change. This means we are constantly building a lot of large structures and throwing them away in a short amount of time. This takes a lot of CPU time and memory.

The optimization basically stops the background type-checking of implementation files if a backing signature(.fsi) file exists. This should be safe to do as the signature file will always be the public-facing API over the implementation file; therefore, the implementation file doesn't matter in most cases. You will still have to type-check an implementation file if you open it, or perform a find-all references.

The optimization only affects projects who use signature files. But for FSharp.Compiler.Private, it gives a very significant speed up in order to get colorization, tool-tips, etc.

The following are some results from starting up VisualFSharp.sln:

  • FSharp.Compiler.Private - service.fs
    • Without Optimization: 60-65 seconds to colorization
    • With Optimization: 18-23 seconds to colorization
  • FSharp.Editor - FSharpProjectOptionsManager.fs
    • Without Optimization: 62-67 seconds to colorization
    • With Optimization: 18-25 seconds to colorization

This is very significant. At the very least, it would boost tooling performance when working in the compiler.

Remaining and currently known tasks:

  • Lazily type-check implementation files when we perform a find-all references.
  • (Stretch) Lazily parse implementation files - extra perf gain; if we don't have to type-check it, we might not have to parse it.
  • (Stretch) Prevent parse/type-check of other files when modifying implementation files with backing signature files; allows modifying implementation files without ever having to analyze any other file or project. #10210 Will make a separate PR for that change, it's the inverse of this optimization.

Implementation details:

  • Adds a new flag to FSharpChecker, enablePartialTypeChecking - this will enable the optimization described above.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK