dotnet / dotnet/fsharp

Graph-based type-checking: speedup graph building by avoiding unnecessary inefficient path checks

Open
#15,427 0 comments 1 reaction 0 assignees View on GitHub
Feature Improvement
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:
![image](https://github.com/dotnet/fsharp/assets/2478401/929953c7-e663-4b30-a6e9-c5a9e973ad78)

Another low-hanging fruit is the memoization where we hash FSharpLists which looks expensive:
![image](https://github.com/dotnet/fsharp/assets/2478401/6a2615d6-474b-40f1-9af4-325f96040326)

Another less important one is here:
https://github.com/dotnet/fsharp/blob/9c55d323c2dae199ea83dd946cf9859163b390dd/src/Compiler/Driver/GraphChecking/DependencyResolution.fs#L97-L98
![image](https://github.com/dotnet/fsharp/assets/2478401/447e91db-5578-469b-9c2f-70f345d36c5a)

This issue is to track this work. I'm happy to submit a PR at some point.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.