Bug in sleep() function - main thread work affecting sleep duration on running tasks

I think this explains what is going on:

I had a Genie-related issue for weeks now - and I wasn’t able to track it down until yesterday when I tried to help solving this issue. I assumed that the complexity of my project and the difficulty to write proper tests to catch the responsivity issue was on me - and I was in the process of refactoring stuff.

~10 hours later - trying to invalidate my conclusions (I initially assumed that it is just about communication between tasks - so I did invalidate some) I arrived at an even more upsetting conclusion: you cannot do proper (or predictible/interactive) multithreading in Julia if your project involves medium-heavy work on main and your tasks are somehow using libuv. Just run my HTTP.jl MWE from an above post.

So - there is hard to say how many Julia packages are poisoned in this way:

  1. It is not straightforward what tests should be run to determine if there is an issue.
  2. If you want to go into source code for anything you use, it is pretty time-consuming (the language users should not need to do such things).
  3. Many toy examples from documentation will not reveal the issue.

For me, it is just incredible that this is happening. Imagine not being able to properly run a server on a different thread because its responsivity will be conditioned on not doing anything significant on the main thread.

2 Likes