Fork me on GitHub
#lsp
<
2021-10-19
>
andrea.crotti14:10:39

clojure-lsp format takes quite a long time to run a medium-big project, and the weird thing is that it stays for most of the time at 95% Analyzying project files

andrea.crotti14:10:10

I guess it's just not estimating correctly how long it would take in total

ericdallo14:10:40

yes, it's not, we could improve the 95% specifically

ericdallo14:10:02

about the format, unfortunately, it's cljfmt performance issue, I don't think we have anything to improve on clojure-lsp side

ericdallo14:10:29

the percentage report is quite new @andrea.crotti I'm still tweaking one thing or other :)

andrea.crotti14:10:39

yeah ok sure np

andrea.crotti14:10:04

could the formatting run more concurrently?

andrea.crotti14:10:14

it seems like it's doing one file at a time

ericdallo14:10:04

wait a sec, when it's 95% Analyzing project files , clojure-lsp is still analyzing with kondo, we didn't call cljfmt yet

ericdallo14:10:19

only when you see Formatting foo.... is where we are calling cljfmt

andrea.crotti14:10:30

yeah ok, both thinigs are pretty slow tbf

andrea.crotti14:10:41

takes a few minutes just analyzing, and then a long time formatting

ericdallo14:10:38

Alright, about the formatting, we could ask cljfmt for performance improvements, @U016JRE24NL already helped a lot in the past with performance improvements on cljfmt side.

ericdallo14:10:20

About the 95% , this is when clojure-lsp is analyzing the project files with kondo, we already pass the :paralel flag to kondo run in paralel, not sure there is anything we could improve there besides a better report progress bar :/

ericdallo14:10:41

what is the size of the files in lines?

andrea.crotti14:10:59

just a few hundred lines

andrea.crotti14:10:03

just a few above 1k maybe

andrea.crotti14:10:20

around 40k lines of clojure in total

ericdallo14:10:30

clojure-lsp has similar project size maybe, and the 95% takes only few seconds

andrea.crotti14:10:02

well maybe I have a slow disk as well, since the dev environment is inside docker

ericdallo14:10:16

could you test on clojure-lsp project?

ericdallo14:10:43

you can just make lint-format on clojure-lsp side

ericdallo14:10:29

for me it takes ~5-6 secs

andrea.crotti14:10:57

I actually get a syntax error

andrea.crotti14:10:02

just pulled master

andrea.crotti14:10:45

trying just with time clojure-lsp format instead

andrea.crotti14:10:56

1 minute and 31 seconds

andrea.crotti14:10:07

running clojure-lsp format on the clojure-lsp codebase

andrea.crotti14:10:10

so well I guess just a slow disk

ericdallo14:10:19

5-6s I meant the 95%

andrea.crotti14:10:31

well a lot longer for that too

andrea.crotti14:10:33

maybe 30 seconds

ericdallo14:10:52

whe you run clojure-lsp for the first time in a project, it analyze the whole classpath (external analysis)

ericdallo14:10:22

this is what takes a long time, the next time, it will use cache

ericdallo14:10:34

but the 95% part always happen

andrea.crotti14:10:52

yeah took 34 seconds the second time

andrea.crotti14:10:05

ok well anyway no worries was just curious

ericdallo14:10:49

yeah, this is something I'm always trying to improve since it's the heaviest thing on clojure-lsp, next release should use Datalevin instead of sqlite which increase the cache finding (`10%`) and cache save after external analysis

ericdallo14:10:52

but thanks for the feedback

andrea.crotti14:10:48

another thing which I'm confused about is that for example clojure-lsp clean-ns would show also things like Cleaned re-graph.core, but that's not a ns in my project at all

andrea.crotti14:10:00

Cleaned zprint.zprint is another example

andrea.crotti14:10:09

where is it getting these from?

andrea.crotti14:10:45

is it not just supposed to go through all the namespaces in the current project directory simply?

ericdallo14:10:34

yes, that's weird 😅

ericdallo14:10:45

probably some misconfiguration

ericdallo15:10:46

we get the namespaces from clj-kondo analysis

andrea.crotti15:10:47

mm of what though? only thing would be clj-kondo config.edn but that doesn't mention zprint or re-frame either

andrea.crotti15:10:15

alright I can try to see what clj-kondo is returniing

ericdallo15:10:18

could you make a repro of this issue so I can investigate? this is new to me

andrea.crotti15:10:09

I'll check clj-kondo output first

andrea.crotti15:10:14

if I can reproduce it I'll report

andrea.crotti15:10:08

it is weird because most of them are correct, just namespaces inside my project

andrea.crotti15:10:25

but maybe a 10% is stuff like re-frame.subs cljs.tools.reader or other things

andrea.crotti15:10:29

totally unrelated

ericdallo15:10:50

yeah, probably a bug on clojure-lsp

ericdallo15:10:57

a repro would help a lot I investigate

ericdallo15:10:13

note the q/filter-project-analysis

ericdallo15:10:53

that baiscally exclude files that come from jars

ericdallo15:10:10

is there any chance you have these namespaces/files included not by jar

andrea.crotti15:10:36

mm not really no

andrea.crotti15:10:23

right I just tried on one of my open source projects

andrea.crotti15:10:26

and I see the same behaviour

andrea.crotti15:10:47

just running clojure-lsp format on that I see all these other namespaces

andrea.crotti15:10:56

should I create an issue mentioning that?

ericdallo15:10:35

Great, please do, with a repro I can debug it :)

ericdallo15:10:55

Oh are you Andrea from Emacs GCC?

ericdallo15:10:50

Nvm, thats other Andrea 😅

andrea.crotti15:10:36

hehe no I'm another Andrea

ericdallo15:10:51

Thank you, I'll try take a look and include on the release of this week

ericdallo19:10:58

@andrea.crotti I can't repro with your project for some reason :thinking_face:

ericdallo19:10:55

uh, it seems it was fixed since latest release to master

ericdallo19:10:13

I'll double check and try to understand why

andrea.crotti19:10:07

I have the latest version but didn't try with latest master

ericdallo19:10:31

yeah, I didn't understand yet why master fixed that 😂

ericdallo19:10:34

I'm debugging

ericdallo20:10:43

@andrea.crotti Would you mind test on your projects as well the latest master clojure-lsp? You can generate a clojure-lsp from master with just running make on clojure-lsp project

andrea.crotti20:10:08

mm I see the same issue

ericdallo20:10:41

:thinking_face:

andrea.crotti20:10:52

just pulled latest master

ericdallo20:10:03

the issue is:

ericdallo20:10:27

when compiling the cljs project, it generate files on the resources folder

ericdallo20:10:36

that clojure-lsp think it's related to your project

andrea.crotti20:10:58

ah wait I deleted .clj-kondo

andrea.crotti20:10:00

and tried again

andrea.crotti20:10:05

and it doesn't do that now

andrea.crotti20:10:16

so maybe it is fixed now actulaly

ericdallo20:10:21

ah it makes, it was the kondo cache from previous release

ericdallo20:10:35

try removing both caches, .clj-kondo/.cache and .lsp/.cache

Joshua Suskalo21:10:11

Hey, I'm currently using lsp for some personal projects for the first time in a while, and it's causing me some problems.

Joshua Suskalo21:10:15

When I work on projects that provide clj-kondo configuration, I tend to create the project hooks and config in the resources/clj-kondo.exports directory, as normal, but in my .clj-kondo directory I symlink to those files so that I can use the configuration I'm exporting.

Joshua Suskalo21:10:27

Every time I start lsp in a project like this though, it overwrites my symlinks as empty normal files

Joshua Suskalo21:10:37

Is that intended, or a bug?

borkdude21:10:36

@suskeyhose There is a better solution for this than symlinks

ericdallo21:10:52

I can't see why clojure-lsp would do that

ericdallo21:10:07

clojure-lsp just create the .clj-kondo dir if not exists, nothing more besides that

borkdude21:10:25

Add {:config-paths ["../resources/clj-kondo.exports/org.your/your.lib"]} to your config instead

Joshua Suskalo21:10:32

maybe there's something more than just lsp, but it's only happening to me when I add +lsp to my clojure module in doom

Joshua Suskalo21:10:42

oh, duh. That makes sense.

Joshua Suskalo21:10:50

For some reason it didn't occur to me to navigate up a directory

borkdude21:10:05

it's probably clj-kondo itself that's overwriting this as the result of lsp calling it with --copy-configs

👍 1
borkdude21:10:11

We should probably document this trick in the import/export configs section. PR or issue welcome... it's too late for me to do this now :)

Joshua Suskalo21:10:33

yeah, that fixed it

ericdallo21:10:28

Good, borkdude saved me from debugging clojure-lsp 😂

😂 1