CFC-Servers / gm_express

An unlimited, out-of-band, bi-directional networking library for Garry's Mod
https://gmod.express
GNU General Public License v3.0
69 stars 4 forks source link

Add "small message" net fallback #36

Closed brandonsturgeon closed 10 months ago

brandonsturgeon commented 1 year ago

After our latest performance tests, it became clear that Express performs poorly for small messages. But we already knew that, Express wasn't made to send small messages - no big surprise.

Well, based on our current per-key storage metrics, people are sending tons very small messages using Express. Unfortunately with messages this small, their experience will be exclusively worse than if they had just used a net message.

The performance tests highlighted another important thing: Express is only worse for messages that require 3 or fewer net messages.

This is interesting. If we look at both the usage metrics and the performance results, we find a cheap way to improve Express.

I don't necessarily want to make a pure-net data sender, but we could pretty easily cover the situation where a message could fit into a single net message.

That's what this PR does; it redirects small message payloads through the net library instead of the Express API, while still behaving the same way (calling receivers, respecting preDl receivers handling proofs, etc.).

I want to take this opportunity to refactor a few things and slim down the code, so the diff will be large but the functional changes will be few.

I also need to decide what to use as the id for these "small" messages in the callback chain. (some callbacks want the item ID). I don't want to introduce a regression, but I also don't want to write any worse code...

brandonsturgeon commented 10 months ago

This will be addressed in https://github.com/CFC-Servers/gm_express/pull/37