Commit Graph

3 Commits

Author SHA1 Message Date
Lorenz Junglas
4610689db8 Pool byte arrays when decoding network packets (#4456)
Avoids System.Byte[] allocations
2026-04-02 13:34:03 +02:00
Lorenz Junglas
519ad5d815 Network: Broadcast and Chunking compression optimization (#4417)
**Broadcast**
now encodes the wire payload just once and sends the same bytes to
every recipient, before we did one redundant compression per connection.
This primarily reduces CPU load on the server/host.

**Chunking**
Large messages are now compressed before chunking rather than after.
Resulting in slightly smaller payloads.
The receiver now decompresses a single reassembled payload instead of
decompressing every chunk independently, significantly reducing CPU load
on receiving clients.

**Refactor**
Chunking and compression are now low-level wire concerns handled by
Connection rather than being mixed into the high-level message types.
The old `InternalMessageType.Chunk` enum is removed; chunk framing uses
a dedicated wire flag byte alongside `FlagRaw` and `FlagCompressed`.

**Results (Chunking changes)**

Synthetic data, results on real payloads may differ.

Benchmarks (1000 GOs / 2000 components, ~1MB payload, 500 iterations):

Wire size (chunk-first-then-compress):    275KB
Wire size (compress-first):               259KB  (5.7% smaller)

Send  chunk-first:                        0.85 ms/op  (old)
Send  compress-first:                     0.88 ms/op  (new)

Recv  chunk-first:                        1.16 ms/op  (old)
Recv  compress-first:                     0.34 ms/op  (new, 3.4x faster)
2026-03-31 11:56:17 +01:00
s&box team
71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00