Fix: too many milo parallel tasks hurting server #46

Merged
Lemmmy merged 1 commits from lemmmy/fix-milo-parallel into develop-1.8 2020-09-29 13:51:36 -04:00
Lemmmy commented 2020-09-29 12:58:52 -04:00 (Migrated from github.com)

We had a player on SwitchCraft recently with >500 chests in their Milo. Milo does a pretty good job of throttling things to avoid hurting the server in this case, however, it relies on a single peripheral.waitForAll call to wait for all the throttles to complete. This ended up spawning 480 coroutine threads for this particular user's Milo:

By reaching the thread limit, these parallel calls actually never finished, causing the user to try to boot-loop their Milo until it would work, causing more damage. We also got alerts about it every 5 minutes on the staff Discord :P

In this patch, I've chunked the tasks in Storage:listItems() to only run 16 at a time. This limit might need to be tuned, but in my testing it runs just as fast, and doesn't spawn infinite threads in the process.

We had a player on SwitchCraft recently with >500 chests in their Milo. Milo does a pretty good job of throttling things to avoid hurting the server in this case, however, it relies on a single `peripheral.waitForAll` call to wait for all the throttles to complete. This ended up spawning 480 coroutine threads for this particular user's Milo: ![](https://i.lemmmy.pw/Y0u3.png) By reaching the thread limit, these parallel calls actually **never finished**, causing the user to try to boot-loop their Milo until it would work, causing more damage. We also got alerts about it every 5 minutes on the staff Discord :P In this patch, I've chunked the tasks in `Storage:listItems()` to only run 16 at a time. This limit might need to be tuned, but in my testing it runs just as fast, and doesn't spawn infinite threads in the process.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MayaTheShy/opus-apps#46