Hello, we’re attempting to upgrade to ktlint 0.4...
# ktlint
b
Hello, we’re attempting to upgrade to ktlint 0.41, and are seeing extremely slow performance compared to 0.39 or 0.40-- earlier versions would run through a file in a second or so, but 0.41 is taking closer to a minute. Any ideas what might be going wrong? This is running directly over 1 small file
slight exaggeration, closer to 30 seconds:
Copy code
bdodson@C02D84ELMD6R snapchat % time java -Djava.awt.headless=true -XX:+UseParallelGC -jar ../utils/git_hooks/helpers/bin/ktlint-0.41.0.jar --verbose -F buildSrc/src/main/java/com/snap/gradle/plugins/quality/SnapQualityPlugin.kt
java -Djava.awt.headless=true -XX:+UseParallelGC -jar  --verbose -F   7.40s user 35.63s system 81% cpu 52.822 total
bdodson@C02D84ELMD6R snapchat % time java -Djava.awt.headless=true -XX:+UseParallelGC -jar ../utils/git_hooks/helpers/bin/ktlint-0.40.0.jar --verbose -F buildSrc/src/main/java/com/snap/gradle/plugins/quality/SnapQualityPlugin.kt
java -Djava.awt.headless=true -XX:+UseParallelGC -jar  --verbose -F   3.39s user 0.31s system 253% cpu 1.457 total
Ran a quick experiment, and see that if I switch to the directory hosting that single file and then run ktlint, it’s perfectly fast. I think there is some O(n) enumeration somewhere regardless of whether the files are explicitly listed (this is a quite large codebase)
s
There's a bug with 0.41 when you specify file globs with absolute paths - is that the case for you? There's a PR open to fix it but we haven't merged it yet
I'm afk so don't have the issue number handy
b
That seems to be part of the story-- 0.41 explicitly doesn’t support absolute paths. That’’s fine, I can pass a relative path, but it then seems to walk over every file in that path rather than the one I specify. I’ll have a look through the issues for it, thanks for the lead
s
Yeah that's exactly it - it is doing file traversals unnecessarily
b
and the unmerged patch would resolve that?
36925 files 😬
Just confirming that this fixed things for me. For now I’ve set up a private branch to pull in just this change on top of 0.41.0. Thanks again for the pointer 🙂