Network Thread & Message Queue?

Started by
15 comments, last by Bluntest 3 years, 10 months ago

Hard to know if that's a reasonable amount of time. I would run a test that approximates the data being batched outside of enet (raise your data size, reduce your send calls), and see where that gets you. If it's significantly faster, you're probably feeling the memory allocations. (enet's send does a malloc)

Advertisement

16 milliseconds sounds better than 100, and even sounds pretty good if you're sending 400x400 == 160,000 packets.

If you're still sending 400 12-byte packets to each of 400 users, you should make sure that you merge the payloads into 400 packets of 480 bytes each instead. I'm still un-clear on whether that is what you're doing or not. Maybe take a look at it using Wireshark?

enum Bool { True, False, FileNotFound };

The code in OP looks very inefficient, because you seem to send the same data to all clients, but copy the data N times and only then the network library merges the same data N times, leading to O(N^2).

If you just collected the whole data once in an array, then broadcast the result once, most of the work would be O(N).

… which would show up on the profile if that was the bottleneck.

enum Bool { True, False, FileNotFound };

They're probably not actually sending the same data to every client (mentioned an AOI system earlier in the thread).

Archduke said:

They're probably not actually sending the same data to every client (mentioned an AOI system earlier in the thread).

For the purpose of stress testing how much throughput I can get I was sending to everyone. I only mentioned AOI because I know this is not how the server should actually function and that I'm aware and already have a system.

wintertime said:

The code in OP looks very inefficient, because you seem to send the same data to all clients, but copy the data N times and only then the network library merges the same data N times, leading to O(N^2).

If you just collected the whole data once in an array, then broadcast the result once, most of the work would be O(N).

I'm at the mercy of enet with this one but you're absolutely right. I should look into my own solution for grouping packets together before passing it to enet.

hplus0603 said:

16 milliseconds sounds better than 100, and even sounds pretty good if you're sending 400x400 == 160,000 packets.

If you're still sending 400 12-byte packets to each of 400 users, you should make sure that you merge the payloads into 400 packets of 480 bytes each instead. I'm still un-clear on whether that is what you're doing or not. Maybe take a look at it using Wireshark?

ENet is already merging the packets and I've confirmed by counting the amount of send calls.

Either way I'm satisfied at the moment. I moved forward with my project and implemented my AOI system. I can handle a sufficient amount of players with my current setup but I will definitely come back to optimize this.

I appreciate all the reply guys.

EDIT: I created my own data aggregation system before sending it to ENet and I can now handle upwards of 3,000 constantly moving clients inside my AOI and the server isn't breaking a sweat. I think ENet's aggregation just isn't that great for sending tons of small packets. Thank you all.

This topic is closed to new replies.

Advertisement