Stream: helpdesk (published)

Topic: combine transducers.jl and native @threads


view this post on Zulip Filippos Christou (Oct 08 2023 at 18:24):

After using Transducers.jl operations in a script and then switching to @threads SOMETIMES I get an error.
Sorry for the vagueness, but it's all I have now and I still didn't manage to reproduce the error.
All I know is that sometimes this fails on the Threads.@threads

objs = tcollect([dosomething(x) for x in X ])
Threads.@threads for s in eachindex(objs)
  dosomethingelse(...)
end

The error looks as the following:

Initially I thought this was related to Makie but after googling "Could not load glyph" it appears other people also had problems with this when multiprocessing.

Has something similar ever been an issue to you?

view this post on Zulip jar (Oct 08 2023 at 18:27):

Makie does not support multithreading. Unpredictable behavior is expected.

view this post on Zulip Expanding Man (Oct 08 2023 at 20:36):

Plotting packages tend to use a lot of globals. Too many, in my opinion. Some of this is kind of understandable because they are usually aspiring to a very convenient user interface and they want to avoid burdening the user with handling objects they probably don't care about.

view this post on Zulip jar (Oct 08 2023 at 22:38):

Yeah, plotting packages and web frameworks take liberties with global variables and it's for the worse.

view this post on Zulip Brian Chen (Oct 08 2023 at 23:07):

At least web frameworks know they'll be run in a shared-almost-nothing, usually single-threaded environment

view this post on Zulip jar (Oct 08 2023 at 23:23):

Often that's true, though it's at least partly a consequence of being designed that way. And mutable global state isn't generally to my taste even in single-threaded environments.

view this post on Zulip Expanding Man (Oct 08 2023 at 23:32):

Web frameworks seem super goddamn weird to me. I had a number of complaints about Oxygen.jl and only later did I realize that the things I was complaining about were common web framework stuff (among them: inexplicably excessive use of globals).

view this post on Zulip jar (Oct 08 2023 at 23:35):

Thankfully there are a lot of web frameworks out there, including some that share my design sensibilities.

view this post on Zulip Brian Chen (Oct 09 2023 at 03:39):

Oh, I was thinking about frontend libraries. I agree that having global variable state in server/backend ones is far less optimal, given those often run with a _high_ degree of both concurrency and parallelism

view this post on Zulip Filippos Christou (Oct 09 2023 at 06:06):

that sounds reasonable. thanks. it's a pity though. Actually what's happening inside @threads is not generating the figures but saving them to the disk.

view this post on Zulip Mason Protter (Oct 09 2023 at 12:15):

pretty much anything you do involving Makie should be assumed to be thread-unsafe.


Last updated: Nov 06 2024 at 04:40 UTC