Skip to content

UniversalReadPipeline - #8798

Merged
xzfc merged 4 commits into
devfrom
uio-pipeline
Apr 29, 2026
Merged

xzfc merged 4 commits into
devfrom
uio-pipeline

Conversation

@xzfc

@xzfc xzfc commented Apr 27, 2026 •

Copy link
Copy Markdown
Member

This PR implements io_uring-like interface for UniversalRead traits. Basically, it allows callers to schedule reads, and wait for scheduled reads.

Rationale

The current interator-based interface (e.g. UniversalRead::read_iter) assumes two separate phases:

// 1. decide what ranges to read
let ranges = something.iter().filter(…).map(…);
// 2. process contents of these ranges
for entry in f.read_iter(ranges)? {
    // ...
}

Some callers might want to interleave decide/process actions. (e.g. graph traversals). The new UniversalReadPipeline interface allows such interleaving.

Interface

pub trait UniversalReadPipeline<'a, T: Copy + 'static, R, Meta>: Sized {
    fn new() -> Result<Self>;
    fn can_schedule(&mut self) -> bool;
    fn schedule(&mut self, meta: Meta, file: &'a R, range: ReadRange) -> Result<()>;
    fn wait(&mut self) -> Result<Option<(Meta, Cow<'a, [T]>)>>;
}

Usage: call can_schedule() first. If it is true, you can call schedule().
After that, call wait().

Default implementations for batch/iter methods

In this PR, all of the existing batch/iter methods (read_batch, read_iter, read_multi, read_multi_iter) are implemented using UniversalReadPipeline. I.e. IoUringFile and MmapFile do not override these methods and implement only UniversalReadPipeline stuff.

This is not necessary, but it works as a stress-test for the new implementation. If the Rust compiler can optimize away all these abstraction layers, then (I hope) the new UniversalReadPipeline interface is good enough for an arbitrary case.

Benchmarks

The first commit made the performance of MmapFile worse (why -- see previous section).

The second commit adds an optimization that reclaims that performance back. (this optimization is not related to the new UniversalReadPipeline interface; but it matters when compiler inlines things)

cargo bench -p common --bench universal_io -- --measurement-time 60
io_uring/8bytes/read_single
                        time:   [199.78 ns 200.00 ns 200.24 ns]
                        change: [−0.9500% −0.7030% −0.4621%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe
io_uring/8bytes/read_batch_small_random
                        time:   [1.9649 µs 1.9667 µs 1.9686 µs]
                        change: [−1.4759% −1.3106% −1.1398%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  2 (2.00%) high mild
  4 (4.00%) high severe
io_uring/8bytes/read_batch_small_sequential
                        time:   [1.2342 µs 1.2362 µs 1.2383 µs]
                        change: [−3.4835% −3.2552% −3.0316%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
io_uring/8bytes/read_batch_full: 7.63s (single iteration)

mmap/8bytes/read_single time:   [18.042 ns 18.054 ns 18.066 ns]
                        change: [−2.7760% −2.5639% −2.3868%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe
mmap/8bytes/read_batch_small_random
                        time:   [126.62 ns 126.71 ns 126.81 ns]
                        change: [+0.5815% +0.7022% +0.8326%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe
mmap/8bytes/read_batch_small_sequential
                        time:   [25.039 ns 25.052 ns 25.065 ns]
                        change: [−0.6707% −0.5368% −0.3929%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe
Benchmarking mmap/8bytes/read_batch_full: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 60.0s. You may wish to increase target time to 71.1s, enable flat sampling, or reduce sample count to 60.
mmap/8bytes/read_batch_full
                        time:   [14.044 ms 14.058 ms 14.074 ms]
                        change: [−0.6710% −0.5204% −0.3642%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 9 outliers among 100 measurements (9.00%)
  1 (1.00%) low mild
  6 (6.00%) high mild
  2 (2.00%) high severe

io_uring/1KiB/read_single
                        time:   [293.83 ns 294.37 ns 294.96 ns]
                        change: [−2.2829% −2.0015% −1.7263%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild
io_uring/1KiB/read_batch_small_random
                        time:   [2.4616 µs 2.4665 µs 2.4714 µs]
                        change: [−0.9522% −0.6791% −0.4001%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
io_uring/1KiB/read_batch_small_sequential
                        time:   [1.7611 µs 1.7638 µs 1.7667 µs]
                        change: [−2.9723% −2.7320% −2.5126%] (p = 0.00 < 0.05)
                        Performance has improved.
io_uring/1KiB/read_batch_full
                        time:   [94.552 ms 94.615 ms 94.678 ms]
                        change: [−9.8336% −9.7564% −9.6820%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  3 (3.00%) low mild
  1 (1.00%) high mild

mmap/1KiB/read_single   time:   [106.76 ns 106.82 ns 106.87 ns]
                        change: [−0.7443% −0.5815% −0.4283%] (p = 0.00 < 0.05)
                        Change within noise threshold.
mmap/1KiB/read_batch_small_random
                        time:   [877.55 ns 878.03 ns 878.57 ns]
                        change: [−0.5131% −0.4133% −0.3161%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 6 outliers among 100 measurements (6.00%)
  5 (5.00%) high mild
  1 (1.00%) high severe
mmap/1KiB/read_batch_small_sequential
                        time:   [496.41 ns 496.74 ns 497.09 ns]
                        change: [+2.9087% +3.0668% +3.2292%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 6 outliers among 100 measurements (6.00%)
  1 (1.00%) low mild
  3 (3.00%) high mild
  2 (2.00%) high severe
mmap/1KiB/read_batch_full
                        time:   [11.006 ms 11.015 ms 11.024 ms]
                        change: [+1.3691% +1.5299% +1.6920%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 12 outliers among 100 measurements (12.00%)
  1 (1.00%) low mild
  5 (5.00%) high mild
  6 (6.00%) high severe

(not in this PR) Better schedule interface

The can_schedule() + schedule() probably is not the safest interface as it's easy to misuse: the caller can call schedule() even when the buffer is not available. Maybe later we can replace it with an interface that can prevent it. Some potential alternatives:

  • fn schedule(…) -> ScheduleResult<Meta>;
    enum ScheduleResult<Meta> {
        Ok, // Scheduled
        NoSpace(Meta), // Same as `can_schedule() == false`.
        Err(UniversalError), // I/O error
    }
  • enqueue_while-like interface.
  • Entry-like interface.

But for now I'd prefer to stick to can_schedule(): bool as it's the simplest option.

@xzfc
xzfc force-pushed the uio-pipeline branch 3 times, most recently from 5d744d7 to 479b82a Compare April 27, 2026 18:43
@xzfc
xzfc marked this pull request as ready for review April 27, 2026 18:46
@coderabbitai

This comment was marked as resolved.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
lib/segment/src/common/operation_error.rs (1)

159-167: Consider service_error_light for QueueIsFull to avoid backtrace cost.

service_error calls Backtrace::force_capture() (line 87), which is expensive on Linux. QueueIsFull is expected to fire on hot backpressure paths, so paying for a captured backtrace on every occurrence is wasteful and skews flame graphs. The same likely applies to Uninitialized, which represents a misconfiguration rather than a runtime invariant violation worthy of a backtrace.

♻️ Proposed split
             UniversalIoError::BytemuckCast(_)
             | UniversalIoError::ZerocopySize(_)
             | UniversalIoError::IoUringNotSupported(_)
             | UniversalIoError::NotFound { .. }
             | UniversalIoError::OutOfBounds { .. }
-            | UniversalIoError::InvalidFileIndex { .. }
-            | UniversalIoError::Uninitialized { .. }
-            | UniversalIoError::QueueIsFull => Self::service_error(err.to_string()),
+            | UniversalIoError::InvalidFileIndex { .. } => Self::service_error(err.to_string()),
+
+            UniversalIoError::Uninitialized { .. } | UniversalIoError::QueueIsFull => {
+                Self::service_error_light(err.to_string())
+            }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/segment/src/common/operation_error.rs` around lines 159 - 167, The match
arm currently maps UniversalIoError::QueueIsFull (and possibly
UniversalIoError::Uninitialized) to Self::service_error(err.to_string()), which
forces a Backtrace capture; change these to use
Self::service_error_light(err.to_string()) for QueueIsFull (and consider
Uninitialized) so hot backpressure/misconfiguration paths don't pay the
backtrace cost—locate the match handling UniversalIoError in operation_error.rs
and replace QueueIsFull (and optionally Uninitialized) branch targets from
service_error(...) to service_error_light(...), leaving other error variants
mapped to service_error(...) unchanged.
lib/common/common/src/universal_io/disk_cache/mod.rs (1)

125-151: Note: P: AccessPattern is silently ignored — fixed to Random.

The associated type DiskCacheReadPipeline<'a, T, Meta> does not propagate the P: AccessPattern parameter from UniversalRead::ReadPipeline<'a, P, Meta> to the underlying read; line 144 always uses file.read::<Random>(range). This is fine for a small in-memory cache layer, but it means callers who build the pipeline through read_batch::<Sequential, _> (or any other P) won't get the access-pattern behavior they asked for.

If the disk cache is ever extended with prefetch/readahead heuristics, you'll want to thread P through (e.g. DiskCacheReadPipeline<'a, T, P, Meta> carrying a PhantomData<P> and using file.read::<P>(range)). For now a brief comment documenting the intentional override would help future readers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/common/common/src/universal_io/disk_cache/mod.rs` around lines 125 - 151,
The code currently ignores the access-pattern type by hardcoding
file.read::<Random>(range) in DiskCacheReadPipeline::schedule, so either thread
the pattern through or explicitly document the override; to fix properly, add a
generic P: AccessPattern to the DiskCacheReadPipeline definition (e.g.,
DiskCacheReadPipeline<'a, T, P, Meta>), store PhantomData<P> in the struct,
update the impl to implement UniversalReadPipeline<'a, P, Meta> for
DiskCacheReadPipeline<'a, T, P, Meta>, and replace file.read::<Random>(range)
with file.read::<P>(range) in schedule so callers of read_batch::<Sequential, _>
get the requested access pattern (alternatively, if intentional, add a concise
comment next to the schedule implementation and the file.read::<Random> call
explaining why Random is forced).
lib/common/common/src/universal_io/io_uring/runtime.rs (1)

12-13: Tighten field visibility to pub(super) (or pub(crate)).

These fields only need to be reached from the sibling pipeline module in io_uring/mod.rs. Exposing them as fully pub widens the public API of the common crate unnecessarily and makes future internal refactors harder.

♻️ Proposed narrowing
 pub struct IoUringRuntime<'data, T, Meta = u64> {
-    pub io_uring: IoUringGuard,
-    pub state: IoUringState<'data, T, Meta>,
+    pub(super) io_uring: IoUringGuard,
+    pub(super) state: IoUringState<'data, T, Meta>,
     pub in_progress: usize,
 }

Note: in_progress (already pub) likely deserves the same treatment if the same accessors are only needed by the pipeline.

Based on learnings: "In the Qdrant codebase, using pub(super) visibility is preferred when fields need to be accessed by sibling modules (particularly for index type conversions), as it provides the necessary access without bloating the interface with numerous getters." (timvisee, PR 6503).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/common/common/src/universal_io/io_uring/runtime.rs` around lines 12 - 13,
The two struct fields currently declared as `pub io_uring: IoUringGuard` and
`pub state: IoUringState<'data, T, Meta>` should have their visibility narrowed
to `pub(super)` (or `pub(crate)` if sibling module layout requires crate-level
access) to avoid widening the public API; update the field declarations for
`io_uring` and `state` accordingly and also evaluate `in_progress` (currently
`pub`) and narrow it the same way if only accessed by the sibling pipeline
module to keep the interface minimal.
lib/common/common/src/universal_io/read.rs (1)

126-129: Document the Ok(None) semantics on wait().

The current doc only describes the "blocking until completed" path. Worth explicitly noting that Ok(None) means there are no outstanding scheduled operations (which is what allows the read_multi_iter driver to terminate the iterator).

📝 Suggested doc
-    /// Block until any of the scheduled operations is completed and consume its
-    /// result.
+    /// Block until any of the scheduled operations is completed and consume its
+    /// result. Returns `Ok(None)` when there are no outstanding scheduled
+    /// operations (i.e. nothing to wait for).
     fn wait(&mut self) -> Result<Option<(Meta, Cow<'a, [T]>)>>;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/common/common/src/universal_io/read.rs` around lines 126 - 129, The
docstring for the trait method wait (fn wait(&mut self) -> Result<Option<(Meta,
Cow<'a, [T]>)>>) is missing the semantics for Ok(None); update the comment to
explicitly state that Ok(None) indicates there are no outstanding scheduled
operations (i.e., the scheduler is empty) and that callers such as the
read_multi_iter driver should treat Ok(None) as the termination condition for
the iterator. Mention that Ok(Some(...)) returns a completed operation's
metadata and buffer and that Err(...) indicates an error.
lib/common/common/src/universal_io/mmap.rs (1)

134-165: Synchronous "pipeline" — consider a brief doc comment.

MmapReadPipeline performs the I/O synchronously inside schedule() (so read errors surface at schedule time, not at wait()). This is permitted by the trait contract but diverges from the IoUringPipeline behavior, so a one-line doc on the type clarifying the semantics would help future readers (and anyone trying to compare error-timing across backends).

📝 Suggested doc
+/// Mmap "pipeline": schedules at most one read at a time and performs
+/// the read synchronously inside [`schedule`](Self::schedule). Read errors
+/// are therefore reported by `schedule`, not by [`wait`](Self::wait).
 pub struct MmapReadPipeline<'a, T, P, Meta> {
     result: Option<(Meta, &'a [T])>,
     _phantom: PhantomData<P>,
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/common/common/src/universal_io/mmap.rs` around lines 134 - 165, Add a
one-line doc comment to the MmapReadPipeline type explaining that it performs
reads synchronously inside schedule(), so read errors are returned at schedule
time (not at wait()), and that this differs from async backends like
IoUringPipeline; reference the struct name MmapReadPipeline and the methods
schedule() and wait() in the comment so readers can quickly understand the
differing error-timing semantics when comparing to implementations of the
UniversalReadPipeline trait such as IoUringPipeline.
lib/common/common/src/universal_io/io_uring/mod.rs (1)

137-182: Pipeline implementation looks correct.

The can_schedule/schedule pair correctly bounds the queue and the unsafe push().expect(...) is properly guarded by the explicit capacity check. One small observation on wait(): when completion_is_empty() is false, we return a completed entry without ever flushing entries staged in squeue. That isn't a correctness bug (the next wait() with empty completion will submit), but it can leave staged entries unsubmitted longer than necessary when the previous submit_and_wait produced multiple completions. Worth keeping in mind if you observe latency anomalies under steady-state load.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/common/common/src/universal_io/io_uring/mod.rs` around lines 137 - 182,
The wait() path can return completed entries while leaving staged submission
queue entries unflushed; update wait() so when completion_is_empty() is false
you still flush any staged submissions before returning. Concretely, in
UniversalReadPipeline::wait(), after checking completion_is_empty()/before
returning a completed() entry, inspect self.runtime.io_uring.submission().len()
(or equivalent) and if > 0 call the runtime method that submits staged entries
(e.g., self.runtime.submit() or submit_and_wait(0) as appropriate) so staged
entries are pushed to the kernel; keep the existing completed() return behavior
otherwise.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/tonic/api/storage_read_api/helpers.rs`:
- Line 253: The mapping for UniversalIoError::QueueIsFull currently returns
Status::internal; change it to a retryable gRPC status such as
Status::resource_exhausted (or Status::unavailable) so the client sees this as
transient backpressure rather than an internal server error; update the match
arm handling UniversalIoError::QueueIsFull in the helper that produces
tonic::Status accordingly (replace Status::internal(e.to_string()) with
Status::resource_exhausted(e.to_string()) or
Status::unavailable(e.to_string())).

---

Nitpick comments:
In `@lib/common/common/src/universal_io/disk_cache/mod.rs`:
- Around line 125-151: The code currently ignores the access-pattern type by
hardcoding file.read::<Random>(range) in DiskCacheReadPipeline::schedule, so
either thread the pattern through or explicitly document the override; to fix
properly, add a generic P: AccessPattern to the DiskCacheReadPipeline definition
(e.g., DiskCacheReadPipeline<'a, T, P, Meta>), store PhantomData<P> in the
struct, update the impl to implement UniversalReadPipeline<'a, P, Meta> for
DiskCacheReadPipeline<'a, T, P, Meta>, and replace file.read::<Random>(range)
with file.read::<P>(range) in schedule so callers of read_batch::<Sequential, _>
get the requested access pattern (alternatively, if intentional, add a concise
comment next to the schedule implementation and the file.read::<Random> call
explaining why Random is forced).

In `@lib/common/common/src/universal_io/io_uring/mod.rs`:
- Around line 137-182: The wait() path can return completed entries while
leaving staged submission queue entries unflushed; update wait() so when
completion_is_empty() is false you still flush any staged submissions before
returning. Concretely, in UniversalReadPipeline::wait(), after checking
completion_is_empty()/before returning a completed() entry, inspect
self.runtime.io_uring.submission().len() (or equivalent) and if > 0 call the
runtime method that submits staged entries (e.g., self.runtime.submit() or
submit_and_wait(0) as appropriate) so staged entries are pushed to the kernel;
keep the existing completed() return behavior otherwise.

In `@lib/common/common/src/universal_io/io_uring/runtime.rs`:
- Around line 12-13: The two struct fields currently declared as `pub io_uring:
IoUringGuard` and `pub state: IoUringState<'data, T, Meta>` should have their
visibility narrowed to `pub(super)` (or `pub(crate)` if sibling module layout
requires crate-level access) to avoid widening the public API; update the field
declarations for `io_uring` and `state` accordingly and also evaluate
`in_progress` (currently `pub`) and narrow it the same way if only accessed by
the sibling pipeline module to keep the interface minimal.

In `@lib/common/common/src/universal_io/mmap.rs`:
- Around line 134-165: Add a one-line doc comment to the MmapReadPipeline type
explaining that it performs reads synchronously inside schedule(), so read
errors are returned at schedule time (not at wait()), and that this differs from
async backends like IoUringPipeline; reference the struct name MmapReadPipeline
and the methods schedule() and wait() in the comment so readers can quickly
understand the differing error-timing semantics when comparing to
implementations of the UniversalReadPipeline trait such as IoUringPipeline.

In `@lib/common/common/src/universal_io/read.rs`:
- Around line 126-129: The docstring for the trait method wait (fn wait(&mut
self) -> Result<Option<(Meta, Cow<'a, [T]>)>>) is missing the semantics for
Ok(None); update the comment to explicitly state that Ok(None) indicates there
are no outstanding scheduled operations (i.e., the scheduler is empty) and that
callers such as the read_multi_iter driver should treat Ok(None) as the
termination condition for the iterator. Mention that Ok(Some(...)) returns a
completed operation's metadata and buffer and that Err(...) indicates an error.

In `@lib/segment/src/common/operation_error.rs`:
- Around line 159-167: The match arm currently maps
UniversalIoError::QueueIsFull (and possibly UniversalIoError::Uninitialized) to
Self::service_error(err.to_string()), which forces a Backtrace capture; change
these to use Self::service_error_light(err.to_string()) for QueueIsFull (and
consider Uninitialized) so hot backpressure/misconfiguration paths don't pay the
backtrace cost—locate the match handling UniversalIoError in operation_error.rs
and replace QueueIsFull (and optionally Uninitialized) branch targets from
service_error(...) to service_error_light(...), leaving other error variants
mapped to service_error(...) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d16fdaa6-6e89-4dd5-b50f-f78b951f0614

📥 Commits

Reviewing files that changed from the base of the PR and between ca4ed7a and 479b82a.

📒 Files selected for processing (14)
  • lib/common/common/src/universal_io/disk_cache/mod.rs
  • lib/common/common/src/universal_io/error.rs
  • lib/common/common/src/universal_io/io_uring/mod.rs
  • lib/common/common/src/universal_io/io_uring/read_iter.rs
  • lib/common/common/src/universal_io/io_uring/runtime.rs
  • lib/common/common/src/universal_io/mmap.rs
  • lib/common/common/src/universal_io/read.rs
  • lib/common/common/src/universal_io/wrappers/mod.rs
  • lib/common/common/src/universal_io/wrappers/read_only.rs
  • lib/common/common/src/universal_io/wrappers/typed.rs
  • lib/common/common/src/universal_io/wrappers/wrapped_pipeline.rs
  • lib/segment/src/common/operation_error.rs
  • lib/segment/src/index/field_index/numeric_index/tests.rs
  • src/tonic/api/storage_read_api/helpers.rs
💤 Files with no reviewable changes (1)
  • lib/common/common/src/universal_io/io_uring/read_iter.rs

coderabbitai[bot]

This comment was marked as resolved.

Comment on lines -78 to -91
fn read_batch<'a, P: AccessPattern, Meta: 'a>(
&'a self,
ranges: impl IntoIterator<Item = (Meta, ReadRange)>,
mut callback: impl FnMut(Meta, &[T]) -> Result<()>,
) -> Result<()> {
let mmap = self.as_bytes::<P>();

for (meta, range) in ranges {
let items = read(mmap, range)?;
callback(meta, items)?;
}

Ok(())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep this custom impl. It would skip the Option from the pipeline.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be optimized away anyway.

@ffuugoo ffuugoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This turned out waaaaaay nicer than I expected! Nice work!

Comment on lines +36 to +39
type ReadPipeline<'a, P: AccessPattern, Meta>
= WrappedReadPipeline<'a, T, S, P, Meta>
where
Self: 'a;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we simply reuse S::ReadPipeline? 🤔

Suggested change
type ReadPipeline<'a, P: AccessPattern, Meta>
= WrappedReadPipeline<'a, T, S, P, Meta>
where
Self: 'a;
type ReadPipeline<'a, P: AccessPattern, Meta> = S::ReadPipeline<'a, P, Meta>
where
Self: 'a;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadPipeline::schedule() wants outer file: &'a S, not inner file: &'a S::ReadPipeline<…>.

I didn't found any non-cursed way to get rid of WrappedReadPipeline.

@ffuugoo ffuugoo Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadPipeline::schedule() wants outer file: &'a S...

Ah, yes, figured.

I didn't found any non-cursed way to get rid of WrappedReadPipeline

type File: UniversalRead<T> and declare as either type File = Self in native impls, or type File = Wrappee in wrappers? 🤔 Not 100% sure if it won't introduce more issues, though.

Comment on lines +50 to +53
type ReadPipeline<'a, P: AccessPattern, Meta>
= WrappedReadPipeline<'a, T, S, P, Meta>
where
Self: 'a;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

xzfc and others added 4 commits April 29, 2026 01:28
The previous commit removed `MmapFile::read_batch` method override. So,
`MmapFile` now re-uses the default `UniversalRead::read_batch` impl,
which is implemented using `UniversalReadPipeline` interface.

Unsurprisingly, it caused a slowdown in the benchmarks, particularly
this one:

    cargo bench -p common --bench universal_io -- mmap/8bytes/read_batch_full

This commit reclaims the performance back.
timvisee pushed a commit that referenced this pull request May 8, 2026
* UniversalReadPipeline

* Performance: cache pointers in MmapFile

The previous commit removed `MmapFile::read_batch` method override. So,
`MmapFile` now re-uses the default `UniversalRead::read_batch` impl,
which is implemented using `UniversalReadPipeline` interface.

Unsurprisingly, it caused a slowdown in the benchmarks, particularly
this one:

    cargo bench -p common --bench universal_io -- mmap/8bytes/read_batch_full

This commit reclaims the performance back.

* remove unfulfilled lint

* Review suggestions

---------

Co-authored-by: Luis Cossío <[email protected]>
Co-authored-by: Roman Titov <[email protected]>
@coderabbitai coderabbitai Bot mentioned this pull request Jun 18, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants