Obsidian icon indicating copy to clipboard operation
Obsidian copied to clipboard

Improve networking performance

Open Seb-stian opened this issue 4 years ago • 4 comments

Networking can be made a lot faster and more clients can be handled. The idea is to use SocketAsyncEventArgs, pure TCP Socket and a custom lightweight buffered stream.

Resources: https://github.com/chronoxor/NetCoreServer/blob/master/source/NetCoreServer/TcpServer.cs https://www.codeproject.com/articles/83102/c-socketasynceventargs-high-performance-socket-cod https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socketasynceventargs?view=net-5.0#examples https://github.com/ObsidianMC/Obsidian/blob/experimental/Obsidian/Net/NetWriteStream.cs

Assigning myself for now

Seb-stian avatar Apr 22 '21 15:04 Seb-stian

Note to self: keep an eye on https://github.com/dotnet/runtime/issues/49941 (.NET 7?)

Seb-stian avatar Jun 11 '21 12:06 Seb-stian

I highly recommend checking out Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets as it already offers performant socket connections and listeners. It is used in ASP.NET Core so it must be 🚀

TheVeryStarlk avatar Aug 05 '23 21:08 TheVeryStarlk

I don't think there is much difference between TcpListener and Sockets. TcpListener uses Sockets underneath it. https://www.codeproject.com/Articles/5270779/High-Performance-TCP-Client-Server-using-TCPListen After all the only thing we need is to accept series of bytes comming over network, the only thing we might be limited by is the serialization and deserialization of packets. Unless something in the source code was implemented incorrectly.

ktalap avatar Aug 08 '23 08:08 ktalap

I still think just using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets is a better option, instead of going into the hassle of the needy greedy details of performant socket implementations.

TheVeryStarlk avatar Aug 08 '23 20:08 TheVeryStarlk