Replacing Networking (#271)

- [X] Removing Kestrel & Libuv
- [X] Cleaning up NetState
- [X] Removing System.IO.Pipelines
- [X] Cleaning up packet reading
- [X] Adds a maximum of 5000 sockets (configurable) to prevent OOM
- [X] Replaces the AsyncState with a thread-safe wrapped boolean called NetworkState
- [X] Removes Parallel.ForEach (no perf gain)
- [X] Removes custom houses compression on another thread
- [X] Test high load scenarios

Bumps release version
This commit is contained in:
Kamron Batman 2020-10-20 20:55:19 -07:00 committed by GitHub
parent 8603e31023
commit 369a27b800
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 1780 additions and 1569 deletions

View file

@ -193,9 +193,8 @@ namespace Server.Network
if (compress)
{
var buffer = ArrayPool<byte>.Shared.Rent(CompressorBufferSize);
NetworkCompression.Compress(m_CompiledBuffer, 0, length, buffer, out length);
var compressorBuffer = ArrayPool<byte>.Shared.Rent(CompressorBufferSize);
NetworkCompression.Compress(m_CompiledBuffer, 0, length, compressorBuffer, out var compressedLength);
if (length <= 0)
{
@ -214,28 +213,23 @@ namespace Server.Network
length
);
op.WriteLine(new StackTrace());
ArrayPool<byte>.Shared.Return(compressorBuffer);
}
else
{
m_CompiledLength = length;
if ((m_State & State.Static) != 0)
{
m_CompiledBuffer = new byte[length];
Buffer.BlockCopy(buffer, 0, m_CompiledBuffer, 0, length);
ArrayPool<byte>.Shared.Return(buffer);
}
else
{
m_CompiledBuffer = buffer;
m_State |= State.Buffered;
}
m_CompiledBuffer = compressorBuffer;
m_CompiledLength = compressedLength;
}
}
else if (length > 0)
else
{
m_CompiledLength = length;
}
if (length > 0)
{
var old = m_CompiledBuffer;
m_CompiledLength = length;
if ((m_State & State.Static) != 0)
{
@ -243,11 +237,17 @@ namespace Server.Network
}
else
{
// Release it later using Release()
m_CompiledBuffer = ArrayPool<byte>.Shared.Rent(length);
m_State |= State.Buffered;
}
Buffer.BlockCopy(old, 0, m_CompiledBuffer, 0, length);
if (compress)
{
ArrayPool<byte>.Shared.Return(old);
}
}
PacketWriter.ReleaseInstance(Stream);