Whenever I wake up my computer from a long (3h+) sleep, the cpu usage for all clojure java processes (either launched by lein or shadow-cljs) would skyrocket for a while, but they would cool down after half a minute. The longer the sleep, the longer it takes for the cpu usage to cool down.
So I use VisualVM to get some profiling data, and it seems it’s related to nrepl:
Does anyone has a clue?
Here are the versions:
OS: MacOS 10.15
cider: CIDER 1.0.0snapshot (package: 20200916.1152)
This happened since a long time and I have upgraded almost all these libs (even emacs), but the problem is always there.
I don’t see that behavior…I have a similar workflow (I just leave REPLs running for days sometimes, with sleeping in between). I’m on Windows 10 most of the time though. Very interesting.
Could it be that waking up from sleep causes some large amount of input to be sent to nRepl? It seems like what you’re seeing is basically input being sent to nRepl.
The trace in this case can be misleading. It is waiting on a blocking
.read, meaning it will just park and wait a long time if nothing is received. Although it looks like it consumes a lot of resources it likely doesn’t since the trace just shows “time spent”. It might totally be that emacs sends a bajillion nrepl messages when waking up but that seems unlikely.
good idea, I’ll exit emacs next time before going to sleep and see if that makes any difference.
But the activity monitor of macos shows these clojure jvm process using 100%+ or even 200%+ cpus, so it must be busy doing something.
I’m not saying that it doesn’t do anything. I just wanted to point out that the profile you posted might be misleading. I have spent much more time than I’d like to admit chasing down misleading profiles only to find the actual problem in completely different areas.
Disconnecting all nREPL connections before sleep should be a good way to test if its actually nREPL.
I only see very brief spikes on Windows10 but pretty much every process seems to be doing that so its probably something the OS does when waking up. No clue what the OS actually does though.
In my case the CPU spikes lasts for as long as 3-5 minutes, so definitely something wrong.
Unfortunately I don’t have a clue what could be causing this. When this happens in shadow-cljs do you see any suspicious output from shadow-cljs itself? Like builds triggering or running in a loop?
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.