Skip to content

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

@safesparrow

Description

@safesparrow

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:

let implicitDepIdx =
files
|> Array.tryFindIndex (fun f -> FileSystemUtils.fileNameOfPath f.FileName = filename)

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

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

Another less important one is here:

(stateAfterFullIdentifier, state.OpenNamespaces)
||> Set.fold (fun acc openNS -> processIdentifier queryTrie [ yield! openNS; yield! path ] acc))

image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions