Skip to content

Keeping the queue full #1476

@andyg24

Description

@andyg24

One possible use for io_uring might be to process data in a file with the following loop:

for (;;) {
reap_io_completions();
submit_new_io_requests();
process_completions(); // this takes a bit of time
}

If the goal is to have a constant number of requests in flight (e.g. because the SSD works best at a certain QD), this loop isn't optimal. While initially the queue is full, the number of requests in flight will decrease while process_completions() is running. Additionally, in the general case this loop requires two syscalls per iteration -- one to reap completions, and then another to submit new requests, based on the number of reaped completions.

Would it make sense to decouple the length of the sqe queue from the internal submission queue? The idea would be to over-provision the sqe queue, and submit more requests than can be in flight at any given time. Then, whenever completions came in, these overflow requests would be automatically submitted. So even if process_completions() took some time, the data would continue to flow optimally.

Additionally, if a version of io_uring_enter() first reaped all completed events and then submitted pending sqes to refill the queue to capacity, the loop above could have only one syscall per iteration:

for (;;) {
add_io_requests_until_sqe_queue_is_full();
reap_and_submit();
process_completions();
}

Does this make sense? Is there another way to keep the number of requests in flight constant as completions arrive?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions