-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Excluded files impact the performance of swiftlint #5018
Comments
We hit this case as well, it seems like for us
Interestingly based on inspecting file opens it looks like what's happening is that when we pass a file list like |
Our exclusion list is as follows, and we saw a 3s->150s increase in execution time included: # paths to include during linting.
- '*/Sources'
- '*/Tests'
excluded: # paths to ignore during linting. Takes precedence over `included`.
- '.build'
- '.swiftpm'
- 'Sources/GraphQLQueries'
- '**/*.graphql.swift' |
There doesn't seem to be a way to actually use the Could this "easily" be added to the configuration file? |
With further testing, this performance impact is only seen when using globstar exclusion patterns. If I instead list out the directories directly, SwiftLint execution drops down to the expected sub-second timing |
I'm having same issue, so you solution is to change this
removing the ** from the path. |
In my case I've been avoiding the problem by making sure that these `.build' folders don't get generated (via some settings in the Swift VSCode extension), but that's not ideal. |
As a general rule one should avoid having the include and exclude patterns match too many files. They should be rather specific to avoid performance issues. I hope this restriction can be mitigated by #5157. |
New Issue Checklist
Describe the bug
The number of files present in the working tree of swiftlint has a huge impact on its performance even if most of these files are ignored. Here's a concrete example/repro:
The execution time is 6x what it is when these ignored files don't exist. Using the
--use-alternative-excluding
flag brings this to 5x but it'd still be nice to completely ignore these file. Not using a glob pattern in the config improves things by another 1x.It looks like the code is traversing the entire file tree in a few places (e.g. in the glob implementation), we could maybe make it use a recursive approach and stop when it encounters a subdirectory that is ignored (e.g. in my example it'd not look at the content of the
.build
directory at all).Environment
SwiftLint version (run
swiftlint version
to be sure)?From source
Installation method used (Homebrew, CocoaPods, building from source, etc)?
Source
Paste your configuration file:
See example
Are you using nested configurations?
No
Which Xcode version are you using (check
xcodebuild -version
)?The text was updated successfully, but these errors were encountered: