Skip to content

Commit

Permalink
Version 5.6.0 with a variety of improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerje committed Dec 1, 2024
1 parent 394cc5e commit 07a638a
Show file tree
Hide file tree
Showing 42 changed files with 372 additions and 244 deletions.
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,23 @@ Get the [NuGet package here][].

- Protocol, serialization and execution strategy extension

Portions of this library are a derivative of [RemotingLite][].
Portions of this library (dynamic proxy) are a derivative of RemotingLite by Frank Thomsen.

[NuGet package here]: http://www.nuget.org/packages/ServiceWire/
[RemotingLite]: http://remotinglite.codeplex.com/
[RemotingLite by Frank Thomsen]: https://codeplexarchive.org/codeplex/project/RemotingLite
[ServiceWire documentation]: https://github.com/tylerjensen/ServiceWire/wiki

## History

### NamedPipeServerStreamFactory and Other Improvements 5.6.0

1. Contributed fix where accepting TCP clients synchronously may block new clients from being accepted until the terminating request is received on the synchronous client.
1. Contributed NamedPipeServerStreamFactory to allow greater level of permissions control in using named pipes.
1. Introducted injectable ILog and IStats across channels and clients with default NullLogger and NullStats, making InjectLoggerStats obsolete.
1. Code improvements for code consistency and eliminating outdated frameworks from tests and supporting projects.
1. Updated several dependencies in supporting projects.
1. Updated System.Text.Json to 9.0.0 to resolve known vulnerabilities in previous versions.

### Support for Enum by Ref 5.5.4

1. Contributed support for proper async exceptions.
Expand Down Expand Up @@ -168,6 +177,61 @@ Note: Use of async/await and Task<T> not recommended. Use of Task return type no
6. Removed dependency on System.Numerics in order to support .NET 3.5 and introduced ZkBigInt class taken from Scott Garland's BigInteger class. See license text for full attribution.


### AllBenchmarks Update (12/1/2024)

We recommend using .NET 8. There is an average 21% performance improvement.

```
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4460/23H2/2023Update/SunValley3)
AMD Ryzen Threadripper PRO 5975WX 32-Cores, 1 CPU, 64 logical and 32 physical cores
.NET SDK 9.0.100
[Host] : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX2
.NET 6.0 : .NET 6.0.36 (6.0.3624.51421), X64 RyuJIT AVX2
.NET 8.0 : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX2
InvocationCount=1024 MaxIterationCount=64 MinIterationCount=8
UnrollFactor=1
| Method | Job | Runtime | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|------------- |------------------- |------------------- |---------:|---------:|---------:|---------:|------:|--------:|-------:|----------:|------------:|
| TcpSim | .NET 6.0 | .NET 6.0 | 27.78 us | 0.542 us | 0.845 us | 27.80 us | 1.05 | 0.11 | - | 569 B | 0.89 |
| TcpSim | .NET 8.0 | .NET 8.0 | 26.69 us | 1.311 us | 2.986 us | 25.21 us | 1.01 | 0.15 | - | 641 B | 1.00 |
| | | | | | | | | | | | |
| TcpSimJson | .NET 6.0 | .NET 6.0 | 28.40 us | 0.567 us | 0.296 us | 28.42 us | 1.14 | 0.04 | - | 569 B | 0.89 |
| TcpSimJson | .NET 8.0 | .NET 8.0 | 25.02 us | 0.497 us | 0.908 us | 24.83 us | 1.00 | 0.05 | - | 641 B | 1.00 |
| | | | | | | | | | | | |
| TcpRg | .NET 6.0 | .NET 6.0 | 73.61 us | 0.911 us | 0.404 us | 73.50 us | 1.37 | 0.03 | - | 15417 B | 1.05 |
| TcpRg | .NET 8.0 | .NET 8.0 | 53.87 us | 0.866 us | 1.064 us | 53.64 us | 1.00 | 0.03 | - | 14738 B | 1.00 |
| | | | | | | | | | | | |
| TcpRgJson | .NET 6.0 | .NET 6.0 | 73.03 us | 1.345 us | 0.890 us | 72.85 us | 1.32 | 0.05 | - | 15417 B | 1.05 |
| TcpRgJson | .NET 8.0 | .NET 8.0 | 55.51 us | 1.104 us | 2.073 us | 54.88 us | 1.00 | 0.05 | - | 14738 B | 1.00 |
| | | | | | | | | | | | |
| TcpCxOut | .NET 6.0 | .NET 6.0 | 62.84 us | 1.198 us | 0.626 us | 62.64 us | 1.30 | 0.03 | - | 6929 B | 0.86 |
| TcpCxOut | .NET 8.0 | .NET 8.0 | 48.35 us | 0.802 us | 1.224 us | 47.99 us | 1.00 | 0.03 | - | 8066 B | 1.00 |
| | | | | | | | | | | | |
| TcpCxOutJson | .NET 6.0 | .NET 6.0 | 64.35 us | 1.194 us | 0.932 us | 64.21 us | 1.33 | 0.05 | - | 6929 B | 0.86 |
| TcpCxOutJson | .NET 8.0 | .NET 8.0 | 48.61 us | 0.970 us | 2.004 us | 47.87 us | 1.00 | 0.06 | - | 8066 B | 1.00 |
| | | | | | | | | | | | |
| NpSim | .NET 6.0 | .NET 6.0 | 22.64 us | 0.540 us | 1.229 us | 22.29 us | 1.36 | 0.15 | - | 569 B | 0.89 |
| NpSim | .NET 8.0 | .NET 8.0 | 16.88 us | 0.870 us | 1.873 us | 16.35 us | 1.01 | 0.15 | - | 641 B | 1.00 |
| | | | | | | | | | | | |
| NpSimJson | .NET 6.0 | .NET 6.0 | 21.77 us | 0.421 us | 0.643 us | 21.59 us | 1.33 | 0.12 | - | 569 B | 0.89 |
| NpSimJson | .NET 8.0 | .NET 8.0 | 16.50 us | 0.760 us | 1.604 us | 15.83 us | 1.01 | 0.13 | - | 641 B | 1.00 |
| | | | | | | | | | | | |
| NpRg | .NET 6.0 | .NET 6.0 | 63.31 us | 0.994 us | 1.144 us | 63.18 us | 1.37 | 0.04 | - | 15417 B | 1.05 |
| NpRg | .NET 8.0 | .NET 8.0 | 46.07 us | 0.650 us | 1.031 us | 45.96 us | 1.00 | 0.03 | - | 14738 B | 1.00 |
| | | | | | | | | | | | |
| NpRgJson | .NET 6.0 | .NET 6.0 | 71.55 us | 0.990 us | 0.518 us | 71.49 us | 1.40 | 0.07 | 0.9766 | 27194 B | 1.09 |
| NpRgJson | .NET 8.0 | .NET 8.0 | 51.35 us | 1.348 us | 2.783 us | 50.50 us | 1.00 | 0.07 | 0.9766 | 24882 B | 1.00 |
| | | | | | | | | | | | |
| NpCxOut | .NET 6.0 | .NET 6.0 | 55.37 us | 0.802 us | 0.670 us | 55.17 us | 1.22 | 0.09 | - | 6929 B | 0.86 |
| NpCxOut | .NET 8.0 | .NET 8.0 | 45.83 us | 1.780 us | 3.831 us | 44.24 us | 1.01 | 0.11 | - | 8066 B | 1.00 |
| | | | | | | | | | | | |
| NpCxOutJson | .NET 6.0 | .NET 6.0 | 58.59 us | 1.109 us | 1.037 us | 58.35 us | 1.27 | 0.08 | - | 10857 B | 0.91 |
| NpCxOutJson | .NET 8.0 | .NET 8.0 | 46.39 us | 1.478 us | 2.986 us | 44.93 us | 1.00 | 0.09 | - | 11890 B | 1.00 |
```


