spotless icon indicating copy to clipboard operation
spotless copied to clipboard

'ratchet' mode is very slow (plugin-maven)

Open rjmunro opened this issue 4 years ago • 5 comments

I have 6830 java files in my maven project (found with git ls-files "*.java" | wc -l) spread across 44 modules. When I have no changes (git diff --name-only origin/develop returns nothing) and I scan in ratchet mode, it takes nearly 10 minutes to do a no-op. When I removed ratchet mode because I wanted to see how many files were still misformatted, it took less than 20 seconds, even though it had to process every java file.

I was expecting it to be a lot slower because it had to actually read and format 6830 java files, rather than just look at git and see nothing has changed.

If you are submitting a bug, please include the following:

  • [ ] summary of problem
  • [ ] gradle or maven version
  • [ ] spotless version
  • [ ] operating system and version
  • [ ] copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
  • [ ] copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

If you're just submitting a feature request or question, no need for the above.

rjmunro avatar Dec 08 '21 20:12 rjmunro

That is surprising! Here's the codepath as it exists today, but #935 is gonna change things a bit.

https://github.com/diffplug/spotless/blob/08bf08c88c289f66019ba746c7acf2481b52958b/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java#L189-L209

https://github.com/diffplug/spotless/blob/08bf08c88c289f66019ba746c7acf2481b52958b/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java#L215-L238

https://github.com/diffplug/spotless/blob/08bf08c88c289f66019ba746c7acf2481b52958b/plugin-maven/src/main/java/com/diffplug/spotless/maven/GitRatchetMaven.java#L59-L72

nedtwigg avatar Dec 08 '21 21:12 nedtwigg

I believe this should be improved in plugin-maven 2.17.7. Can you report back @rjmunro?

nedtwigg avatar Dec 17 '21 00:12 nedtwigg

On my project on my Intel Macbook Pro, using version 2.17.7 it still takes about 9 minutes, similar to version 2.17.6. With ratchet turned off it takes 20 seconds with either version, so it's not made a noticeable difference.

rjmunro avatar Dec 24 '21 14:12 rjmunro

Bummer :(. I'm surprised by this, but the good news is that 2.18.0 adds an up-to-date cache which should help a lot whether ratchet is on or off. (#935)

nedtwigg avatar Dec 25 '21 21:12 nedtwigg

Can this be reopened?

rjmunro avatar Feb 09 '22 12:02 rjmunro

This should be much improved in our latest plugin-gradle 6.13.0 and plugin-maven 2.30.0 thanks to

  • #1426

I'm going to close this again, but please reopen if it is still issue in the latest releases.

nedtwigg avatar Jan 14 '23 23:01 nedtwigg