perf(bootstrapper): reduce disk I/O with throttled stack writes, async graph writes, deferred build-order write#1249
Conversation
…c graph writes, deferred build-order write Three file-write hotspots in the bootstrap loop were generating O(n²) disk I/O on the main thread: 1. `_record_stack_state` was called on every loop iteration, serializing and writing the full stack to bootstrap-stack.json. Throttled to at most once every 5 seconds (force-flush in `finalize()`). 2. `add_to_graph` → `write_to_graph_to_file()` wrote the full graph on every dependency edge. Graph writes are now moved to a single-threaded background `_write_pool` via `_write_graph_async()`, keeping serialization on the main thread for a consistent snapshot but eliminating blocking I/O from the critical path. 3. `add_to_build_order` rewrote build-order.json on every package. The disk write is removed entirely; data stays in `_build_stack` in memory and is written once in `finalize()`. Also renames `write_to_graph_to_file()` → `write_graph_file()` in `WorkContext` for clarity. Tests updated to reflect deferred build-order write (call `finalize()` before reading the file) and the stack-write throttle. Two new tests added: one verifying the throttle suppresses rapid writes, one verifying `finalize()` drains the write pool and produces both output files. Co-Authored-By: Claude <claude@anthropic.com> Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
|
Warning Review limit reached
Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Three file-write hotspots in the bootstrap loop were generating O(n²) disk I/O on the main thread:
_record_stack_statewas called on every loop iteration, serializing and writing the full stack to bootstrap-stack.json. Throttled to at most once every 5 seconds (force-flush infinalize()).add_to_graph→write_to_graph_to_file()wrote the full graph on every dependency edge. Graph writes are now moved to a single-threaded background_write_poolvia_write_graph_async(), keeping serialization on the main thread for a consistent snapshot but eliminating blocking I/O from the critical path.add_to_build_orderrewrote build-order.json on every package. The disk write is removed entirely; data stays in_build_stackin memory and is written once infinalize().Also renames
write_to_graph_to_file()→write_graph_file()inWorkContextfor clarity.Tests updated to reflect deferred build-order write (call
finalize()before reading the file) and the stack-write throttle. Two new tests added: one verifying the throttle suppresses rapid writes, one verifyingfinalize()drains the write pool and produces both output files.