### ConnBenchmarks (6/6/2022)

No real change from previous benchmarks. Making a connection is still expensive. About 15ms.
Expand Down
3 changes: 2 additions & 1 deletion src/Benchmarks/ServiceWire.Benchmarks/AllBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace ServiceWire.Benchmarks
[MinIterationCount(8)]
[MaxIterationCount(64)]
[InvocationCount(1024)]
[SimpleJob(RuntimeMoniker.Net60, baseline: true)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net48)]
[MemoryDiagnoser]
public class AllBenchmarks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace ServiceWire.Benchmarks
[MinIterationCount(4)]
[MaxIterationCount(16)]
[InvocationCount(64)]
[SimpleJob(RuntimeMoniker.Net60, baseline: true)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net48)]
[MemoryDiagnoser]
public class ConnectionBenchmarks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace ServiceWire.Benchmarks
[MinIterationCount(8)]
[MaxIterationCount(64)]
[InvocationCount(1024)]
[SimpleJob(RuntimeMoniker.Net60, baseline: true)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net48)]
[MemoryDiagnoser]
public class NamedPipesBenchmarks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1;net48;net462</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0;net48</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>true</Optimize>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="protobuf-net" Version="3.1.4" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="protobuf-net" Version="3.2.45" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
<PackageReference Include="System.Reflection.Metadata" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Benchmarks/ServiceWire.Benchmarks/TcpBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace ServiceWire.Benchmarks
[MinIterationCount(8)]
[MaxIterationCount(64)]
[InvocationCount(1024)]
[SimpleJob(RuntimeMoniker.Net60, baseline: true)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net48)]
[MemoryDiagnoser]
public class TcpBenchmarks
Expand Down
45 changes: 26 additions & 19 deletions src/Demo/DemoClient/DemoClient.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>net462</TargetFrameworks>
<!-- <TargetFrameworks>net6.0;netcoreapp3.1;net48;net462</TargetFrameworks> -->
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>net6.0;net8.0;net48</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ServiceWire\ServiceWire.csproj" />
<ProjectReference Include="..\DemoCommon\DemoCommon.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="9.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\ServiceWire\ServiceWire.csproj" />
<ProjectReference Include="..\DemoCommon\DemoCommon.csproj" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Demo/DemoCommon/DemoCommon.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>net6.0;netcoreapp3.1;net48;net462</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0;net48</TargetFrameworks>
</PropertyGroup>

