From 59da2cc70ce30378910cb4e95d87fe3bc05bd298 Mon Sep 17 00:00:00 2001 From: vitek-karas Date: Sun, 15 Aug 2021 14:27:45 -0700 Subject: [PATCH 1/2] Revert workarounds for mono/linker#2181 Trying to revert both. The Http3RequestStream is definitely fixed by the linker changes. The ArrayPool ones probably not, but trying to get a repro. --- .../src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs index d38bda960e7528..45d8f93cf7a4b3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs @@ -211,7 +211,6 @@ public bool Trim() // Under high pressure, release all thread locals. if (pressure == Utilities.MemoryPressure.High) { -#if !MONO // TODO https://github.com/mono/linker/issues/2181: Remove !MONO ifdefs in this method once is fixed if (log.IsEnabled()) { foreach (KeyValuePair tlsBuckets in _allTlsBuckets) @@ -227,7 +226,6 @@ public bool Trim() } } else -#endif { foreach (KeyValuePair tlsBuckets in _allTlsBuckets) { @@ -270,12 +268,10 @@ public bool Trim() // Clear out the array, and log its being trimmed if desired. if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer) { -#if !MONO if (log.IsEnabled()) { log.BufferTrimmed(buffer.GetHashCode(), buffer.Length, Id); } -#endif } } } From d8b1b1bb69982d43eb63e8a34db674d55d6f44a5 Mon Sep 17 00:00:00 2001 From: vitek-karas Date: Mon, 16 Aug 2021 07:55:18 -0700 Subject: [PATCH 2/2] Fully revert ArrayPool workaround --- .../TlsOverPerCoreLockedStacksArrayPool.cs | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs index 45d8f93cf7a4b3..108cee7b4a6e39 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/TlsOverPerCoreLockedStacksArrayPool.cs @@ -211,7 +211,14 @@ public bool Trim() // Under high pressure, release all thread locals. if (pressure == Utilities.MemoryPressure.High) { - if (log.IsEnabled()) + if (!log.IsEnabled()) + { + foreach (KeyValuePair tlsBuckets in _allTlsBuckets) + { + Array.Clear(tlsBuckets.Key); + } + } + else { foreach (KeyValuePair tlsBuckets in _allTlsBuckets) { @@ -225,13 +232,6 @@ public bool Trim() } } } - else - { - foreach (KeyValuePair tlsBuckets in _allTlsBuckets) - { - Array.Clear(tlsBuckets.Key); - } - } } else { @@ -266,12 +266,10 @@ public bool Trim() { // Time noticeably wrapped, or we've surpassed the threshold. // Clear out the array, and log its being trimmed if desired. - if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer) + if (Interlocked.Exchange(ref buckets[i].Array, null) is T[] buffer && + log.IsEnabled()) { - if (log.IsEnabled()) - { - log.BufferTrimmed(buffer.GetHashCode(), buffer.Length, Id); - } + log.BufferTrimmed(buffer.GetHashCode(), buffer.Length, Id); } } }