This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-10
Channels
- # aleph (1)
- # beginners (4)
- # biff (7)
- # calva (7)
- # cider (8)
- # clara (17)
- # clerk (19)
- # clj-kondo (30)
- # clojure (12)
- # clojure-austin (1)
- # clojure-europe (12)
- # clojure-losangeles (1)
- # clojure-norway (21)
- # clojurescript (2)
- # datalevin (1)
- # datomic (24)
- # duct (3)
- # fulcro (8)
- # hyperfiddle (8)
- # lambdaisland (4)
- # membrane (6)
- # missionary (7)
- # off-topic (55)
- # overtone (2)
- # reagent (4)
- # reitit (4)
- # releases (6)
- # shadow-cljs (80)
So I have some code looks at a hashmap for a key and there can be a promise
, if there is, it is derefed
but otherwise one is created, inserted into hashmap and some calculation proceeds that deliver
s on that promise. This calculation can call this code again, of course, and that’s fine if the key is different, but if the key is the same I have a deadlock. Promise is created, inserted, then calculation starts and promise is fetched and derefed, which blocks the thread and promise is never delivered.
So the question here is: what’s the best, most performant way to stop this scenario? I don’t care how complicated it is, I need performance. My first idea is straightforward, it is to use ThreadLocal
and keep a set of promises created by this thread there and check it before derefing a promise.
But it’s pretty slow, so if someone has any tricks, any tricks at all, I’d love to hear them. If I have to write Java code and add java compilation, that’s no problem.
It feels that, while the direct issue is deadlocks, the root cause is a suboptimal approach to computation altogether. Have you seen the libraries that let you build a computation graph in advance and then execute it?
The actual computation is implemented by library user, I have to be ready for anything
That makes it sound even more vague. :) "How do I ensure that my program never hangs and performs the best it can, while being able to process absolutely anything?"
Could you use clojure.core.async - the map would hold promise-channels - and computations would read them in a way that would park, not block: <!
, not <!!
? (But, do have a look at Plumatic Plumbing for an elegant example of what you could do if you required the tasks to be declared in such a way that you could detect which depended on which others.)
A request to the OP - please don't delete questions that others have taken the time to answer.
Sorry, I’ve deleted it specifically because I didn’t want more people to waste their time reading and potentially answering it. Realized it was a mistake to ask this in the first place.
@U66G3SGP5 A note in the response thread saying that would be better than deleting it (and losing the context of the responses).
Sorry, I’ve deleted it specifically because I didn’t want more people to waste their time reading and potentially answering it. Realized it was a mistake to ask this in the first place.> I never consider it a waste to read or answer questions here. I think it's great that people ask questions, and interesting to read questions and answers. That's a great way to learn for me :) I believe it's people's own responsibility to judge whether they should answer a question when reading the question. (and personally, I'm very curious about what the original question actually was ...)
Maybe I'm doing a rookie mistake here, but I'm on macOS 14 with an OpenJDK 21 and when I go through the eelchat tutorial and try to sign up, the signup link isn't printed on my console:
TO: [{:email [email protected]}]
SUBJECT: Sign up for My Application
nil
There's #C013Y4VG20J and if I were in your shoes I'd just try debugging it to see where the problem is. Maybe it ends up being worthy of a proper issue report.
Oh sorry, I think I misclicked in the channel list and posted here by accident