Graph-based type-checking: speedup graph building by avoiding unnecessary inefficient path checks
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Experimental graph-based checking in compilation has some opportunities for performance improvements.
One of them is the below code invoked for each file when making the graph:
https://github.com/dotnet/fsharp/blob/9c55d323c2dae199ea83dd946cf9859163b390dd/src/Compiler/Driver/GraphChecking/DependencyResolution.fs#L215-L217
The `fileNameOfPath` checks for illegal characters in a very inefficient way, and besides, we should only have to do it once, instead of doing it once per each file node we're creating.
Here is a snapshot showing the graph construction part of compilation when GraphBasedChecking is enabled:

Another low-hanging fruit is the memoization where we hash FSharpLists which looks expensive:

Another less important one is here:
https://github.com/dotnet/fsharp/blob/9c55d323c2dae199ea83dd946cf9859163b390dd/src/Compiler/Driver/GraphChecking/DependencyResolution.fs#L97-L98

This issue is to track this work. I'm happy to submit a PR at some point.
Contributor guide
Assessment
This issue has not been assessed yet.