Skip to content

String allocations from fullNameOfEntitityRef when used in ItemsAreEffectivelyEqual - necessary? #10898

Open
@cartermp

Description

@cartermp

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

image

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

| Item.ModuleOrNamespaces modrefs1, Item.ModuleOrNamespaces modrefs2 ->
modrefs1 |> List.exists (fun modref1 -> modrefs2 |> List.exists (fun r -> tyconRefDefnEq g modref1 r || fullDisplayTextOfModRef modref1 = fullDisplayTextOfModRef r))
| _ -> false

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FCSImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions