Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
https://conjure.oli.me.uk
The Unlicense
1.77k stars 109 forks source link

Conjure 4.40.x and Neovim 0.9.0 have 100% CPU by clojure-lsp when opening JAR using zipfile:/// scheme #494

Open oryband opened 1 year ago

oryband commented 1 year ago

Similar Neovim setup as https://github.com/Olical/conjure/issues/481 , except I updated to Neovim 0.9.0 ; Opening the following file hangs the process entirely due to 100% CPU. Downgrading to Conjure 4.39.x or Neovim 0.8.3 resolves the issue. This also occurs if I install Neovim without snap, using apt install with the latest version (0.10.0-dev)

# this is a dependency library for one of my projects, managed via `lein deps`
$ nvim zipfile:///home/ory/.m2/repository/com/stuartsierra/component/1.0.0/component-1.0.0.jar::com/stuartsierra/component.cljc

Calling htop shows this

    PID  CPU%▽MEM%  DISK READ   DISK WRITE Command
 148218 291.3 16.9   58.99 M/s    0.00 B/s /snap/nvim/2801/usr/bin/nvim --embed
 148398 103.0  4.6    0.00 B/s    0.00 B/s /home/ory/.local/share/nvim/mason/bin/clojure-lsp
 148555 103.0  4.6    0.00 B/s    0.00 B/s pool-3-thread-1

Debug screenshot when hangs. I'm reached this zipfile via going to definition of component library:

; Assumed session: Sloughi (Clojure)
; debug: receive
{:id "51a2e239-03c0-450b-a688-2a71ebdc3ebe"
 :ns "user"
 :session "c4ec88da-16c5-4c5c-ae64-826602d463d1"
 :value "nil"}
; debug: receive
{:id "51a2e239-03c0-450b-a688-2a71ebdc3ebe"
 :session "c4ec88da-16c5-4c5c-ae64-826602d463d1"
 :status ["done"]}
; debug: send
{:code "(require 'component.core)"
 :id "485d9f3b-e0ea-4b29-9669-2a81c22402cb"
 :nrepl.middleware.print/options {:associative 1 :length 500 :level 50}
 :nrepl.middleware.print/print "conjure.internal/pprint"
 :op "eval"
 :session "e6a1b3af-bf5f-4b6e-9a93-f6baa713ce49"}
; debug: receive
{:id "485d9f3b-e0ea-4b29-9669-2a81c22402cb"
 :ns "some.ns.from.my.project"
 :session "e6a1b3af-bf5f-4b6e-9a93-f6baa713ce49"
 :value "nil"}
; debug: receive
{:id "485d9f3b-e0ea-4b29-9669-2a81c22402cb"
 :session "e6a1b3af-bf5f-4b6e-9a93-f6baa713ce49"
 :status ["done"]}
oryband commented 1 year ago

Update: I'm not entirely sure this is related to Conjure. See related Slack discussion in Clojurians here: https://clojurians.slack.com/archives/CPABC1H61/p1684239469765269

Olical commented 1 year ago

😞 not good, I can open it just fine on the latest Conjure development commit and:

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

It could be LSP related, although that'd surprise me too tbh. The things that changed over some of these Conjure / Neovim transition periods were breaking changes in Neovim's APIs that Conjure had to handle and branch on, so that's the most likely candidate.

So they changed some names of methods in the LSP API and I think a few things around how mappings and autocmds worked from the Lua side. So Conjure upgraded with those changes, moving off of the deprecated APIs and naming. Some parts had a switch where if you had an older Neovim it'd support the old approach for a while, so it gracefully degraded or at least supported older and newer Neovim versions.

One thing I've run into in the past was that my Tree Sitter grammars were out of date, so when I updated Neovim it crashed or hung until I performed the :TSUpdate command. Just trying to brain dump everything I think could be relevant to this right now since nothing stands out as a prime suspect so far.

Olical commented 1 year ago

Did you ever get to the bottom of this? Or even get any more clues?

oryband commented 1 year ago

@Olical sorry for delay, I switch between Python and Clojure every few weeks which affects my responsiveness on these issues. Updating Treesitter parsers and queries has no effect on resolving. I'm running the same version as you. No idea what's causing this. Maybe if we could find a way to catch which neovim / lua calls are hanging it would help - but this has to be viewable outside of the neovim process since it hangs.

Olical commented 1 year ago

Not a problem, no need to apologise! Thanks for trying those bits and ruling more out, I'll try to reproduce it myself and see if I can narrow it down. I still don't see how it'd be Conjure doing this, but your evidence of it going away at particular versions is quite convincing.

oryband commented 1 year ago

Suggestion: Try installing Ubuntu on a VM and reproduce

oryband commented 1 year ago

Update: