Skip to content

Comments

Use batching instead of individual runs per file#55

Merged
lolgab merged 3 commits intomasterfrom
single-batch-run-to-improve-performance
Feb 17, 2026
Merged

Use batching instead of individual runs per file#55
lolgab merged 3 commits intomasterfrom
single-batch-run-to-improve-performance

Conversation

@jorgebraz
Copy link

@jorgebraz jorgebraz commented Feb 9, 2026

Somewhere along Codacy's lifetime swiftlint was changed to run individually for each file which was resulting in constant an pervasive timeouts at 15 minutes (from testing, the tool would take close to 2 hours to be able to analyse a frequent workload -- under version 0.61.0). This was happening because starting up all the swiftlint machinery was quite expensive and time consuming (~1 minute) and was being done for each individual file.

Seemingly, with a bump to version 0.63.2 this problem basically all but vanishes, as a workload that was takin 1:55:33 to be performed under 0.61.0 would take 00:01:29 under 0.63.2 therefore greatly mitigating the original issue.

Still, batching (giving the tool a list of all the files to be analysed) significant performance improvements, reducing the analysis time from 90 seconds to 10 seconds.

Assuming the same workload (100 files):

0.61.0 sequential:

  • 01:55:33 (~2 hours)
  • docker run --rm -t -e TIMEOUT_SECONDS="18000" --net=none --cap-drop=ALL - 0.20s user 0.07s system 0% cpu 1:55:33.54 total

0.63.2 sequential:

  • 00:01:26 (~1:30 minutes)
  • docker run --rm -t --net=none --cap-drop=ALL --security-opt=no-new-privileges 0.08s user 0.04s system 0% cpu 1:26.32 total

0.63.2 batch:

  • 00:00:09 (~10 seconds)
  • docker run --rm -t --net=none --cap-drop=ALL --security-opt=no-new-privileges 0.08s user 0.04s system 1% cpu 9.682 total

The generated results across versions and approaches seem to be similar, so the change is apparently a net positive. Unfortunately it was not really possible to fully confirm the motivations that originally had moved swiflint from batch to sequential.

TAROT-3633
Screenshot 2026-02-09 at 10 22 40

Metabase dashboard:
Screenshot 2026-02-09 at 10 57 37

Somewhere along Codacy's lifetime swiflint was changed to run
individually for each file which was resulting in constant an prevasive
timeouts at 15 minutes (from testing, the tool would take close to 2
hours to be able to analyse a frequent workload -- under version
`0.61.0`). This was happening because starting up all the swiflint
machinery was quite expensive and time consuming (~1 minute) and was being
done for each indivitual file.

Seemingly, with a bump to version `0.63.2` this problem basically all
but vanishes, as a workload that was takin 1:55:33 to be performed under
`0.61.0` would take 00:01:29 under `0.63.2` therefore greatly mitigating
the original issue.

Still, batching (giving the tool a list of all the files to be analysed)
significan performance improvemnts, reducing the analysis time from 90
seconds to 10 seconds.

Assuming the same workload (100 files):
0.61.0 sequential: `01:55:33` (~2 hours)
0.63.2 sequential: `00:01:26` (~1:30 minutes)
0.63.2 batch: `00:00:09` (~10 seconds)

The generated results accross versions and approaches seem to be
similar, so the change is apparently a net positive. Unfortunately it
was not really possible to fully confirm the motivations that originally
had moved swiflint from batch to sequential.

TAROT-3633
@codacy-production
Copy link

codacy-production bot commented Feb 9, 2026

Codacy's Analysis Summary

0 new issue (≤ 1 medium issue)
0 new security issue (≤ 0 issue)
0 complexity
0 duplications

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

Now that we run files all together,
we can't return a FileError, since we don't know which file caused the error.
We return a global error instead.
Copy link

@codacy-production codacy-production bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR is 'up to standards'. Moving to batching provides a significant performance gain (from ~2 hours to ~10 seconds), effectively addressing timeout issues. However, there is a discrepancy: the description mentions a version bump to SwiftLint 0.63.2 as a key part of the fix, but this change (typically in a Dockerfile) is missing from the diff. Additionally, the implementation trades off granular error reporting for speed.

About this PR

  • The PR description highlights a version bump to SwiftLint 0.63.2 as a major factor in performance improvement, but the diff does not include changes to the Dockerfile or any build configuration where this version is defined. Ensure the version update is part of this PR.

💡 Codacy uses AI. Check for mistakes.

Comment on lines +111 to +112
runToolCommand(command, source, cfgOpt)
}.flatten

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

The move to batch execution removes the resilience provided by the previous per-file error handling. Previously, a crash or failure on a single file was captured as a FileError, allowing results for other files to still be reported. In the new batch mode, any failure during execution will cause the entire apply method to return a global Failure. While this trade-off is likely acceptable for the 100x performance gain, it changes how partial failures are communicated.

Try running the following prompt in your IDE agent:

Check if runToolCommand can be adapted to handle cases where SwiftLint returns a non-zero exit code but still produces partial JSON results on stdout, allowing us to report available violations even if the tool encountered an error on some files.

@lolgab lolgab enabled auto-merge (squash) February 17, 2026 10:41
@lolgab lolgab disabled auto-merge February 17, 2026 10:41
@lolgab lolgab merged commit 56de1d3 into master Feb 17, 2026
4 checks passed
@lolgab lolgab deleted the single-batch-run-to-improve-performance branch February 17, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants