Module merge

Module merge 

Source
Expand description

§IO Merging

This module provides functionality to merge multiple sequential IO requests into a single larger request.

§Overview

Merging IO requests can significantly improve performance by:

  • Reducing the number of system calls (io_uring_enter or io_submit).
  • Allowing larger sequential transfers which are often more efficient for storage devices.
  • Reducing per-request overhead in the driver and completion handling.

§Mechanism

The core component is IOMergeSubmitter, which buffers incoming IOEvents.

  • Buffering: Events are added to EventMergeBuffer. They are merged if they are:

    • Sequential (contiguous offsets).
    • Same IO action (Read/Write).
    • Same file descriptor.
    • Total size does not exceed merge_size_limit.
  • Flushing: When the buffer is full, the limit is reached, or flush() is called, the merged request is submitted.

  • Sub-tasks:

    • If events are merged, a new “master” IOEvent is created covering the entire range.
    • The original events are attached as sub_tasks (a linked list) to this master event.
    • Write: The data from individual buffers is copied into a single large aligned buffer.
    • Read: A large buffer is allocated for the master event. Upon completion, data is copied back to the individual event buffers.
    • Completion: When the master event completes, callback_merged (in tasks.rs) is invoked. It iterates over sub-tasks, sets their results (copying data for reads), and triggers their individual callbacks.

§Components

Structs§

EventMergeBuffer
IOMergeSubmitter
Try to merge sequential IOEvent.