-
Notifications
You must be signed in to change notification settings - Fork 1
Exponential overflow header buffer #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/reader.rs
Outdated
async fn expand_prefetch(&mut self, range: Range<u64>) -> AsyncTiffResult<Bytes> { | ||
let existing_buffer_length = self.buffer_length() as u64; | ||
let additional_fetch = | ||
(existing_buffer_length as f64).powf(self.overflow_fetch_exponent) as u64; | ||
|
||
// Make sure that we fetch at least the entire desired range | ||
let new_range = | ||
existing_buffer_length..range.end.max(existing_buffer_length + additional_fetch); | ||
let buffer = self.reader.get_metadata_bytes(new_range).await?; | ||
self.buffers.push(buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we request the overflow and add it to the existing buffering (self.buffers.push(buffer)
)
src/reader.rs
Outdated
/// ## Panics | ||
/// | ||
/// If the range does not fall completely within the pre-cached buffers. | ||
fn buffer_slice(&self, range: Range<u64>) -> Bytes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads from the existing buffers, handling a cross-buffer merge in case the input request overlaps multiple of self.buffers
Changes
AsyncFileReader
to use&mut self
instead of&self
on the trait methods. This is necessary so that the buffer can be mutated when fetching the overflow, while also adding it to the cached buffersBox
instead ofArc
in reader code, now that we need mutability of the reader.AsyncFileReader
directly on anything that implementsAsyncRead
andAsyncSeek
. We don't need a wrapper object now that we use&mut self
ourselves.This PR is not made on top of #82, but I think some mix of this and #82 makes sense.