Fork me on GitHub
#clojure-dev
<
2023-04-19
>
rschmukler17:04:32

Can anyone confirm or deny a comment made by Ron on the loom-dev mailing list about Clojure considering moving away from synchronized methods for things like LazySeq (switching to java.util.concurrent primitives) make it more friendly for virtual threads? I haven't seen anything anywhere mentioning it. Thishttps://clojurians.slack.com/archives/C06E3HYPR/p1677254218136409 makes it sound like it might just be a wait for them to resolve it on the JVM side (which they said likely won't be this year). Link to https://mail.openjdk.org/pipermail/loom-dev/2023-April/005486.html. Right now there is an interaction where if you set the send-off! executor to a virtual thread executor you can deadlock the run-time by calling nested pmaps. I ended up running into this in real code in a project where we were using the virtual thread executor and cider-nrepl uses haystack (error analysis library) which uses lots of nested pmaps. Anyway, was just wondering where the mindset was on all of this. Cheers!

Alex Miller (Clojure team)17:04:22

it's on our list to investigate but we do not yet have a plan, not sure that will get done in 1.12

Alex Miller (Clojure team)17:04:24

it's probably beneficial to do regardless as most of the lock use is read on lazy seqs

rschmukler17:04:34

Awesome! I searched in the repo and saw a few other places synchronized is used as well - is the plan to potentially get rid of all uses of it?

Alex Miller (Clojure team)17:04:43

not sure on the others. atoms rely on compareAndSet not synchronized

Alex Miller (Clojure team)17:04:57

not sure how or whether that's affected

Alex Miller (Clojure team)17:04:10

don't know, needs real work

rschmukler18:04:01

Fair enough. Yes, I think Agent restart is also synchronized, as is some stuff in AReference and Var. Completely agree it's non-trivial. Not sure where the Clojure team is at w/ outside contributors but I might have time to take a peak. Also completely understand that this is something so under the hood and deep that you may not want the outside help - so completely understand either way 🙏

Alex Miller (Clojure team)18:04:47

information to inform decisions is useful :)

Alex Miller (Clojure team)18:04:10

feel free to make an Ask Clojure question and add stuff there

👍 1