Skip to content

feat: add bounded work queue to concurrent_delta to prevent OOM - #2971

Merged
oferchen merged 1 commit into
masterfrom
feat/bounded-delta-work-queue
Mar 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/bounded-delta-work-queue

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds a bounded WorkQueue to the concurrent_delta module that limits in-flight DeltaWork items to 2x rayon thread count, preventing OOM when transferring millions of small files.
  • Uses std::sync::mpsc::sync_channel for backpressure - the producer blocks when the queue is full. Consumers drain items via rayon par_bridge for parallel processing.
  • Includes comprehensive tests: backpressure verification, concurrency bounds, par_bridge integration, large batch (10K items) through small queue, deadlock detection, error handling.

Test plan

  • CI passes fmt+clippy, nextest on all platforms (Linux, macOS, Windows, musl)
  • backpressure_blocks_producer test verifies producer blocks at capacity
  • bounded_respects_in_flight_limit test verifies max active workers stays within rayon thread count
  • large_batch_completes_without_oom test sends 10K items through capacity-8 queue
  • concurrent_producer_consumer_timing test with capacity-1 queue detects deadlocks

@github-actions github-actions Bot added the enhancement New feature or request label Mar 22, 2026
Add WorkQueue backed by std::sync::mpsc::sync_channel that limits
in-flight DeltaWork items to 2x rayon thread count. The producer
blocks when the queue is full, applying backpressure to the generator.
Consumers drain items via rayon par_bridge for parallel processing.

This prevents unbounded memory growth when transferring millions of
small files, where the previous par_iter approach could queue all
work items simultaneously.
@oferchen
oferchen force-pushed the feat/bounded-delta-work-queue branch from c0ace6e to 4fa3870 Compare March 22, 2026 14:15
@oferchen
oferchen merged commit 728900c into master Mar 22, 2026
4 of 9 checks passed
@oferchen
oferchen deleted the feat/bounded-delta-work-queue branch March 22, 2026 14:15
oferchen added a commit that referenced this pull request May 1, 2026
Add WorkQueue backed by std::sync::mpsc::sync_channel that limits
in-flight DeltaWork items to 2x rayon thread count. The producer
blocks when the queue is full, applying backpressure to the generator.
Consumers drain items via rayon par_bridge for parallel processing.

This prevents unbounded memory growth when transferring millions of
small files, where the previous par_iter approach could queue all
work items simultaneously.
oferchen added a commit that referenced this pull request May 5, 2026
Add WorkQueue backed by std::sync::mpsc::sync_channel that limits
in-flight DeltaWork items to 2x rayon thread count. The producer
blocks when the queue is full, applying backpressure to the generator.
Consumers drain items via rayon par_bridge for parallel processing.

This prevents unbounded memory growth when transferring millions of
small files, where the previous par_iter approach could queue all
work items simultaneously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant