A few super-minor compiler perf improvements
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
ToStringonBuildPhase; the automaticprintf-based implementation does a lot more work than it needs to for a fieldless DU.Example
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.ParseBut maybe it's best to speed up any potential future stringifications anyway, just in case.
-
Cache the delegate passed into
ConcurrentDictionary.GetOrAddwhere possible. See #14582, fsharp/fslang-suggestions#1083, etc. -
Remove a redundant
StringBuilderin one place.
Checklist
- [x] Release notes entry updated.
: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.Coredocs/release-notes/.FSharp.Core/8.0.400.md src/Compilerdocs/release-notes/.FSharp.Compiler.Service/8.0.400.md