You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix super-linear compilation of guarded shared-or active-pattern matches (#20244)
* Fix exponential compilation of guarded shared-or partial-active-pattern matches (#18425)
A single match clause of N disjuncts sharing one `when` guard, whose disjuncts
contain partial active patterns, compiled in exponential (2^N) time and assembly
size and eventually overflowed the stack at analysis time.
Each guarded disjunct contributes both a match-fail edge and a guard-false edge
into the same residual decision state, which InvestigateFrontiers re-investigated
along all 2^N paths with nothing sharing the identical residuals.
Memoize the residual states (Maranget-style join point): each distinct residual
state is keyed by structural identity plus captured locals and, once it has been
reached more than a fixed threshold (32) of times, compiled once into a let-bound
join function that later equal-keyed paths call. Below the threshold the emitted
IL is byte-for-byte identical to before, so ordinary code is unchanged; byref-like
result types disable memoization for the whole match (a join is an FSharpFunc and
the CLR forbids byref-like generic arguments). Active patterns are evaluated the
same number of times, in the same order, with the same side effects.b3
Copy file name to clipboardExpand all lines: docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
### Fixed
2
2
3
3
* Fix recursive inline SRTP resolution being truncated by one currying level (e.g. FSharpPlus `memoizeN`), a regression from the function-domain unification order change in [PR #15181](https://github.com/dotnet/fsharp/pull/15181); the contravariant domain now keeps the inference variable that still carries the pending member constraint. ([PR #20247](https://github.com/dotnet/fsharp/pull/20247))
4
+
* Fix exponential (2^N) compile time in pattern matching with shared guards and partial active patterns. ([Issue #18425](https://github.com/dotnet/fsharp/issues/18425), [PR #20244](https://github.com/dotnet/fsharp/pull/20244))
4
5
* Fix incorrect `StructLayout(Size = 1)` emission for data-less struct unions where the compiler-generated tag field makes the actual runtime size larger. ([PR #19759](https://github.com/dotnet/fsharp/pull/19759))
5
6
* Fix FS0750 "This construct may only be used within computation expressions" incorrectly raised for `let!`/`use!`/`do!` appearing in the right-hand side of a plain `let` binding inside a computation expression. The right-hand side is now desugared as a nested computation of the same builder whose result is bound with `let!`, keeping its bindings correctly scoped. ([Issue #19457](https://github.com/dotnet/fsharp/issues/19457), [PR #19868](https://github.com/dotnet/fsharp/pull/19868))
6
7
* Stop leaking a `System.Diagnostics.Metrics.MeterListener` per `Cache` in DEBUG builds. Each cache created a `CacheMetrics.CacheMetricsListener` (which starts a `MeterListener` registered in the process-global metrics registry) and never disposed it, so listeners accumulated for the lifetime of the process. Because every cache hit/miss/add published to all registered listeners, the per-operation cost grew linearly with the number of leaked listeners, so repeated checks (and Debug FCS test runs) slowed down over time. The per-cache `CacheMetricsListener` and the per-instance `cacheId` tag are removed; `DebugDisplay` and tests now read the existing name-aggregated stats populated by the single `ListenToAll` listener, so no per-cache listener is created and no per-operation cost is added. ([PR #19995](https://github.com/dotnet/fsharp/pull/19995))
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/ExpressionQuotations/QuotationRendering/QuotationRenderingTests.fs
0 commit comments