Skip to content

perf: batch all files into a single docker run invocation#281

Merged
jidicula merged 4 commits intomainfrom
batch-docker-invocation
Mar 16, 2026
Merged

perf: batch all files into a single docker run invocation#281
jidicula merged 4 commits intomainfrom
batch-docker-invocation

Conversation

@jidicula
Copy link
Copy Markdown
Owner

Problem

As reported in #147, the action runs much slower than expected because check.sh spawns 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-format in a single docker run invocation.

  • clang-format ≥ 10: All files are passed to --dry-run --Werror in one call. Failing file paths are extracted from the diagnostic output.
  • clang-format < 10: A single container runs an inline bash script that formats and diffs each file.

Preserved behavior

  • Failing files are still listed individually on stderr (Failed on file: ...)
  • failing-files.txt is still written for the job summary step
  • Exit code 1 on any formatting violation

Fixes #147

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>
@jidicula jidicula force-pushed the batch-docker-invocation branch from a8ebc5b to b41357e Compare March 16, 2026 12:45
Comment thread check.sh Outdated
@jidicula jidicula marked this pull request as ready for review March 16, 2026 13:01
@jidicula jidicula merged commit 322ba61 into main Mar 16, 2026
161 checks passed
@jidicula jidicula deleted the batch-docker-invocation branch March 16, 2026 13:07
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.

Action runs much slower than compiling a full project

1 participant