clojure-dev

rschmukler 2023-04-19T17:54:32.347749Z

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) 2023-04-19T17:55:22.952839Z

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) 2023-04-19T17:56:24.094689Z

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

rschmukler 2023-04-19T17:57:34.332689Z

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) 2023-04-19T17:57:43.146429Z

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

Alex Miller (Clojure team) 2023-04-19T17:57:57.758429Z

not sure how or whether that's affected

Alex Miller (Clojure team) 2023-04-19T17:58:10.275889Z

don't know, needs real work

rschmukler 2023-04-19T18:01:01.255579Z

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) 2023-04-19T18:20:47.312279Z

information to inform decisions is useful :)

Alex Miller (Clojure team) 2023-04-19T18:21:10.438369Z

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

👍 1