MariaTheDinkus / cc-tweaked-fabric

CC: Tweaked ported for Fabric 1.14.x
Other
18 stars 8 forks source link

Optimize WirelessNetwork #4

Open immibis opened 4 years ago

immibis commented 4 years ago

Seen here: https://github.com/Zundrel/cc-tweaked-fabric/blob/fabric/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java

the wireless network just loops through all modems to find ones that are able to receive the message.

It's good enough, but to support very large servers it would be good to optimize it. Suggestions:

SquidDev commented 4 years ago

Take what I'm about to say with however many pinches of salt you deem necessary, as I'm obviously a little biased. Just a couple of points:

Honestly, the big performance problem with wireless modems isn't the routing itself but the fact that every computer who receives a message needs to queue an event and execute some Lua code.


As an aside, the wired network code is terrible - we use dijkstra to route packets through the network, so it's O(n lg n)(ish), rather than the O(n) here. Though typically wired networks will be smaller than wireless ones.