Suboptimal code generated when pattern matching a tuple in a lambda parameter #16037
Labels
Area-Compiler-CodeGen
IlxGen, ilwrite and things at the backend
Feature Improvement
Theme-Performance
Milestone
When pattern matching a tuple in the parameter of a lambda function, the performance is inferior compared to using the
fst
/snd
functions or pattern matching inside the function.Repro steps
Consider the following example code:
I would expect the three functions to have similar performance and code-style-wise I would in many cases prefer the pattern match in the parameter.
In the decomplied code, two FSharpFunc classes are created when the pattern matching in the parameter is used.
Benchmark result with the example code:
Expected behavior
Pattern matching a tuple in a parameter does not affect performance.
Actual behavior
Pattern matching a tuple in a parameter degrades performance and causes more memory allocations.
Known workarounds
Use the
fst
/snd
functions or do the pattern match in the body of the lambda function.The text was updated successfully, but these errors were encountered: