Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces read amplification for lagging consumers by choosing the byte-range strategy during planning: hot-path requests remain block-aligned for cache efficiency, while cold-path requests bypass cache and fetch coalesced exact ranges.
Changes:
- Update
FetchPlannerto select aligned vs coalesced ranges based on lagging/hot determination during planning. - Add
ByteRange.coalesce()to merge overlapping/adjacent ranges into a minimal set. - Extend unit tests to validate cold-path planning behavior and
ByteRange.coalesce()semantics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
storage/inkless/src/main/java/io/aiven/inkless/consume/FetchPlanner.java |
Chooses coalescing vs alignment during planning and extracts isLagging() helper used by both planning and submission. |
storage/inkless/src/main/java/io/aiven/inkless/common/ByteRange.java |
Adds coalesce(List<ByteRange>) utility to merge overlapping/adjacent ranges. |
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java |
Adds planning-focused tests to ensure cold path uses exact/coalesced ranges and hot path stays aligned. |
storage/inkless/src/test/java/io/aiven/inkless/common/ByteRangeTest.java |
Adds test coverage for ByteRange.coalesce() behavior across overlap/adjacency/ordering cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
storage/inkless/src/main/java/io/aiven/inkless/consume/FetchPlanner.java
Show resolved
Hide resolved
storage/inkless/src/test/java/io/aiven/inkless/consume/FetchPlannerTest.java
Outdated
Show resolved
Hide resolved
storage/inkless/src/test/java/io/aiven/inkless/common/ByteRangeTest.java
Outdated
Show resolved
Hide resolved
storage/inkless/src/test/java/io/aiven/inkless/common/ByteRangeTest.java
Outdated
Show resolved
Hide resolved
28f05c8 to
a5ecdf7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
storage/inkless/src/main/java/io/aiven/inkless/common/ByteRange.java
Outdated
Show resolved
Hide resolved
a5ecdf7 to
583b55a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
583b55a to
2019a0b
Compare
| * @param ranges the byte ranges to coalesce (may be null or empty) | ||
| * @return an unmodifiable set of merged, non-overlapping byte ranges in offset order | ||
| */ | ||
| public static Set<ByteRange> coalesce(List<ByteRange> ranges) { |
There was a problem hiding this comment.
This is the signature of KeyAlignment, which makes me think this is inappropriate complexity to add as a static method.
| // Overlapping or adjacent — extend | ||
| currentEnd = Math.max(currentEnd, nextEnd); | ||
| } else { | ||
| // Gap — emit current and start new |
There was a problem hiding this comment.
If there are gaps, they are expected to be small, and making multiple requests to skip around that gap would be worse than just throwing around the data.
This routine shouldn't do this sort/match end-to-end algorithm, it should compute the minimum start and maximum end offset.
There was a problem hiding this comment.
Good call! I have updated the implementation to go along this approach. PTAL
2019a0b to
f716ab6
Compare
f716ab6 to
d709c1b
Compare
storage/inkless/src/main/java/io/aiven/inkless/cache/BoundingRangeAlignment.java
Outdated
Show resolved
Hide resolved
storage/inkless/src/test/java/io/aiven/inkless/cache/BoundingRangeAlignmentTest.java
Outdated
Show resolved
Hide resolved
…ngeAlignment strategy Reuse KeyAlignmentStrategy interface for cold-path range computation instead of a static method on ByteRange. One bounding range per object minimizes HTTP requests at the cost of reading small interleaved gaps.
d709c1b to
83f2f9f
Compare
…ngeAlignment strategy (#532) Reuse KeyAlignmentStrategy interface for cold-path range computation instead of a static method on ByteRange. One bounding range per object minimizes HTTP requests at the cost of reading small interleaved gaps.
to reduce read amplification
FetchPlanner.createFetchRequests() unconditionally aligned all byte ranges to fixed blocks (e.g. 16 MiB) before the hot/cold path decision. For the cold path, the cache is bypassed entirely, so alignment padding is pure read amplification with zero benefit — a 10 KB batch could trigger a 16 MiB fetch.
Move the hot/cold determination into the planning phase so that:
Add ByteRange.coalesce() to merge overlapping/adjacent ranges, and extract isLagging() helper to deduplicate the threshold check between createFetchRequests() and submitSingleRequest().