Skip to content

Commit 2bd97c4

Browse files
dannycjonesmansi153
authored andcommitted
Update prefetcher window increment heuristic to move window forward linearly with reads
Signed-off-by: Daniel Carl Jones <[email protected]>
1 parent 1336ee3 commit 2bd97c4

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

mountpoint-s3-fs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Adopt a unified memory pool to reduce overall memory usage. ([#1511](https://github.com/awslabs/mountpoint-s3/pull/1511))
66
* Replace `S3Uri` with `S3Path` and consolidate related types like `Bucket` and `Prefix` into the `s3` module.
77
([#1535](https://github.com/awslabs/mountpoint-s3/pull/1535))
8+
* `PrefetchGetObject` now has an updated backpressure algorithm advancing the read window with each call to `PrefetchGetObject::read`, with the aim of higher sequential-read throughput. ([#1453](https://github.com/awslabs/mountpoint-s3/pull/1453))
89

910
## v0.6.0 (July 23, 2025)
1011

mountpoint-s3-fs/src/prefetch/backpressure_controller.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,40 +126,33 @@ impl BackpressureController {
126126
BackpressureFeedbackEvent::DataRead { offset, length } => {
127127
self.next_read_offset = offset + length as u64;
128128
self.mem_limiter.release(BufferArea::Prefetch, length as u64);
129-
let remaining_window = self.read_window_end_offset.saturating_sub(self.next_read_offset) as usize;
130-
131-
// Increment the read window only if the remaining window reaches some threshold i.e. half of it left.
132-
// When memory is low the `preferred_read_window_size` will be scaled down so we have to keep trying
133-
// until we have enough read window.
134-
while remaining_window < (self.preferred_read_window_size / 2)
135-
&& self.read_window_end_offset < self.request_end_offset
136-
{
129+
130+
loop {
137131
let new_read_window_end_offset = self
138132
.next_read_offset
139133
.saturating_add(self.preferred_read_window_size as u64)
140134
.min(self.request_end_offset);
141-
// We can skip if the new `read_window_end_offset` is less than or equal to the current one, this
142-
// could happen after the read window is scaled down.
143-
if new_read_window_end_offset <= self.read_window_end_offset {
144-
break;
145-
}
146135
let to_increase = new_read_window_end_offset.saturating_sub(self.read_window_end_offset) as usize;
147136

148-
// Force incrementing read window regardless of available memory when we are already at minimum
149-
// read window size.
150-
if self.preferred_read_window_size <= self.min_read_window_size {
151-
self.mem_limiter.reserve(BufferArea::Prefetch, to_increase as u64);
152-
self.increment_read_window(to_increase).await;
137+
if to_increase == 0 {
138+
// There's nothing to increment, just accept the feedback.
139+
// This can happen with random read patterns or prefetcher scale down.
153140
break;
154141
}
155142

156-
// Try to reserve the memory for the length we want to increase before sending the request,
157-
// scale down the read window if it fails.
158-
if self.mem_limiter.try_reserve(BufferArea::Prefetch, to_increase as u64) {
143+
// Force incrementing window regardless of available memory when at minimum window size.
144+
if self.preferred_read_window_size <= self.min_read_window_size {
145+
self.mem_limiter.reserve(BufferArea::Prefetch, to_increase as u64);
159146
self.increment_read_window(to_increase).await;
160147
break;
161148
} else {
162-
self.scale_down();
149+
// Try to reserve memory and inc. read window, otherwise scale down and try again.
150+
if self.mem_limiter.try_reserve(BufferArea::Prefetch, to_increase as u64) {
151+
self.increment_read_window(to_increase).await;
152+
break;
153+
} else {
154+
self.scale_down();
155+
}
163156
}
164157
}
165158
}

mountpoint-s3/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
* Add support for renaming files using the RenameObject API when mounting directory buckets in S3 Express One Zone. ([#1468](https://github.com/awslabs/mountpoint-s3/pull/1468))
1010

11+
### Other changes
12+
13+
* Mountpoint's prefetcher has an updated backpressure algorithm which advances the amount of data prefetched with each read rather than waiting for half of the read window to be consumed. The aim of the change is to achieve higher sequential-read throughput. ([#1453](https://github.com/awslabs/mountpoint-s3/pull/1453))
14+
1115
## v1.18.0 (May 30, 2025)
1216

1317
### New features

0 commit comments

Comments
 (0)