Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable net6.0 build #2497

Merged
merged 3 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Current package versions:

## Unreleased

- 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))
- Fix: Fix nullability annotation of IConnectionMultiplexer.RegisterProfiler ([#2494 by eerhardt](https://github.com/StackExchange/StackExchange.Redis/pull/2494))

## 2.6.116
Expand Down
20 changes: 2 additions & 18 deletions src/StackExchange.Redis/ConnectionMultiplexer.ReaderWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;

namespace StackExchange.Redis;

Expand All @@ -9,27 +9,11 @@ public partial class ConnectionMultiplexer
[MemberNotNull(nameof(SocketManager))]
private void OnCreateReaderWriter(ConfigurationOptions configuration)
{
SocketManager = configuration.SocketManager ?? GetDefaultSocketManager();
SocketManager = configuration.SocketManager ?? SocketManager.Shared;
}

private void OnCloseReaderWriter()
{
SocketManager = null;
}

/// <summary>
/// .NET 6.0+ has changes to sync-over-async stalls in the .NET primary thread pool
/// If we're in that environment, by default remove the overhead of our own threadpool
/// This will eliminate some context-switching overhead and better-size threads on both large
/// and small environments, from 16 core machines to single core VMs where the default 10 threads
/// isn't an ideal situation.
/// </summary>
internal static SocketManager GetDefaultSocketManager()
{
#if NET6_0_OR_GREATER
return SocketManager.ThreadPool;
#else
return SocketManager.Shared;
#endif
}
}
5 changes: 0 additions & 5 deletions src/StackExchange.Redis/PhysicalBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,6 @@ private void StartBacklogProcessor()
{
_backlogStatus = BacklogStatus.Activating;

#if NET6_0_OR_GREATER
// In .NET 6, use the thread pool stall semantics to our advantage and use a lighter-weight Task
Task.Run(ProcessBacklogAsync);
#else
// Start the backlog processor; this is a bit unorthodox, as you would *expect* this to just
// be Task.Run; that would work fine when healthy, but when we're falling on our face, it is
// easy to get into a thread-pool-starvation "spiral of death" if we rely on the thread-pool
Expand All @@ -871,7 +867,6 @@ private void StartBacklogProcessor()
Name = "StackExchange.Redis Backlog", // help anyone looking at thread-dumps
};
thread.Start(this);
#endif
}
else
{
Expand Down
5 changes: 2 additions & 3 deletions src/StackExchange.Redis/StackExchange.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<PropertyGroup>
<Nullable>enable</Nullable>
<!-- extend the default lib targets for the main lib; mostly because of "vectors" -->
<!-- Note: we're NOT building for .NET 6 because the thread pool changes are not wins yet -->
<TargetFrameworks>net461;netstandard2.0;net472;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;net472;netcoreapp3.1;net6.0</TargetFrameworks>
<Description>High performance Redis client, incorporating both synchronous and asynchronous usage.</Description>
<AssemblyName>StackExchange.Redis</AssemblyName>
<AssemblyTitle>StackExchange.Redis</AssemblyTitle>
Expand Down Expand Up @@ -35,7 +34,7 @@
<AdditionalFiles Include="PublicAPI/PublicAPI.Shipped.txt" />
<AdditionalFiles Include="PublicAPI/PublicAPI.Unshipped.txt" />
<!-- APIs for netcoreapp3.1+ -->
<AdditionalFiles Include="PublicAPI/netcoreapp3.1/PublicAPI.Shipped.txt" Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0'" />
<AdditionalFiles Include="PublicAPI/netcoreapp3.1/PublicAPI.Shipped.txt" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/StackExchange.Redis.Tests/ConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public void DefaultThreadPoolManagerIsDetected()

using var conn = ConnectionMultiplexer.Connect(config);

Assert.Same(ConnectionMultiplexer.GetDefaultSocketManager().Scheduler, conn.SocketManager?.Scheduler);
Assert.Same(SocketManager.Shared.Scheduler, conn.SocketManager?.Scheduler);
}

[Theory]
Expand Down