Lothrazar / Storage-Network

Other
43 stars 48 forks source link

Improved performance for export nodes #492

Closed IIpragmaII closed 1 year ago

IIpragmaII commented 1 year ago

We noticed that the network is not scaling well. When you are connecting a lot of chests and have many export nodes with a bunch of filters in them the server starts to lag. That happens because we are searching every chest for every defined filter item in every export node.

The fix is to go through all the connected chests an grouping the items in them. Then we are also grouping all the requested items in the export nodes by their requested item. With these two groups we are able to search for the needed items without iterating every chest over and over again.

What we also did is grouping the requested items by their priority. That means, that lowering the priority on an export node makes it receive items before the other export nodes with a higher priority.

JayPeaSize commented 1 year ago

Another part of the issue is when isStackFiltered() is called that it makes a copy and collects each time due to streams. Simply switching the streams to a normal for loop would provide better performance as well.

Lothrazar commented 1 year ago

thanks for your patience this looks amazing