perf: batch all files into a single docker run invocation#281
Merged
Conversation
Instead of spawning a new Docker container for every source file, collect all files into an array and pass them to clang-format in a single docker run call. This eliminates the per-file container startup overhead that made the action slower than compiling a full project. For clang-format >= 10, all files are passed to --dry-run --Werror in one invocation. For older versions (< 10), a single container runs format-diff-old.sh (mounted read-only) which diffs each file. Failing files are still listed individually in failing-files.txt and on stderr, and the script exits with 1 if any file is incorrectly formatted. Fixes #147 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a8ebc5b to
b41357e
Compare
jidicula
commented
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
As reported in #147, the action runs much slower than expected because
check.shspawns a new Docker container for every source file. The per-file container startup overhead dominates runtime, making the format check slower than compiling an entire project.Solution
Collect all matching source files into an array and pass them to
clang-formatin a singledocker runinvocation.--dry-run --Werrorin one call. Failing file paths are extracted from the diagnostic output.Preserved behavior
Failed on file: ...)failing-files.txtis still written for the job summary stepFixes #147