Stream: helpdesk (published)

Topic: Polyester.jl composability


view this post on Zulip James Wrigley (Jun 01 2023 at 09:40):

Does Polyester.jl compose with tasks launched with Threads.@threads etc? i.e., will launching a bunch of tasks with both simultaneously cause oversubscription? I see in the README there's a section about using disable_polyester_threads(), but I don't know if that's because it doesn't compose well with Base.Threads, or if it's just to avoid the overhead of launching too many tasks.

view this post on Zulip Mason Protter (Jun 01 2023 at 15:07):

No, it does not compose well

view this post on Zulip James Wrigley (Jun 01 2023 at 19:34):

Ah, that's unfortunate. Do you know why? I browsed the repo and docs but couldn't really grok how it works, it's pretty under-documented.

view this post on Zulip Mason Protter (Jun 01 2023 at 20:58):

It's basically an orthogonal threading system that makes different tradeoffs in order to get lower overhead. From what I understand, it would lose those benefits if it tried to compose well

view this post on Zulip Mason Protter (Jun 01 2023 at 20:58):

Maybe @chriselrod can expand or correct what I've said though

view this post on Zulip Brenhin Keller (Jun 01 2023 at 21:03):

Any other things one shouldn't use Polyester for in preference to base Threads? The only thing that comes to mind for me is that I once had a problem when trying to @batch something that including making and saving some Plots.jl plots but wasn't sure if it was because of Plots.jl doing weird non-thread-safe things or something else

view this post on Zulip Mason Protter (Jun 01 2023 at 21:07):

I don't know of any cases where Polyester isn't prefereable to Threads.@threads, but Polyester also has no replacement for things like Threads.@spawn as far as I'm aware.

view this post on Zulip James Wrigley (Jun 01 2023 at 21:45):

I see, thanks.

view this post on Zulip chriselrod (Jun 02 2023 at 12:19):

Polyester won't oversubscribe your CPU, because it runs on regular Julia tasks that get scheduled by the regular scheduler.
Instead of having a short lifetime, these tasks live until you exit Julia. Polyester works by telling them what to do.
It is faster because it avoids spawning new tasks and getting the scheduler to schedule them. It is much more direct in this way.

ThreadingUtilities is the library that provides both the task pool, and the ability to send them code to run.

PolyesterWeave is the extremely naive scheduling library that Polyester, LoopVectorization, and Octavian use.
One could experiment with writing other scheduling libraries/taking other approaches. That'd be interesting, but unfortunately not something I have time for. An alternative to PolyesterWeave that supports @spawn/implements work-stealing while still quickly allowing one to launch large threaded jobs would be great.

view this post on Zulip chriselrod (Jun 02 2023 at 12:20):

I think code should generally work when you run Polyester and base threading together, but it will likely regress performance.

view this post on Zulip James Wrigley (Jun 04 2023 at 11:55):

Ah thanks, that clears up a lot :thumbs_up:


Last updated: Dec 28 2024 at 04:38 UTC