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

Add UnixDomainSocket feature to interprocess PubSub #61

Merged
merged 17 commits into from Jan 13, 2022

Conversation

itn3000
Copy link
Contributor

@itn3000 itn3000 commented Jun 17, 2021

In some cases,unix domain socket may be more efficient than IP socket(especially linux).
I think I must resolve following problems for review

  • how to pass unix domain socket option(smart way must be found)
  • comparison about throughput for IP and unix domain socket
  • resolving why GetResult and UnsafeGetStatus appears twice in src/MessagePipe.Unity/Assets/Plugins/MessagePipe/Runtime/SubscriberExtensions.FirstAsync.cs

@itn3000
Copy link
Contributor Author

itn3000 commented Jun 23, 2021

duplicated method problem is fixed by #64

@itn3000
Copy link
Contributor Author

itn3000 commented Jun 24, 2021

add following methods and classes to public.
These are only enabled on tfm=net5.0 because UDS in .NET is supported by 5.0 or later.

  • MessagePipeInterprocessUdpUdsOptions
  • MessagePipeInterprocessTcpUdsOptions
  • UdpWorker.ctor(MessagePipeInterprocessUdpUdsOptions options, , IAsyncPublisher<IInterprocessKey, IInterprocessValue> publisher)
  • TcpWorker.ctor(IServiceProvider provider, MessagePipeInterprocessTcpUdsOptions options, IAsyncPublisher<IInterprocessKey, IInterprocessValue> publisher)
  • TcpDistributedSubscriber.ctor(TcpWorker worker, MessagePipeInterprocessTcpUdsOptions options, IAsyncSubscriber<IInterprocessKey, IInterprocessValue> subscriberCore, FilterAttachedMessageHandlerFactory syncHandlerFactory, FilterAttachedAsyncMessageHandlerFactory asyncHandlerFactory)
  • UdpDistributedSubscriber.ctor(UdpWorker worker, MessagePipeInterprocessUdpUdsOptions options, IAsyncSubscriber<IInterprocessKey, IInterprocessValue> subscriberCore, FilterAttachedMessageHandlerFactory syncHandlerFactory, FilterAttachedAsyncMessageHandlerFactory asyncHandlerFactory)
  • ServiceCollectionInterprocessExtensions.AddMessagePipeTcpUdsInterprocess(this IServiceCollection services, string socketPath, Action<MessagePipeInterprocessTcpUdsOptions> configure)
  • ServiceCollectionInterprocessExtensions.AddMessagePipeUdpInterprocessUds(this IServiceCollection services, string domainSocketPath)
  • ServiceCollectionInterprocessExtensions.AddMessagePipeUdpInterprocessUds(this IServiceCollection services, string domainSocketPath, Action<MessagePipeInterprocessUdpUdsOptions> configure)
  • ServiceCollectionInterprocessExtensions.AddMessagePipeTcpInterprocessUds(this IServiceCollection services, string domainSocketPath)
  • ServiceCollectionInterprocessExtensions.AddMessagePipeTcpInterprocessUds(this IServiceCollection services, string domainSocketPath, Action<MessagePipeInterprocessTcpUdsOptions> configure)

@itn3000
Copy link
Contributor Author

itn3000 commented Jun 30, 2021

I made benchmark between TCP/IP and TCP/UDS for PubSub and IRemoteRequestHandler,
and here is the result

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19043.1081 (21H1/May2021Update)
Intel Core i7-4712MQ CPU 2.30GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.100-preview.5.21302.13
  [Host]   : .NET 5.0.7 (5.0.721.25508), X64 RyuJIT
  ShortRun : .NET 5.0.7 (5.0.721.25508), X64 RyuJIT

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3  
Method DataSize Mean Error StdDev
TcpIpRemoteRequest 1 15,713.297 μs 6,586.3137 μs 361.0181 μs
TcpUdsRemoteRequest 1 16,173.616 μs 8,344.4551 μs 457.3877 μs
TcpIpPubSub 1 11.991 μs 1.2852 μs 0.0704 μs
TcpUdsPubSub 1 4.469 μs 0.4775 μs 0.0262 μs
TcpIpRemoteRequest 1000000 21,698.121 μs 92,866.5611 μs 5,090.3296 μs
TcpUdsRemoteRequest 1000000 21,600.040 μs 120,109.9536 μs 6,583.6319 μs
TcpIpPubSub 1000000 1,267.865 μs 4,862.3026 μs 266.5192 μs
TcpUdsPubSub 1000000 1,403.482 μs 11,602.4892 μs 635.9716 μs

@itn3000 itn3000 marked this pull request as ready for review June 30, 2021 18:21
@itn3000
Copy link
Contributor Author

itn3000 commented Jul 1, 2021

I forget to add some unittests, please wait

@itn3000 itn3000 marked this pull request as draft July 1, 2021 00:40
@itn3000
Copy link
Contributor Author

itn3000 commented Jul 1, 2021

fixed

@itn3000 itn3000 marked this pull request as ready for review July 1, 2021 02:59
@itn3000
Copy link
Contributor Author

itn3000 commented Jul 2, 2021

I found redundant wait in benchmark, so I re-run benchmark, here is the result.

BenchmarkDotNet=v0.13.0, OS=Windows 10.0.19043.1081 (21H1/May2021Update)
Intel Core i7-4712MQ CPU 2.30GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.100-preview.5.21302.13
  [Host]   : .NET 5.0.7 (5.0.721.25508), X64 RyuJIT
  ShortRun : .NET 5.0.7 (5.0.721.25508), X64 RyuJIT

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3  
Method DataSize Mean Error StdDev
TcpIpRemoteRequest 1 102.389 μs 63.317 μs 3.4706 μs
TcpUdsRemoteRequest 1 82.432 μs 96.100 μs 5.2676 μs
TcpIpPubSub 1 11.407 μs 14.996 μs 0.8220 μs
TcpUdsPubSub 1 4.733 μs 1.027 μs 0.0563 μs
TcpIpRemoteRequest 1000000 1,863.976 μs 171.943 μs 9.4248 μs
TcpUdsRemoteRequest 1000000 1,707.872 μs 48.693 μs 2.6690 μs
TcpIpPubSub 1000000 649.905 μs 245.091 μs 13.4343 μs
TcpUdsPubSub 1000000 701.670 μs 774.508 μs 42.4534 μs

@neuecc
Copy link
Member

neuecc commented Jul 8, 2021

thanks for the nice PR.
Please wait a bit for the review, I will probably merge them.

@neuecc
Copy link
Member

neuecc commented Jan 13, 2022

Sorry for the extremely delay to merge.
I'll merge and release it soon.

@neuecc neuecc merged commit 044b810 into Cysharp:master Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants