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:
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.
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.
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?