Fork me on GitHub
#cider
<
2024-08-07
>
andrea.crotti15:08:36

I'm having some extremely weird problem in one project that I've never seen before. So in one file if I run the same test with cider-test-run-test multiple times, sometimes it takes up to a minute and most times it takes less than a second. Now this happens even with a stupid test and after disabling all the fixtures (which I thought were the problem)

`

(deftest check-speed
  (testing "hello"
    (is (= 1 0))))
When I enabled the fixtures and added some logging I would still see that it simply wasn't even getting there for the first 30 seconds, so I really don't get wtf is going here. I tried to profile Emacs itself as well in case somehow it's the thing locking, and this is a sample output from the profiler, but I don't think it's that either.
17,708,184  65% + redisplay_internal (C function)
      4,839,610  17% + command-execute
      3,212,640  11% + timer-event-handler
      1,369,590   5% + nrepl-client-filter
         39,961   0% + #<compiled -0x9c8d5a8487f65e>
          4,144   0% + jit-lock--antiblink-post-command
          1,848   0% + lsp--post-command
          1,544   0% + flycheck-display-error-at-point-soon
            240   0% + flycheck-error-list-highlight-errors
             72   0% + lsp-ui-sideline
              0   0%   ...

andrea.crotti15:08:00

it just looks like for whatever reason, in that scenario it just sometimes hangs for a while before doing anything

andrea.crotti15:08:09

never seen an issue like that before

andrea.crotti15:08:25

I guess one thing about this project that's maybe different from all the rest is that it's using schema.core for defining many functions, with (s/defn

andrea.crotti15:08:55

but I also tried to disable the (s/set-fn-validation! false) the validation with that and I think it's the same

Samuel Ludwig16:08:38

if you view top/`htop` do you see your CPU or RAM spike when you get these hangs? You would, I suppose, possibly expect to see a Java process skyrocket on one of those

andrea.crotti16:08:02

I can check, but the interesting thing is that I also tried to attach visualvm to the process

andrea.crotti16:08:07

but it just broke the repl

andrea.crotti16:08:32

so I could not get much out of it, maybe I can try with a different jvm version

andrea.crotti16:08:09

of course now that I opened btop it stopped happening entirely

Samuel Ludwig16:08:52

we love heisenbugs ❤️

andrea.crotti16:08:17

I don't think there are any cpu spikes

andrea.crotti16:08:33

and the other intersting thing is that every time according to cider the tests still only take 40ms

andrea.crotti16:08:44

so whatever is hanging doesn't end up in the total time

andrea.crotti16:08:57

other interesting thing is that it happened with both cider-test-run-test and kaocha

andrea.crotti16:08:09

but only when I run the single test, not all of them

Samuel Ludwig16:08:16

hmm, i assume if you run the tests from the cli you don't encounter any hitching then? (which would imply it is just a cider/emacs thing)

andrea.crotti16:08:06

yeah it looks fine when I run all the tests from the cli

oyakushev16:08:11

So you can reproduce it, but not reliably? That is, it happened more than once?

mikerod16:08:56

What did you use from visualvm? The cpu sampler?

vemv16:08:49

I'd run cider-nrepl from the CLI and hit Ctrl+\ (print thread dump) whenever it happens again, that will tell us what the JVM part of cider is doing at that point in time

👀 2
jpmonettas19:08:20

other options that don't need to start the process from the cli (for the Ctrl+\ ) is to run jstack PID or jcmd PID Thread.print they are all the same thing

til 1
❤️ 1
andrea.crotti19:08:20

Nice thanks yeah very weird, in the evening I could make it happen very often

andrea.crotti19:08:54

And it doesn't get stuck for long enough to be able to do other things, but I'll try again tomorrow

andrea.crotti19:08:37

I even wondered if it was related to the rest of the code in that particular file since commenting all the other tests out seemed to have helped, which seems crazy

andrea.crotti19:08:07

But another colleague noticed the same thing so I'm not the only one

andrea.crotti19:08:19

There is definitely something weird going on

vemv19:08:54

> other interesting thing is that it happened with both cider-test-run-test and kaocha I missed this. If it's happening on kaocha from the cli without cider-nrepl activated or in the classpath, that should guide to a different direction But if it's cider-nrepl, a GH issue is most welcome

andrea.crotti19:08:32

Well I run kaocha from emacs with the kaocha runner, which I think uses cider nrepl

andrea.crotti19:08:23

Running from the cli is tricky since it takes forever to start (and it's Leiningen so ever slower)

vemv19:08:16

> Well I run kaocha from emacs with the kaocha runner, which I think uses cider nrepl Yep. But at that point it's a bare nrepl eval request, most likely no cider-nrepl involved for practical cases > Running from the cli is tricky since it takes forever to start (and it's Leiningen so ever slower) Maybe run it in a timed manner 100 times while you sleep

andrea.crotti19:08:56

Hehe could try

andrea.crotti20:08:01

I was trying to run the test after jacking in from an external process actually but that doesn't work at all

andrea.crotti20:08:26

the repl works fine but cider-test-run-test doesn't, not sure if that's normal since I never really do it that way

vemv21:08:58

Sounds like the cider-nrepl middleware isn't there https://docs.cider.mx/cider/basics/middleware_setup.html

andrea.crotti07:08:23

ah yeah it's not in the dependencies