Skip to content

Commit c0c71c3

Browse files
authored
Enable net6.0 build (#2497)
This allows for using new APIs introduced in net6.0. In order to enable building for net6.0, we also need to revert the thread pool changes in #1939 and #1950. This was already effectively reverted in #1992 by not building for net6.0. Now that we are building for net6.0 again, these if-defs need to be removed.
1 parent 5e618dc commit c0c71c3

File tree

5 files changed

+6
-27
lines changed

5 files changed

+6
-27
lines changed

docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Current package versions:
88

99
## Unreleased
1010

11+
- Change: Target net6.0 instead of net5.0, since net5.0 is end of life. ([#2497 by eerhardt](https://github.com/StackExchange/StackExchange.Redis/pull/2497))
1112
- Fix: Fix nullability annotation of IConnectionMultiplexer.RegisterProfiler ([#2494 by eerhardt](https://github.com/StackExchange/StackExchange.Redis/pull/2494))
1213

1314
## 2.6.116
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
22

33
namespace StackExchange.Redis;
44

@@ -9,27 +9,11 @@ public partial class ConnectionMultiplexer
99
[MemberNotNull(nameof(SocketManager))]
1010
private void OnCreateReaderWriter(ConfigurationOptions configuration)
1111
{
12-
SocketManager = configuration.SocketManager ?? GetDefaultSocketManager();
12+
SocketManager = configuration.SocketManager ?? SocketManager.Shared;
1313
}
1414

1515
private void OnCloseReaderWriter()
1616
{
1717
SocketManager = null;
1818
}
19-
20-
/// <summary>
21-
/// .NET 6.0+ has changes to sync-over-async stalls in the .NET primary thread pool
22-
/// If we're in that environment, by default remove the overhead of our own threadpool
23-
/// This will eliminate some context-switching overhead and better-size threads on both large
24-
/// and small environments, from 16 core machines to single core VMs where the default 10 threads
25-
/// isn't an ideal situation.
26-
/// </summary>
27-
internal static SocketManager GetDefaultSocketManager()
28-
{
29-
#if NET6_0_OR_GREATER
30-
return SocketManager.ThreadPool;
31-
#else
32-
return SocketManager.Shared;
33-
#endif
34-
}
3519
}

src/StackExchange.Redis/PhysicalBridge.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -855,10 +855,6 @@ private void StartBacklogProcessor()
855855
{
856856
_backlogStatus = BacklogStatus.Activating;
857857

858-
#if NET6_0_OR_GREATER
859-
// In .NET 6, use the thread pool stall semantics to our advantage and use a lighter-weight Task
860-
Task.Run(ProcessBacklogAsync);
861-
#else
862858
// Start the backlog processor; this is a bit unorthodox, as you would *expect* this to just
863859
// be Task.Run; that would work fine when healthy, but when we're falling on our face, it is
864860
// easy to get into a thread-pool-starvation "spiral of death" if we rely on the thread-pool
@@ -871,7 +867,6 @@ private void StartBacklogProcessor()
871867
Name = "StackExchange.Redis Backlog", // help anyone looking at thread-dumps
872868
};
873869
thread.Start(this);
874-
#endif
875870
}
876871
else
877872
{

src/StackExchange.Redis/StackExchange.Redis.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
<PropertyGroup>
33
<Nullable>enable</Nullable>
44
<!-- extend the default lib targets for the main lib; mostly because of "vectors" -->
5-
<!-- Note: we're NOT building for .NET 6 because the thread pool changes are not wins yet -->
6-
<TargetFrameworks>net461;netstandard2.0;net472;netcoreapp3.1;net5.0</TargetFrameworks>
5+
<TargetFrameworks>net461;netstandard2.0;net472;netcoreapp3.1;net6.0</TargetFrameworks>
76
<Description>High performance Redis client, incorporating both synchronous and asynchronous usage.</Description>
87
<AssemblyName>StackExchange.Redis</AssemblyName>
98
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
@@ -35,7 +34,7 @@
3534
<AdditionalFiles Include="PublicAPI/PublicAPI.Shipped.txt" />
3635
<AdditionalFiles Include="PublicAPI/PublicAPI.Unshipped.txt" />
3736
<!-- APIs for netcoreapp3.1+ -->
38-
<AdditionalFiles Include="PublicAPI/netcoreapp3.1/PublicAPI.Shipped.txt" Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0'" />
37+
<AdditionalFiles Include="PublicAPI/netcoreapp3.1/PublicAPI.Shipped.txt" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
3938
</ItemGroup>
4039

4140
<ItemGroup>

tests/StackExchange.Redis.Tests/ConfigTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public void DefaultThreadPoolManagerIsDetected()
468468

469469
using var conn = ConnectionMultiplexer.Connect(config);
470470

471-
Assert.Same(ConnectionMultiplexer.GetDefaultSocketManager().Scheduler, conn.SocketManager?.Scheduler);
471+
Assert.Same(SocketManager.Shared.Scheduler, conn.SocketManager?.Scheduler);
472472
}
473473

474474
[Theory]

0 commit comments

Comments
 (0)