Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspicion: when Calva's REPL window has a lot of text, it is slowing down clojure-lsp #1250

Closed
PEZ opened this issue Aug 5, 2021 · 9 comments

Comments

@PEZ
Copy link
Collaborator

PEZ commented Aug 5, 2021

As VS Code is sending all Clojure files to clojure-lsp, and the REPL/output window is a Clojure file, it is analysed and could potentially be causing performance problems affecting the whole project.

@PEZ
Copy link
Collaborator Author

PEZ commented Aug 5, 2021

Speaking with @ericdallo about this it seems we can't cut off clojure-lsp analysis of this file without also loosing the clojure-lsp services in the file. So a worst case solution (given that this really is a problem) is to make clojure-lsp ignore the file and drop the clojure-lsp support there.

@bpringe
Copy link
Member

bpringe commented Aug 5, 2021

To stop clojure-lsp from analyzing the repl file, these are some possible options off the top of my head, without looking further into it right now:

  1. We may be able to modify the initialize request
  2. We probably can use middleware to not send the file in certain individual protocol requests

@ericdallo
Copy link
Contributor

One thing I can think to fix the issue is that for the REPL buffer, we just care about the code that was not sent to repl yet, right? the code user is writing right now, not the one that was already evaluated, if we could make calva send only that code, it'd certainly fix the issue.

image

@ericdallo
Copy link
Contributor

I temporary fix for users right now is cleaning the repl as well...

@brdloush
Copy link
Contributor

brdloush commented Aug 5, 2021

a simple way to reproduce:

  1. open a lein new whatever project in calva
  2. cider jack in
  3. evaluate and wait until this finishes
(->> (range 100000)
     (run! #(println "line " %)))
  1. watch clojure-lsp eat 100-300 %CPU for many minutes

EDIT: adding step 5

  1. evaluate any expression in REPL window. (+ 1 1) should be enough. You may also want to make sure that code completion got triggered.

@ericdallo
Copy link
Contributor

ericdallo commented Aug 5, 2021

watch clojure-lsp eat 100-300 %CPU for many minutes

Odd, I could not repro that slowness or high CPU 🤔

Even so, a huge clojure buffer will certainly affect the performance (only for that buffer, other buffers should work normally as expected).

My suggestion would still work for this case

@ericdallo
Copy link
Contributor

ericdallo commented Aug 5, 2021

Odd, I could not repro that slowness or high CPU 🤔

I can repro the issue if I try to edit the repl and complete something

I even got a OOM exception, and we can see rewrite-clj is having issues as it needs to parse a huge text:

2021-08-05T15:47:30.033Z gregnix-nubank ERROR [clojure-lsp.server:?] - 
                              clojure.core/seq     core.clj:  139
                                           ...                   
                    clojure.core/repeatedly/fn     core.clj: 5138
               rewrite-clj.parser/parse-all/fn  parser.cljc:   25
                      rewrite-clj.parser/parse  parser.cljc:   20
            rewrite-clj.parser.core/parse-next    core.cljc:   46
             rewrite-clj.reader/read-with-meta  reader.cljc:  147
                                           ...                   
                    rewrite-clj.parser.core/fn    core.cljc:   74
          rewrite-clj.parser.token/parse-token   token.cljc:   45
                rewrite-clj.reader/string->edn  reader.cljc:  109
          clojure.tools.reader.edn/read-string      edn.clj:  437
          clojure.tools.reader.edn/read-string      edn.clj:  440
                 clojure.tools.reader.edn/read      edn.clj:  392
                 clojure.tools.reader.edn/read      edn.clj:  407
          clojure.tools.reader.edn/read-symbol      edn.clj:  260
clojure.tools.reader.impl.commons/parse-symbol  commons.clj:  117
                                           ...                   
java.lang.OutOfMemoryError: Java heap space

@brdloush
Copy link
Contributor

brdloush commented Aug 5, 2021

Oh, you're correct, I also evaluated some expression in the REPL window, just after all that output got appended to the REPL window.

So I'm adding step 5:

5. evaluate any expression in REPL window. `(+ 1 1)` should be enough. You may also want to make sure that code completion got triggered.

ericdallo added a commit to ericdallo/calva that referenced this issue Jan 18, 2022
ericdallo added a commit to ericdallo/calva that referenced this issue Jan 18, 2022
@ericdallo
Copy link
Contributor

This should fix the issue: #1479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants