Fork me on GitHub
#clj-kondo
<
2024-01-25
>
borkdude15:01:47

I've been wrestling with getting Java analysis in clj-kondo's cache to warn about 1.12 errors about Java static field calls First succesfull version locally now!

🎉 15
borkdude20:01:28

hmm, I saved built-in analysis for a lot of Java classes (, java.lang, java.util, , java.time) etc but this increases the binary size of clj-kondo from 40 to 75 mb, I wonder if there's a better way to do it...

Noah Bogart20:01:57

is it computationally expensive to generate the analysis on the fly?

borkdude20:01:53

well, it requires downloading OpenJDK's source code and takes about 30 seconds. This is essentially what clojure-lsp is doing (cc @UKFSJSM38)

👍 1
Noah Bogart20:01:20

ah, i thought you were analyzing the jars directly. that makes sense

borkdude20:01:40

The JDKs jars aren't on the classpath

😮 1
😅 1
Noah Bogart20:01:18

Oh! there's always more to learn...

borkdude20:01:47

I could also just include the most popular top 200 classes or so instead of a couple of thousands of them

borkdude20:01:02

Then I guess I need to make myself some stats of what those are

borkdude20:01:15

which I can do with #C01EF12T49W

borkdude20:01:18

tomorrow...

ericdallo20:01:13

@U04V15CAJ did you try UPX on clj-kondo binary? I'm using for clojure-lsp for linux and mac, it increases slightly the startup time but it's way faster than JVM one (if using native-image)

ericdallo20:01:55

clojure-lsp binary size is ~120mb something and with upx it's 30mb

borkdude20:01:45

for lsp it doesn't matter much but clj-kondo can be invoked quite a few times (e.g. with xargs ) so I don't want to make it slower

👍 1
borkdude14:01:15

guess what, the resource increase didn't come from those transit files at all, it already happened on master. some bisecting to do

ohno 2
borkdude14:01:32

I get exactly the same size (71mb) with the previous release tag, but on CI the binary is around 40mb, I'm still using 22.3.0 Java 11 on CI though... so maybe that's it

borkdude15:01:41

with -O1 I get 54mb locally

borkdude15:01:56

yeah, without -O1 the image is 71mb, so that mostly explains it...

Alexander Kouznetsov18:01:46

Am I correct that https://github.com/clj-kondo/clj-kondo/blob/8cbc5d90db8ae3a25b95322015023077e672109a/src/clj_kondo/impl/analyzer.clj#L2470 lists all acceptable values for :lint-as target and it includes much more than just clojure. . For example, I see datahike.api/q , compojure.core/GET , re-frame.core/reg-event-db and many more.

Alexander Kouznetsov19:01:17

Would it be easy to change the code here to flag if lint-as is given for something clj-kondo doesn’t understand? It looks like it could be done if we replaced the ;; catch-all line with more specific [nil nil] maybe? And then the catch-all were flagging anything else? I’m trying to prevent situations when people add lint-as to something unsupported and it silently makes no difference without clj-kondo flagging that.

borkdude19:01:21

I'm not sure if :lint-as can be exclusively used for that list, I think lint-as can also be used for hooks but I'm not 100% sure

borkdude19:01:44

there was some edge case, can't remember the exact reason

borkdude20:01:28

hmm, I saved built-in analysis for a lot of Java classes (, java.lang, java.util, , java.time) etc but this increases the binary size of clj-kondo from 40 to 75 mb, I wonder if there's a better way to do it...