fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

A few super-minor compiler perf improvements

Open brianrourkeboll opened this issue 1 year ago • 1 comments

Description

I saw some of these show up when I did a quick profile of FSharp.Compiler.ComponentTests, which take the longest to run of all the tests.

  • Override ToString on BuildPhase; the automatic printf-based implementation does a lot more work than it needs to for a fieldless DU.

    Example DiagnosticsLogger_BuildPhase_ToString_Screenshot 2024-05-09 110559_2

    https://github.com/dotnet/fsharp/blob/fec36c9fe756063c8d21331b338710f3c4a501b8/src/Compiler/Driver/ParseAndCheckInputs.fs#L410-L428

    I guess I could have just changed the above to this instead:

    -Activity.Tags.buildPhase, BuildPhase.Parse.ToString()
    +Activity.Tags.buildPhase, nameof BuildPhase.Parse
    

    But maybe it's best to speed up any potential future stringifications anyway, just in case.

  • Cache the delegate passed into ConcurrentDictionary.GetOrAdd where possible. See #14582, fsharp/fslang-suggestions#1083, etc.

  • Remove a redundant StringBuilder in one place.

Checklist

  • [x] Release notes entry updated.

brianrourkeboll avatar May 09 '24 20:05 brianrourkeboll

:heavy_exclamation_mark: Release notes required


:white_check_mark: Found changes and release notes in following paths:

Change path Release notes path Description
src/FSharp.Core docs/release-notes/.FSharp.Core/8.0.400.md
src/Compiler docs/release-notes/.FSharp.Compiler.Service/8.0.400.md

github-actions[bot] avatar May 09 '24 20:05 github-actions[bot]