NebulaModTeam / nebula

A multiplayer mod for the game Dyson Sphere Program
GNU General Public License v3.0
835 stars 124 forks source link

Refactor networking logic & Deprecate `PlayerManager` #634

Closed Reousa closed 8 months ago

Reousa commented 9 months ago

This is in preparation for implementing hot-swappable messaging libraries.

Things done:


This PR is included in a series:

  1. 634 - Working

  2. 638 - Working

    3. #639 - Working

Reousa commented 8 months ago

@Therzok; Extensions served as a temporary placeholder until I removed PlayerManager and conclusions were made over some discord discussions. Admittedly I hadn't considered performance impact yet, given the WIP nature of things, that would've been a later step. 😅

Adjustments made in any case, will rebase #638 after PR acceptance.

By extension & to keep reference, this PR also eliminates dependency on the Locker object, avoiding potential GC triggers in hotpaths from frequent PlayerManager member access.


I sadly have no easy way to measure or compare these impacts as of yet, but a mocking of Server and Client to simulate some measurable traffic is something I'm attempting.

With that said, should pooling packets & potentially packet buffers be brought into the scope of this refactor (in a later PR)? I recon that'd have far more impact on easing out the GCs? What do you think?

Therzok commented 8 months ago

Thanks for removing the allocs!

Pooling sounds good, an alternative would be restructuring the generic packet handling to be use where T:struct, IPacket and the JIT will do everything else, but that's probably a bigger refactoring compared pooling.