Skip to content

perf: parallel blame, parallel link checks, overlapped startup#26

Merged
laulauland merged 1 commit intomainfrom
lau/zig-0.16-async
Apr 17, 2026
Merged

perf: parallel blame, parallel link checks, overlapped startup#26
laulauland merged 1 commit intomainfrom
lau/zig-0.16-async

Conversation

@laulauland
Copy link
Copy Markdown
Member

Three additional concurrency layers in src/commands/lint.zig, all stacked on the per-doc Io.Group parallelism from #24. Fully documented in docs/CONCURRENCY.md.

Changes

Layer 2: per-binding parallel blame (io.async). checkBinding no longer shells out to git log inline. A new phase in checkOneDocInner spawns one io.async(vcs.getLatestBlameInfo, …) future per changed_after_baseline stale anchor, then awaits all of them and fills in the blame info on the anchor rows. A doc with 5 stale anchors previously ran 5 sequential git log calls; now they run concurrently on the thread pool.

Note: blame is fired after staleness is confirmed, not speculatively. Speculative blame on fresh anchors would cost ~20 ms per fresh anchor (typical git log -1 latency) to save ~15 ms per stale one — net negative in the common case where most anchors are fresh.

Layer 3: per-link parallel existence checks (Io.Group). checkDocLinks now spawns one task per markdown link, each doing realPathFileAlloc + accessAbsolute. Results fill pre-allocated ?JsonLinkRow slots and are appended in doc-order after group.await. Io.Batch was evaluated and rejected because its Operation union doesn't include stat/access ops in Zig 0.16.

Layer 4: overlapped startup (io.async). vcs.getRepoIdentity now runs as an io.async future in parallel with discoverDocGroups. Two independent git subprocesses execute concurrently. Small absolute win, but free.

Testing

  • zig build passes
  • zig build test passes: 63 tests, 0 failures
  • drift check output byte-identical to sequential baseline (same docs, same blame info, same sort order)
  • Local timing on drift's repo: ~0.14 s (layer 1 only) → ~0.11 s (layers 1–4). The layer-1 win from feat: parallelize per-doc check loop with Io.Group #24 dominates; layers 2–4 matter more in specific shapes (many stale anchors per doc, many cross-links per doc, tighter startup budgets).

Docs

docs/CONCURRENCY.md replaces the "proposed future work" sections with the actual implementation, keeps the rationale for why speculative blame was rejected, and notes one remaining proposal (persistent GitCatFile request/response pipelining) that doesn't match any current use case.

@laulauland laulauland marked this pull request as ready for review April 17, 2026 12:31
@laulauland laulauland merged commit 4c8bc3b into main Apr 17, 2026
5 checks passed
@laulauland laulauland deleted the lau/zig-0.16-async branch April 17, 2026 12:31
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.

1 participant