Skip to content

Bound the outline file queue to prevent memory spikes under parallel walk #2741

Description

@coderabbitai

Summary

In crates/cli/src/outline/extract.rs, the stream_paths function (around line 140) uses an unbounded mpsc::channel to pass OutlineFile payloads from a parallel producer to a sequential consumer. On large repos, parallel walkers can enqueue many full file payloads before the consumer processes them, causing significant memory spikes.

Suggested fix

Replace the unbounded channel with a bounded sync_channel to apply backpressure to producers:

const OUTLINE_QUEUE_BOUND: usize = 256;
let (tx, rx) = mpsc::sync_channel(OUTLINE_QUEUE_BOUND);

This limits the number of queued OutlineFile items, slowing producers when the queue is full rather than accumulating unbounded memory.

References

/cc @HerringtonDarkholme

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions