dotnet / dotnet/fsharp

String allocations from fullNameOfEntitityRef when used in ItemsAreEffectivelyEqual - necessary?

Open
#10,898 1 comment 1 reaction 0 assignees View on GitHub
Area-FCS Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

I took a sample of editing some code across several in FSharp.Editor.dll and noticed that there's a _lot_ of string allocations happening in `ItemsAreEffectivelyEqual`. In only 37 seconds it allocated **84 MB**. Most of these are small and short-lived, but it still feels excessive.

Two routines are involved, both allocating a lot:

![image](https://user-images.githubusercontent.com/6309070/105074966-f67faf00-5a3d-11eb-826b-bb37d29753b5.png)

![image](https://user-images.githubusercontent.com/6309070/105075342-80c81300-5a3e-11eb-8e6d-781ec3b6c5cd.png)

Looking at the code, this happens when checking `Item.ModuleOrNamespaces` here:

https://github.com/dotnet/fsharp/blob/2571fe75185b057828532faa1f1b037b164a8a03/src/fsharp/NameResolution.fs#L1813-L1816

And it appears to be a "only do this if everything else failed" check.

Is it necessary? This is a lot of string allocations, and when combined makes up the bulk registered by profiling when editing code. Note that the source of these allocations is **unused opens analysis**.

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.