dotnet / dotnet/fsharp

Tokenizing massive F# file leads to LOH allocations and UI freezes in VS

Open
#9,069 7 comments 0 reactions 0 assignees View on GitHub
Area-LangService-Colorization Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

1. Open the F# codebase
2. Open some F# compiler files (this is just to get memory usage up to where it normally is when working in the compiler)
3. Open `ComparersRegression.fs` (nearly 60k LoC)
4. Scroll around, note that memory pressure is high in VS and the UI freezes often

From a 50ish second sample:

![image](https://user-images.githubusercontent.com/6309070/80543992-f3e7a180-8964-11ea-96a2-7447e7fa3970.png)

These LOH allocs are all coming from tokenizing the source, the `SourceTextData.extendTo` function: https://github.com/dotnet/fsharp/blob/be621d8725e3ea88cb832f4d457bc0bf377172ed/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs#L419

![image](https://user-images.githubusercontent.com/6309070/80544041-0a8df880-8965-11ea-8ecf-36de10a496cc.png)

And tokenizing source itself is the lion's share of all allocs. Note the LOH part of it:

![image](https://user-images.githubusercontent.com/6309070/80544206-65275480-8965-11ea-9a16-03e3b77f004c.png)

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.