Refined Storage

Refined Storage

77M Downloads

A lot of lag when a lot of items change at once

pkmnfrk opened this issue ยท 10 comments

commented

Issue description:

When a lot of items change at once, it causes a lot of lag on the client side

What happens:

In the context of my mod (external EMC-based storage, see #1979), whenever EMC changes, the items that I expose all recalculate how many items you could craft. This means that potentially hundreds of items can change quantity at the same time.

If you have a terminal open when this happens (and, since extracting an item through a terminal will affect your EMC as above, this is fairly common), then you get anywhere from 1 - 30 seconds of lag on the client side.

It appears as though each item change generates a packet, so the server effectively DOSes the client when this happens.

https://github.com/raoulvdberge/refinedstorage/blob/94c93d1e115bbcb710a26db2cdfe6c7947007a14/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/storage/StorageCacheListenerGridItem.java#L34-L36

What you expected to happen:

No lag, maybe one big packet that contains all the changes.

Steps to reproduce:

  1. Set up as in #1979
  2. Add a Tome of Knowledge to your Transmutation Table
  3. Extract a large-valued item via a terminal

Version (make sure you are on the latest version before reporting):

  • Minecraft: 1.12.2
  • Forge: 2732
  • Refined Storage: 1.6.4-279

Does this issue occur on a server? yes

commented

I might take a stab at fixing this, since I have a pretty good test set up already...

commented

The packet is already combined. This is the reason why project e support was removed.

commented

(you are also looking in the wrong place of the code)

commented

I beg to differ. The packet is only combined in certain circumstances. See my pull request (which I was just a few seconds late on creating). The changes I added completely fix the lag problem

commented

Just to clarify:

The packet is already combined

This is not true in External Storage (which is the context this is in). I can provide more proof that this is the case if required, but it was absolutely 100% triggering a flood of packets before my patch, and absolutely 100% not afterwards.

commented

Can you link proof in an external storage context? Storage caches have a "batched" argument and a flush method.

commented

Yep, they do, which I used in the code I linked to in the other bug. Give me a few minutes, and I'll get some data for you.

commented

So, I added logging to a few places within Refined Storage, and tested both without my patch and with, and collected the logs here:

https://gist.github.com/pkmnfrk/27b8c0c46acb282597b1af4bf34fd474

My test setup isn't complicated, but here it is just in case: https://imgur.com/a/euQOACR

commented

I will take a look at your PR tomorrow. ;)

commented

Thanks, our mutual users will appreciate it ๐Ÿ‘