Fork me on GitHub
#lsp
<
2022-09-19
>
ribelo20:09:17

am i the only one whose new version hangs and is unresponsive?

ribelo20:09:16

return to 2022.07.24-18.25.43 solves the problem

borkdude20:09:46

I've had this too and reverting to pre-lsp4clj solved the problem for me. https://github.com/clojure-lsp/clojure-lsp/issues/1240

borkdude20:09:15

Perhaps you could add to the issue if you see a different problem that you can easily reproduce

borkdude20:09:41

I think @U07M2C8TT is already on it, if I'm not mistaking

ribelo20:09:55

thanks, looks like my problem

borkdude20:09:21

are you using emacs as well?

borkdude21:09:28

Might be worth mentioning in the issue then since we also suspected it would be something with emacs lsp-mode

jacob.maine21:09:36

Thanks for the report @U0BBFDED7. As @U04V15CAJ said I think I have a handle on what the problem is and have made some progress on fixing it. I hope to have a build together by next week (I'm traveling atm). If you'd be able to test that, whenever it's ready, it'd be much appreciated.

ribelo21:09:43

no problem

ribelo21:09:09

I'm watching the repo, so as soon as the release comes out I'll test it out

gratitude 1
Drew Verlee02:09:39

Is lsp development easier in vscode somehow or does it not matter that much?

jacob.maine02:09:31

Do you mean working on clojure-lsp? Or using it while working on other projects? I'd say working on clojure-lsp itself is equally easy in any editor. I use Emacs, but that's personal preference. Using it is similar. Although the editors each offer slightly different ways of interacting with clojure-lsp, it's mostly the same, and primarily comes down to personal preference.

jacob.maine02:09:27

Or was your question about the development of the client (editor) side? I don't have any experience with that

Drew Verlee02:09:20

I mean working "on" it, in this case the vscode, emacs, etc.. clojure lsp clients.

Drew Verlee02:09:54

I suppose I'm asking the maintainers specifically which editor Sparks more joy.

jacob.maine02:09:54

I'm a little confused about what you mean by “emacs clojure lsp client”. That's kind of a contradiction in terms. There's an “emacs lsp client” as well as one or more for each of the other editors. But they're language agnostic—not Clojure specific. Then there's a “clojure lsp server”, which is language-specific, but editor agnostic. The maintainers of the clients usually develop their side using the same editor, because they like that editor. And the maintainers of the server use whatever editor they prefer. That's part of the beauty—everyone gets to use what they like

Drew Verlee02:09:33

Yep, you seemed to have gleamed my unclear meaning. Sure, i guess the easier question is, what editor do they prefer. It's easier to maintain and grow something you need and benefit from. I believe Eric uses doom, i'm not sure what borkdude uses in his day to day clojure development...

jacob.maine03:09:11

I think they both use some flavor of Emacs. snoe uses nvim.

👍 1
Drew Verlee03:09:02

thanks jacob. I'm slowly (years) becoming more invested in emacs to, so thats good to hear. Though it comes with some tradeoffs obviously 🙂

👍 1
snoe06:09:37

For lsp development specifically, I'll actually say more diverse editor usage would be good.

borkdude06:09:15

I use emacs for day to day development, but when I develop lsp servers, I usually use VSCode too since it's pretty easy to test there

👍 1
jacob.maine15:09:34

I’ve submitted a https://github.com/clojure-lsp/clojure-lsp/issues/1240 for the lsp4clj side of this and made a draft https://github.com/clojure-lsp/clojure-lsp/pull/1259 for the clojure-lsp side. To test a build, you’ll need the lsp4clj branch checked out in the same directory as clojure-lsp. If that sounds too complicated, please wait until the clojure-lsp branch is out of draft. /cc @UKFSJSM38

👀 1
jacob.maine23:09:15

@U0BBFDED7 if you have a chance, will you report on whether https://clojurians.slack.com/archives/C032YH7P0R2/p1664133908073819 build (or a more recent one) improves performance for you?

ericdallo11:09:26

Hi @U0BBFDED7, did you run into any performance issues with nightly above ☝️ ?

borkdude12:09:28

FWIW I still have the same issue and will keep using the 2022.06 release for now

ribelo22:09:22

I checked one of the longer files and can't find any performance issues

ericdallo22:09:54

Cool! Thanks for testing, so it does fix your perf. Issues, one more reason to think it's something specific with the borkdude's case @U07M2C8TT

ribelo22:09:13

previously in neovim lsp/diagnosis appeared literally letter by letter, so it would be quite hard to miss now if it was the same

👌 1
ribelo22:09:02

no problem, thanks for the instant solution, with clojure-lsp dev expirience is much higher

gratitude 2
borkdude05:09:50

Glad to hear your problem is solved

🙃 1
jacob.maine17:09:41

@U0BBFDED7 glad that worked for you. @U04V15CAJ, I apologize we haven’t got performance back on par for you. Were you able to follow up on any of my questions about Emacs garbage collection? I’m still very curious about this because it’s the only way I’ve been able to truly reproduce what you’re seeing. I know the problem is with clojure-lsp, not Emacs, but it’s possible that the Emacs settings affect garbage creation differently in the two versions of clojure-lsp. In particular I’m curious what describe-variable says about lsp-log-io, lsp-clojure-server-command, lsp-idle-delay, gc-cons-percentage, gc-cons-threshold, and read-process-output-max. Anecdotally, do the freezes correlate with times that Emacs is doing GC? I checked this by watching top but there may be a better way. The Emacs profiler https://emacs-lsp.github.io/lsp-mode/page/performance/#reporting-performance-problems memory usage. And in theory setting garbage-collection-messages should show you when GC is done, though I can’t actually find those messages. If you truncate your clojure-lsp log file, does that help? I want to follow up on these threads, but I also don’t want to get stuck on GC as the problem. I asked @UKFSJSM38 if he could duplicate the lag when Emacs was handling giant log files, but he couldn’t.

borkdude18:09:26

@U07M2C8TT Appreciate all your efforts. In the last conversation we had you asked for my emacs GC settings and I posted that

borkdude18:09:07

I'll try your other suggestions here when I'm back home

jacob.maine19:09:49

Ok cool, thanks 👍

borkdude15:09:23

Didn't get to it yesterday, will look into it today

jacob.maine15:09:47

No problem. Sorry to keep making you switch builds. Thanks for the help debugging

borkdude16:09:15

Now running the nightly from yesterday, let's see

borkdude16:09:47

lsp-log-io is a variable defined in 'lsp-mode.el'.

Its value is nil

borkdude16:09:07

lsp-clojure-server-command is also nil

borkdude16:09:23

lsp-idle-delay is 0.5

borkdude16:09:49

gc-cons-percentage 0.1

borkdude16:09:18

gc-cons-threshold `Its value is 104857600 Original value was 800000`

borkdude16:09:38

read-output-process-max Its value is 1048576

jacob.maine16:09:43

Darn… that all looks like normal config. Do you happen to have any *lsp-log* files? You should have one, but if there are more that’d be surprising

jacob.maine16:09:00

Err… buffers, not files

borkdude16:09:23

yes, it's about 700 lines

borkdude16:09:34

there is one

jacob.maine16:09:41

OK, that’s normal

borkdude16:09:02

There are also these:

ericdallo16:09:09

everything looks correct

jacob.maine16:09:23

You might still try truncating your server log. I doubt it’ll affect anything, but good to eliminate that variable. The next thing to look at is whether the freezes correlate with Emacs GC

borkdude16:09:51

I immediately notice the lags after switching, it's very clear to me

borkdude16:09:16

$ rm /tmp/clojure-lsp.out

👍 1
borkdude16:09:04

doesn't seem to help

jacob.maine16:09:16

Not too surprising

jacob.maine16:09:34

Can you tell whether Emacs is doing GC whenever a freeze happens @U04V15CAJ ?

borkdude16:09:19

how can I tell?

jacob.maine17:09:36

Sorry afk. Will leave instructions here as soon as I can

gratitude 1
borkdude09:10:38

If you want, we could also do a video chat to debug things, if that helps

borkdude10:10:56

I ran with the nightly all weekend but I've switched back to the June version now as the lag is still noticeable to me to the point where it becomes annoying

borkdude10:10:46

Is there a chance we can move back to lsp4j perhaps? I don't know how large that change was. Perhaps there is a way we can hide this behind a protocol so lsp4clj can see more testing before switching definitively?

borkdude10:10:16

I realize this may be a case similar to people being able to hear high pitch sounds where others don't notice it, but for me it's enough that the thought of forking for personal use has even crossed my mind briefly (which I find undesirable)

ericdallo10:10:35

I see your pain @U04V15CAJ, sorry for the headache, not sure if @U07M2C8TT has anything more to debug related to that, it's really weird this only happen with you and I don't think that is related with the way we code, we usually can repro all performance issues and test even in other editors. From my point of view, after Jacob's change, clojure-lsp is fast as before, even faster with some other improvements we did, so I still believe it's something related with your emacs or something as we didn't have any more complains even posting on #lsp channel. It's not that easy to rollback to lsp4j I think and not sure it's worth to maintain 2 versions of that unfortunately. My suggestion is to release a new version with that as we already have lots of changes for next release which would be good to be released and check for some time if there are any other people with issues like yours.

borkdude10:10:49

What I suspect is that other people have these issues too, but they just don't notice it (yet)

borkdude10:10:44

The June version doesn't have this issue for me with the same emacs config, so I have a hard time believing that it's my emacs config

borkdude10:10:44

but maybe co-incidentally some issue will be found in the future and perhaps I will be able to upgrade at some point in the future... :(

ericdallo10:10:30

Yeah, having it only on nightly limits a lot the people that will test that, that's why if we have it as release we may find other people with that issue and maybe in other editors

👍 2
borkdude10:10:35

Makes sense. Btw, I'll probably release a new clj-kondo too this week

ericdallo10:10:10

Cool, so I'll wait for that

borkdude10:10:28

probably Wednesday

👍 2
lread14:10:33

FWIW, I see the big lag using doom emacs, when doing the xxxxxxxx test in analyzer.clj from clj-kondo sources. I can confirm it is pretty bad. I also see a vast improvement in the nightly build. The nightly build lag seems fine for me but I work at leespeed not borkspeed. For folks who work at borkspeed the lag could feel like eons. I’m not currently working on any larger files right now (the lag is correlated to larger files?), when I get back into working on a larger file I might get a better feel for the effect of the lag on my psyche.

thanks 1
ericdallo14:10:14

so for you the nightly fix the issue right? same for me, and I consider that I usually type fast as well IMO 😅 (that's why releasing this fix may bring more users or no)

borkdude14:10:07

> fix the issue right? I think what we are seeing is that the lag got reduced to an amount that for some people is tolerable and for some people is not. And it's still not close to what it was imo.

ericdallo14:10:28

That's what looks like for you right? we are not sure yet, for all other users that complained they consider fixed

borkdude14:10:14

I think @UE21H2HHD told me earlier that he does notice the lag, but it doesn't bother him enough to feel it.

ericdallo14:10:43

Your gif representing your issue is quite noticeable, so I don't think it's a "Some people may notice or not" issue, the lag was quite high on the gif.

borkdude14:10:57

Yes, I'm referring to the new nightly

borkdude14:10:30

but even at this moment, I don't get why not more people reported the problem with the currently released lsp

borkdude14:10:59

The first one who reported this was me, 5 minutes after upgrading and then you all could reproduce the problem, while you had been working with this for probably weeks

ericdallo14:10:55

I noticed the problem too, just didn't have time to take a look/not sure was really clojure-lsp or any other thing on my setup The idea is to have it released as latest release is really being affected

lread14:10:16

I’ll retry the xxxxxx test with current nightly on doom emacs.

gratitude-thank-you 2
jacob.maine15:10:56

Apologies for not being able to follow up on this. I’ve been traveling for the last few days. I’ll have a few hours to look at it this morning, but I have a cold so my energy is pretty low.

jacob.maine15:10:37

@UE21H2HHD are you having freezes too? Are you running the nightly or the last official release?

ericdallo15:10:50

@U07M2C8TT Keep in mind we don't need to hurry IMO, we should do the release this week soon since we have most users using the latest release with the bug, and this new release should fix or at least improve a lot, so take your time

👆 3
jacob.maine15:10:04

@U04V15CAJ will you (setq garbage-collection-messages t)?

jacob.maine15:10:00

I know… I’m not feeling a TON of urgency, but I do want to figure this out. I’m starting a new job next week, so I won’t have as much time for this. I’d like to make some more progress on it this week

👍 1
borkdude15:10:35

I'll try it now: (setq garbage-collection-messages t)

jacob.maine15:10:05

Emacs says that it will log whenever it does GC if you set garbage-collection-messages. This doesn’t actually work for me—I get nothing in Messages—but if it works for you, it’s a good thing to try first

borkdude15:10:25

I don't see anything either (assumed that this lag is caused by GC)

jacob.maine15:10:13

Another quick thing to check… does your clojure-lsp server log include Trace messages—the logs of the actual JSON going back and forth—or just the regular clojure-lsp logging?

borkdude15:10:17

You mean the file to which lsp logs on disk?

borkdude15:10:07

no JSON there

jacob.maine15:10:59

Yes, that’s the file I meant. An aside… In the old code there were 3 log sources. 1. lsp-mode trace (JSON) logs (available in a buffer in Emacs) 2. clojure-lsp normal logs (a file on disk) 3. clojure-lsp trace (JSON) logs (a different file on disk, but which required a special build to set up) In the new code, the two flavors of clojure-lsp logs have been combined into one file. The tracing can be turned on or off, either by making a special build, or by starting the clojure-lsp executable with --trace

ericdallo15:10:09

About 1. I'll make lsp-mode stop tailing that file autoamtically, removing gcs

jacob.maine15:10:46

> I’ll make lsp-mode stop tailing that file autoamtically Uh… will you explain in more detail?

jacob.maine15:10:57

lsp-mode tails which file automatically?

ericdallo15:10:22

Yes, when I created lsp-clojure-server-log I thought it'd be a good idea to automatically emacs tail that file, I just didn't know emacs was terrible on performace doing that :) https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-clojure.el#L246-L269

jacob.maine15:10:41

Does that tail start whenever you open a Clojure file? Or only when you run lsp-clojure-server-log? That is are you always tailing that log, or only sometimes?

ericdallo15:10:55

But that should only affect performance if: • user has the log file huge • user has the log buffer opened

ericdallo15:10:08

Only when running that command manually

jacob.maine15:10:48

OK. @U04V15CAJ do you know if you’ve run that command in your current Emacs session?

borkdude15:10:44

dunno, but I'll restart just to make sure I haven't

👍 2
borkdude15:10:49

restarted but no difference

jacob.maine15:10:09

@UKFSJSM38 my Emacs “remembers” open buffers, so restarting sometimes re-opens stuff I had tried to close. Do you know if there’s a way to disable that?

😮 1
ericdallo15:10:54

Not really, I didn't know about such feature

jacob.maine15:10:12

OK, not a big deal

borkdude15:10:13

I'll be happy to try out some minimal other emacs config with lsp enabled

jacob.maine15:10:56

@U04V15CAJ that’d be great. I have a few other ways to check whether Emacs GC might be to blame… want to try those?

ericdallo15:10:08

There is one lsp-mode's lsp-start-plain which we recommend to test bugs

borkdude15:10:44

@U07M2C8TT I wanna try everything

jacob.maine16:10:13

haha… sounds good. I just don’t want to send you on too many errands simultaneously. Which do you want to try first? More GC research or a simple Emacs config?

borkdude16:10:55

simple emacs sounds good, preferably with CIDER and clojure-mode etc already enabled so I can test it in clojure

borkdude16:10:34

perhaps it would be good to have such a minimal config for clojure-lsp users in general

borkdude16:10:41

which you can just swap with your .emacs.d

borkdude16:10:43

I do not use vim keybindings so anything with that, I can't work with

ericdallo16:10:46

Maybe we should link it on clojure-lsp troubleshooting, although it's emacs specific.

borkdude16:10:16

ok, I'll try this one

borkdude16:10:38

it's installing now...

jacob.maine16:10:59

I just tried lsp-start-plain.el, but I get Debugger entered--Lisp error: (cl-assertion-failed ((seq-every-p (apply-partially #'stringp) command) "Invalid command list")) as lsp is starting. I’ll try the Clojure specific config

borkdude16:10:24

I had no lag with the minimal setup, but when running lsp-clojure-server-info it turned out it was running the lsp4j one ;)

😂 1
borkdude16:10:30

Now trying to switch to the nightly again...

borkdude16:10:04

ok back on :server-version "2022.09.29-20.05.41-nightly", now... let's try

borkdude16:10:49

Hmmmm, I can't reproduce now with the minimal setup, interesting!

🙌 1
ericdallo16:10:49

Oh, so glad to see progress!!

🎉 1
borkdude16:10:59

Btw, this is useful to add to the minimal setup for debugging with a specific clojure-lsp: lsp-clojure-custom-server-command '("/Users/borkdude/bin/clojure-lsp-2022-09-30")

ericdallo16:10:19

For sure, I'll update the docs soon with this kind of debugging

ericdallo16:10:02

@U04V15CAJ I suggest you start enabling some lsp features you have on your config, like lens etc and check if that changes anything

jacob.maine16:10:35

Very exciting. Still a lot to bisect, but at least we have a starting point

🙌 1
ericdallo16:10:09

FYI: Removed the tail from lsp-clojure-server-log , it should not cause performance issues anymore on latest lsp-mode.

borkdude16:10:01

I can't get my separate clj-kondo install working alongside this minimal setup

lread16:10:05

Ok, I’m back… retried xxxxxxx test on clj-kondo analyzer.clj on latest nightly clojure-lsp and do not notice any lag.

🙏 1
ericdallo16:10:01

@U04V15CAJ wait a sec, all this time you were using clj-kondo diagnostics with lsp?

ericdallo16:10:43

this could be important to test, if clj-kondo could be causing any conflicts with lsp-mode, I know you use like that for years though

borkdude16:10:47

No, I disabled those, I'm always running my own version of clj-kondo

jacob.maine16:10:56

oooh… that explains why i wasn’t getting squiggles with your lsp-mode config @U04V15CAJ

👍 1
borkdude16:10:05

I now was able to enable it. For some reason I had to toggle flycheck-mode

borkdude16:10:43

but still no lag 😅

jacob.maine16:10:52

and also why i haven’t noticed the new unused expr warning

borkdude16:10:12

Ah well, maybe I'll just use this minimal setup then :P

😂 1
emacs 3
borkdude16:10:53

(I'll keep digging)

🙏 1
borkdude16:10:46

How do I start another emacs with my own config again? I can hardly work here ;)

ericdallo16:10:06

I think you can pass a flag to emacs command to point to a file :thinking_face:

ericdallo16:10:11

maybe

emacs -q --load <path-to-your-init.el>

borkdude16:10:51

Awesome: emacs -q --load ~/.emacs.d.bak/init.el

jacob.maine16:10:38

Agh… wrong file

😅 1
jacob.maine16:10:39

It’s subtle, but there’s a tiny pause as I’m deleting the ~10th character on the 3rd line of xxxs. Emacs’ memory usage also drops right around that time

borkdude16:10:10

yep, the tiny pauses.... but I only have them when I stop and then edit again

jacob.maine16:10:54

@U04V15CAJ would you keep an eye on Activity Monitor to see if you notice a drop in Emacs memory usage around the time that the pauses happen? Remember that Activity Monitor only samples every 2 seconds or so, so there may be a delay before a new reading. Can anyone recommend a better tool than Activity Monitor?

borkdude16:10:49

(dinner, be back tonight)

borkdude18:10:26

I am bisecting my config now and I excluded some packages, it still works now... slowly adding stuff back

👍 1
borkdude18:10:02

Well, it seems throwing away my elpa directory and recompiling all packages fixed the issue laughsob

🎉 3
1
borkdude18:10:45

How on earth could that fix the issue and what has this got to do with the clojure-lsp version I wonder... but it would maybe be good to add to the "troubleshooting" section of clojure-lsp...

2
lread18:10:22

Welcome back to the awesome world of up-to-date clojure-lsp @U04V15CAJ!

borkdude18:10:40

Thank you all for hanging in there with me!

❤️ 2
borkdude18:10:55

It's probably not the first time that an emacs issue got fixed by deleting elpa, but I always forget to do this

lread18:10:07

I didn’t do much but I do know we must invest in keeping the borkmachine productive. simple_smile

☝️ 1
borkdude18:10:53

If I ever meet you, I owe you guys a beer or two

lread18:10:48

Likewise! But coffee beans for me please!

borkdude18:10:12

"beer" as placeholder for any drink you would like

2
ericdallo18:10:28

Awesome! Never faced a issue where the backend change could affect emacs elpa packages, pretty wild! Doom uses straight el to manage packages so probably that's related why I never faced that

jacob.maine18:10:30

It was a worthwhile adventure. I’m really glad that we found and fixed the CompletableFuture problem. I’m quite confused why the clojure-lsp version makes a difference, and still wonder if there’s some lingering problem. I’ll think about it

❤️ 1
jacob.maine18:10:48

I’m also using straight.el

borkdude18:10:12

I should probably rewrite my config to one of those things and ditch 50% of what I'm using right now

👍 1
lread18:10:35

I use doom and mostly with a config stolen from @UKFSJSM38 simple_smile

😛 1
borkdude18:10:50

one of the problems I haven't solved to satisfaction is version-control my elisp packages, this is why I even save the elpa dir in git

jacob.maine18:10:06

> version-control my elisp packages I’m not an expert on straight.el, but I think that’s the problem that it’s supposed to solve

borkdude18:10:51

So a few things that helped debugging/narrowing down the issue: • Minimal .emacs.d for clojure(script) users: this showed the issue didn't occur with the other config • (which lead to): Removing elpa (after bisecting) Both things are probably good to have in the trouble-shooting section

ericdallo18:10:46

will add to docs, thank you!

borkdude19:10:37

@UKFSJSM38 @U07M2C8TT @UE21H2HHD Would any of you be interested in a free babashka t-shirt, as a thank you? (Feel free to say no if this is not your cup of tea). https://www.etsy.com/borkdude/listing/1241766068/babashka-clj-kondo-nbb-shirt

jacob.maine19:10:14

That would be amazing! Totally unnecessary though

lread19:10:16

Dude! Cool! Didn’t know that these existed. I’d be happy to buy one.

lread19:10:14

And nbb and kondo on the back! Neat!

borkdude19:10:27

@U07M2C8TT I mean it, let me know your address and I'll make sure one gets delivered

borkdude19:10:33

and also the size etc.

ericdallo19:10:48

Oh, I'd love it!

lread19:10:51

I’m already pretty darn handsome, I’m not sure the world could handle me in a shirt like this.

😂 2
borkdude19:10:43

DM me the color, size and address if you want one, take it or leave it :)

👍 1
excited 1
borkdude20:10:25

Someone just mentioned eglot to me: https://github.com/joaotavora/eglot I'd never heard of that. Is it any good, what are the differences?

ericdallo20:10:11

It has less feaatures than lsp-mode, I personally prefer lsp-mode, but have some friends that use it with clojure and say that work well. There is a https://github.com/joaotavora/eglot/issues/661 though that you can't go to jars or goto def of java

ericdallo20:10:25

The development is usually slower than lsp-mode as it's shipped on elpa or something like that IIRC

ericdallo20:10:43

Eglot doesn't support code lens and call hierarchy too AFAIK

borkdude20:10:26

I see, so no "x references"?

yes 1
borkdude20:10:03

I'll stay with whatever the maintainers of clojure-lsp are using for now, seems the safest ;)

😂 1
👍 1