</Project>
15 changes: 11 additions & 4 deletions src/Demo/DemoHost/DemoHost.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>net6.0</TargetFrameworks>
<!-- <TargetFrameworks>net6.0;netcoreapp3.1;net48;net462</TargetFrameworks> -->
<TargetFrameworks>net6.0;net8.0;net48</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -14,8 +13,16 @@
<StartupObject />
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="9.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Demo/DemoHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class IPCBridge : IIPCBridge
{
public List<float> GetData()
{
List<float> list = new();
List<float> list = new List<float>();
list.Add(99.625F);
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ServiceWire" Version="5.4.2" />
<PackageReference Include="ServiceWire" Version="5.5.4" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions src/ServiceWire/Aspects/InterceptChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public class InterceptChannel : Channel

public InterceptPoint InterceptPoint { get { return _interceptPoint; } }

public InterceptChannel(Type interceptedType, InterceptPoint interceptPoint, ISerializer serializer, ICompressor compressor)
: base(serializer, compressor)
public InterceptChannel(Type interceptedType, InterceptPoint interceptPoint, ISerializer serializer, ICompressor compressor,
ILog logger = null, IStats stats = null)
: base(serializer, compressor, logger, stats)
{
_serviceType = interceptedType;
_interceptPoint = interceptPoint;
Expand Down
26 changes: 14 additions & 12 deletions src/ServiceWire/Aspects/Interceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ namespace ServiceWire.Aspects
{
public static class Interceptor
{
public static TTarget Intercept<TTarget>(TTarget target, CrossCuttingConcerns crossCuttingConcerns, ISerializer serializer = null, ICompressor compressor = null) where TTarget : class
public static TTarget Intercept<TTarget>(TTarget target, CrossCuttingConcerns crossCuttingConcerns, ISerializer serializer = null, ICompressor compressor = null, ILog logger = null, IStats stats = null) where TTarget : class
{
return Intercept<TTarget>(0, target, crossCuttingConcerns, serializer, compressor);
return Intercept<TTarget>(0, target, crossCuttingConcerns, serializer, compressor, logger, stats);
}

public static TTarget Intercept<TTarget>(int id, TTarget target, CrossCuttingConcerns crossCuttingConcerns, ISerializer serializer = null, ICompressor compressor = null) where TTarget : class
public static TTarget Intercept<TTarget>(int id, TTarget target, CrossCuttingConcerns crossCuttingConcerns, ISerializer serializer = null, ICompressor compressor = null, ILog logger = null, IStats stats = null) where TTarget : class
{
if (!typeof(TTarget).IsInterface) throw new ArgumentException("TTarget not an interface");
if (null == target) throw new ArgumentNullException("target");
if (null == serializer) serializer = new DefaultSerializer();
if (null == compressor) compressor = new DefaultCompressor();
TTarget interceptedTarget = ProxyFactory.CreateProxy<TTarget>(typeof(InterceptChannel),
typeof(InterceptPoint),
new InterceptPoint
{
Id = id,
Target = target,
Cut = crossCuttingConcerns
},
serializer,
compressor);
typeof(InterceptPoint),
new InterceptPoint
{
Id = id,
Target = target,
Cut = crossCuttingConcerns
},
serializer,
compressor,
logger,
stats);
return interceptedTarget;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/ServiceWire/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ public abstract class Channel : IDisposable
{
protected Type _serviceType;

protected ILog _logger = new NullLogger();
protected IStats _stats = new NullStats();
protected ILog _logger;
protected IStats _stats;
internal readonly ISerializer _serializer;
internal readonly ICompressor _compressor;

public Channel(ISerializer serializer, ICompressor compressor)
public Channel(ISerializer serializer, ICompressor compressor, ILog logger = null, IStats stats = null)
{
_serializer = serializer ?? new DefaultSerializer();
_compressor = compressor ?? new DefaultCompressor();
_logger = logger ?? new NullLogger();
_stats = stats ?? new NullStats();
}

[Obsolete]
public void InjectLoggerStats(ILog logger, IStats stats)
{
_logger = logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace ServiceWire.NamedPipes
{
public class DefaultNamedPipeServerStreamFactory : INamedPipeServerStreamFactory
{
public NamedPipeServerStream Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize)
public NamedPipeServerStream Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize)
{
return new NamedPipeServerStream(pipeName, direction, maxNumberOfServerInstances, transmissionMode, options, inBufferSize, outBufferSize);
}
Expand Down
3 changes: 2 additions & 1 deletion src/ServiceWire/NamedPipes/INamedPipeServerStreamFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace ServiceWire.NamedPipes
{
public interface INamedPipeServerStreamFactory
{
NamedPipeServerStream Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize);
NamedPipeServerStream Create(string pipeName, PipeDirection direction, int maxNumberOfServerInstances,
PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize);
}
}
Loading

0 comments on commit 07a638a

Please sign in to comment.