perf(net): borrow inbound packet storage

Decode headers, optional fields, fragments, and single-fragment messages directly over pooled datagrams. Copy only fragment state that crosses a datagram lifetime, preserve synchronous dispatch and ACK ordering, and lock the path to the owned decoder with differential and zero-allocation tests.
This commit is contained in:
Erik 2026-07-25 05:58:55 +02:00
parent 7211bb1bf7
commit e928c5dd02
18 changed files with 1329 additions and 66 deletions

View file

@ -30,9 +30,9 @@ public static class PlayerKilled
uint VictimGuid,
uint KillerGuid);
public static Parsed? TryParse(byte[] body)
public static Parsed? TryParse(ReadOnlySpan<byte> body)
{
if (body is null || body.Length < 4) return null;
if (body.Length < 4) return null;
uint opcode = BinaryPrimitives.ReadUInt32LittleEndian(body);
if (opcode != Opcode) return null;
@ -41,9 +41,9 @@ public static class PlayerKilled
int pos = 4;
string deathMessage = StringReader.ReadString16L(body, ref pos);
if (body.Length - pos < 8) return null;
uint victimGuid = BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(pos));
uint victimGuid = BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(pos));
pos += 4;
uint killerGuid = BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(pos));
uint killerGuid = BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(pos));
return new Parsed(deathMessage, victimGuid, killerGuid);
}
catch { return null; }