Re:Memory usage of a toy C# server and client with 500K conc...
by benaadams on Saturday January 26, 2019 @07:47PM
(#19009608)
Can use System.Threading.Channels
https://docs.microsoft.com/en-us/dotnet/api/system.threading... if you like that programming model
[ Parent
| on HN ]
Re:Memory usage of a toy C# server and client with 500K conc...
by coder543 on Saturday January 26, 2019 @08:16PM
(#19009777)
Do those channels support async? Since C# is built around async/await for scaling to large numbers of connections / tasks, they wouldn't be very useful if they didn't support async, but I'm not familiar enough with modern C# to figure out if they do or not.
Re:Memory usage of a toy C# server and client with 500K conc...
by manigandham on Saturday January 26, 2019 @08:27PM
(#19009818)
Yes. It's a library that is fully async. We process millions of records/second using these.
Re:Memory usage of a toy C# server and client with 500K conc...
by noir_lord on Sunday January 27, 2019 @01:43PM
(#19013074)
Do you happen to have any public information on this approach, it sounds interesting but I'm not up on the C# world like I used to be.
Re:Memory usage of a toy C# server and client with 500K conc...
by manigandham on Sunday January 27, 2019 @02:43PM
(#19013402)
This is the best overview article so far: https://ndportmann.com/system-threading-channels/
Re:Memory usage of a toy C# server and client with 500K conc...
by noir_lord on Sunday January 27, 2019 @02:53PM
(#19013451)
Thank you.
Re:Memory usage of a toy C# server and client with 500K conc...
by benaadams on Saturday January 26, 2019 @08:28PM
(#19009826)
Yeah you have a triple for different use cases; the sync call is `TryRead` so its non-blocking; `ReadAsync` for async reading and `WaitToReadAsync` to wait for data to be available without reading (likely then followed by the non-blocking `TryRead` in usage)
Re:Memory usage of a toy C# server and client with 500K conc...
by tapirl on Saturday January 26, 2019 @08:24PM
(#19009809)
Does it support select? Almost half of concurrrent programming use cases in Go are select related.
Re:Memory usage of a toy C# server and client with 500K conc...
by benaadams on Saturday January 26, 2019 @09:02PM
(#19009955)
Yeah, at a guess you'd combine the multiple `WaitToReadAsync` with `await Task.WhenAny`; then use `TryRead` to run though the bunch of channels in a non-blocking way.
Could even use the return `await Task.WhenAny` to tell you the specific one to check. Shouldn't be a very hard construct to make; to make it more select like.
Re:Memory usage of a toy C# server and client with 500K conc...
by tapirl on Saturday January 26, 2019 @09:46PM
(#19010093)
good. It looks it is much like the reflect.Select (https://golang.org/pkg/reflect/#Select) in Go.
It has the benefit that any number of tasks can be selected, but the efficiency is not good as hard-coded select blocks.
But it looks C# Task.WhenAny has much less use case variants than Go select block.