Skip to content

perf(check): parallelize file reads in grepFiles()#349

Merged
rhuanbarreto merged 1 commit into
mainfrom
perf/parallel-grep-files
May 25, 2026
Merged

perf(check): parallelize file reads in grepFiles()#349
rhuanbarreto merged 1 commit into
mainfrom
perf/parallel-grep-files

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Parallelize grepFiles() in src/engine/runner.ts — file reads were sequential inside a for await loop; now files are collected first, then read in parallel batches of 32 via Promise.all()
  • I/O-bound operation benefits from concurrent reads — expected 2–5× improvement in repos with >100 matched files
  • Batch size of 32 stays within OS fd limits; results are order-independent so parallelism is safe

Test plan

  • All 1202 existing tests pass (including grepFiles regression + helper tests)
  • bun run validate passes (lint, typecheck, format, test, ADR check, knip, build)
  • ADR compliance reviewed — no violations or warnings

Closes #344

grepFiles() previously read files sequentially inside a for-await loop
over Bun.Glob.scan(). Since the operation is I/O-bound, concurrent reads
improve throughput significantly for rules that grep across many files.

Collect file paths from the glob scan first, then read + grep in parallel
batches of 32 via Promise.all(). Batch size stays within OS fd limits
while providing 2-5x faster grepFiles calls in repos with >100 matched
files.

Closes #344

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 926d487
Status: ✅  Deploy successful!
Preview URL: https://466a95c5.archgate-cli.pages.dev
Branch Preview URL: https://perf-parallel-grep-files.archgate-cli.pages.dev

View logs

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.0% (6525 / 7247)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.1% 2069 / 2348
src/engine/ 93.1% 1208 / 1298
src/formats/ 100.0% 141 / 141
src/helpers/ 89.8% 3107 / 3460

@rhuanbarreto rhuanbarreto merged commit 1d7bd1f into main May 25, 2026
11 checks passed
@rhuanbarreto rhuanbarreto deleted the perf/parallel-grep-files branch May 25, 2026 18:51
@archgatebot archgatebot Bot mentioned this pull request May 25, 2026
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.

perf: parallelize file reads in grepFiles()

1 participant