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

Lint in parallel #632

Closed
2 tasks done
borkdude opened this issue Nov 26, 2019 · 1 comment
Closed
2 tasks done

Lint in parallel #632

borkdude opened this issue Nov 26, 2019 · 1 comment
Assignees
Labels
clj-together enhancement New feature or request
Projects

Comments

@borkdude
Copy link
Member

borkdude commented Nov 26, 2019

This can speed up linting when providing a large classpath.

We borrowed some code from ClojureScript parallel-build:

https://github.com/clojure/clojurescript/blob/a15247a743d4d1c5d73224038f7289c447b38ca8/src/main/clojure/cljs/closure.clj#L1072

Without parallel:

clj-kondo --lint $(lein classpath)
linting took 59392ms, errors: 2176, warnings: 3995

With --parallel:

clj-kondo --lint $(lein classpath) --parallel
linting took 35919ms, errors: 2176, warnings: 3995

TODO:

  • improve contention on namespaces atom by using local atom in analyze-input and merging the contents with the main atom
  • get rid of nested swap! where possible (e.g. calling reg-finding! inside clj-kondo.impl.namespace/reg-var!).
@borkdude borkdude added this to Needs triage in clj-kondo via automation Nov 26, 2019
@borkdude borkdude moved this from Needs triage to In progress in clj-kondo Nov 26, 2019
@borkdude borkdude added the enhancement New feature or request label Nov 26, 2019
@sanel
Copy link

sanel commented Nov 26, 2019

This can be already done via find and xargs or parallel, but clj-kondo needs to be compiled as binary for fast startup.

Assuming standard leiningen project with src and test folders:

# run 10 parallel processes
$ find src test -name "*.clj*" | xargs -n 1 -P 10 clj-kondo --lint

# or
$ find src test -name "*.clj*" | parallel -j 10 clj-kondo --lint

However, this requires --cache false to be used or it will start throwing exception:

java.lang.Exception: Clj-kondo cache is locked by other process.
	at clj_kondo.impl.cache$sync_cache.invokeStatic(cache.clj:124)
	at clj_kondo.core$run_BANG_.invokeStatic(core.clj:97)
	at clj_kondo.main$main.invokeStatic(main.clj:85)
	at clj_kondo.main$main.doInvoke(main.clj:78)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:665)
	at clj_kondo.main$_main$fn__4926.invoke(main.clj:104)
	at clj_kondo.main$_main.invokeStatic(main.clj:104)
	at clj_kondo.main$_main.doInvoke(main.clj:102)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clj_kondo.main.main(Unknown Source)

Not sure if caching per process will make sense. After I disabled caching, speed was noticeable in multiple processes.

@borkdude borkdude moved this from In progress to Medium priority (new / enhance) in clj-kondo Nov 28, 2019
@borkdude borkdude self-assigned this Jan 31, 2020
@borkdude borkdude added this to TODO in Clojurists Together via automation Apr 2, 2020
borkdude added a commit that referenced this issue Aug 28, 2020
@borkdude borkdude moved this from Medium priority (new / enhance) to Next release in clj-kondo Aug 28, 2020
@borkdude borkdude moved this from Next release to In progress in clj-kondo Aug 30, 2020
borkdude added a commit that referenced this issue Aug 31, 2020
@borkdude borkdude moved this from In progress to Next release in clj-kondo Sep 8, 2020
@borkdude borkdude closed this as completed Sep 9, 2020
clj-kondo automation moved this from Next release to Done Sep 9, 2020
Clojurists Together automation moved this from To do to Done Sep 9, 2020
@borkdude borkdude removed this from Done in Clojurists Together Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clj-together enhancement New feature or request
Projects
clj-kondo
  
Done
Development

No branches or pull requests

2 participants