CC: Tweaked

CC: Tweaked

59M Downloads

Computer freezes when more than 257 parallel peripheral functions

Kicory opened this issue ยท 5 comments

commented

Minecraft Version

1.20.x

Version

1.109.2

Details

Setting:
image

Lua script wrote:
image

Modloader: Neoforge 47.1.83
Other mods: None

If the parallel jobs are 257 or smaller, then everything is OK. The freezing bug only happens when it's 258 or larger. And this bug happens after some trial from computer boot; for first few (mostly less than 2) executions, this bug does not happen.

I tested other lua computation like lua table manipulation or lots of printings, but only functions that interacts with peripherals seemed to be cause problem.

For example, following script also cause the bug.
image

commented

Oh I forgot to mention; there are no log appears when freezing bug occurs.

commented

Since parallel works via events, my guess would be that you probably hit event queue limit

commented

Since parallel works via events, my guess would be that you probably hit event queue limit

Oh... Then can this problem be bypassed if I use coroutine API directly?

btw thank you for quick answer. this bug was real headache for me...

commented

I'm afraid this is an intentional design choice. We need a limit for the event queue to avoid entirely unbounded growth, and 256 is a relatively reasonable limit. Most code doesn't really benefit from this level of parallelism, as we rate-limit the work main-thread tasks can do anyway.

If you're trying to scan multiple inventories at once, my recommendation is to instead spin up a smaller number of workers (e.g. 64) and have a shared queue that each worker pulls from. I have some code for this in one of my projects, which you're free to use, though it may be over-complicated for your needs.

commented

Thank you, I will take a look.

Actually I already implemented small, easy workaround for my project. This issue is for others who looking for the reason of freezing in the future...

So maybe it would be better to show simple warning message by os, if event queue is full and might cause potential bug.

Thank you for addressing my headache.