lsp

ericdallo 2025-07-25T15:42:04.176739Z

Just pushed a clj-kondo bump which may improve memory usage a lot in clojure-lsp, if so, we can reduce the min-memory clojure-lsp use, please test nightly! Context https://clojurians.slack.com/archives/C02RPGUCQNB/p1753457036233039

borkdude 2025-07-26T07:03:56.496909Z

Left is new?

lassemaatta 2025-07-26T07:05:01.791379Z

yeah

borkdude 2025-07-26T07:21:40.653229Z

Nice, a 1gb win

borkdude 2025-07-26T14:31:15.454589Z

Made some (low hanging fruit) optimizations and publishing a new version now. I'm seeing a bit better performance even compared to the previous version and all without caching. There's more optimizations I could do but those require a bigger change (captured that into an issue for the future).

ericdallo 2025-07-26T15:03:34.049639Z

Awesome, thank you both for the help! Will bump clojure-lsp in a few mins

ericdallo 2025-07-26T18:14:57.137439Z

nightly build available

👍 1
borkdude 2025-07-26T21:33:09.885389Z

@lasse.olavi.maatta would be nice if you could re-lint your project. what I'm seeing locally is that it is now even slightly faster than before and better memory behavior, but YMMV

lassemaatta 2025-07-27T05:11:53.089909Z

I ran the clojure-lsp diagnostics a few times; I discarded the first run after switching versions as that always seemed to be a bit slower: • 2025.06.13-20.45.44: about 33.9 - 34.2 s cpu time • 2025.07.25-15.41.15-nightly: 35.8 - 35.9 s • 2025.07.26-16.45.48-nightly: 32.2 - 33.4 s

👍 2
lassemaatta 2025-07-27T05:14:27.026419Z

no dramatic change in the memory usage when opening a projet between versions .25 - .26, as far as I can tell.

seancorfield 2025-07-25T15:46:17.509969Z

I assume that build isn't quite ready year -- I reloaded VS Code and got an error downloading lsp nightly.

ericdallo 2025-07-25T15:47:29.162749Z

yes, it will be available in a few mins and post in #clojure-lsp-builds

seancorfield 2025-07-25T15:48:13.583699Z

Thanks!

seancorfield 2025-07-25T16:12:35.618909Z

Got the new version, and it seems to have run successfully on our big project at work.

borkdude 2025-07-25T16:16:06.429409Z

Any difference in speed or memory usage?

lassemaatta 2025-07-25T16:21:47.747919Z

is there some specific way to benchmark the speed / memory use you'd suggest to make things easy to compare? I can test on our largeish project, but I'd love to provide exact numbers if I only knew how

seancorfield 2025-07-25T16:27:48.210969Z

I don't pay much attention to startup speed or memory usage so it's hard for me to say. I suspect for ongoing performance, I might notice more when working on HoneySQL, since that lags a bit...

ericdallo 2025-07-25T16:28:33.441369Z

I'm wondering if people will notice memory difference if we are passing a xms of 2gb in clojure-lsp

borkdude 2025-07-25T16:31:13.946569Z

Maybe run the command line version of LSP to see if diagnostics runs slower or equally fast

ericdallo 2025-07-25T16:31:33.215069Z

indeed, clojure-lsp diagnostics

lassemaatta 2025-07-25T16:32:53.309219Z

I ran clojure-lsp diagnostics from the command line a few times without clearing the cache; 2025.06.13 took about 34 s cpu time, 2025.07.25 took 36 - 37 s so just a bit slower.

ericdallo 2025-07-25T16:50:12.708269Z

thank you for testing @lasse.olavi.maatta! would you consider it a large project?

lassemaatta 2025-07-25T16:51:57.000869Z

No idea how accurate these are, but I used some random psrecord tool to graph the cpu and memory graphs (of the lsp process itself) while running the diagnostics from the cli. Looks like the memory use is quite a bit smaller with the new version.

ericdallo 2025-07-25T16:59:19.233939Z

the problem with clojure-lsp memory was always clj-kondo initial lint when starting, if we improved that, we can certainly touch that limit

borkdude 2025-07-25T17:43:26.786179Z

for clojure-lsp it's especially relevant that after the initial lint, all (or most) memory is freed, which is now the case

borkdude 2025-07-25T17:43:48.373599Z

I measured 28mb heap before linting and after linting (after forcing a GC)

borkdude 2025-07-25T17:44:51.581709Z

all by removing memoize usage which turned out to not be so beneficial especially when having large configs...

ericdallo 2025-07-25T18:00:28.597339Z

Intereesting

lassemaatta 2025-07-26T06:39:39.440849Z

here's the graphs for the first 120 seconds from opening a project in emacs with lsp-mode.

ericdallo 2025-07-27T13:56:59.179089Z

a good benchmark we use at nubank (suggestion from @andreribeirocamargo):

find .clj-kondo -mindepth 1 ! -name config.edn -exec rm -rf {} + && find .lsp -mindepth 1 ! -name config.edn -exec rm -rf {} + && time clojure-lsp diagnostics

ericdallo 2025-07-27T13:57:20.861899Z

basically removes the cache so clj-kondo analyzes the classpath again, which is what take most of time usually.

ericdallo 2025-07-27T13:58:01.509629Z

and since clj-kondo has no cache now, in the future we will need to remove only lsp cache

borkdude 2025-07-27T13:59:38.829239Z

Clj-kondo does have a file cache, just not in memory

👍 1
borkdude 2025-07-27T14:39:04.195089Z

To clarify, I just removed memoize usage which keeps stuff around in memory forever, if you keep the memoized function around

ericdallo 2025-07-27T14:52:19.390149Z

Yeah my bad, I got it but mentioned the wrong cache 😅

😅 1