Optimize batch-read to avoid wasted disk IO#4741
Conversation
eolivelli
left a comment
There was a problem hiding this comment.
I can't find tests about failure scenarios.
Memory leaks can happen in case of failures (reading from storage...), client may see the wrong error code.....
|
@eolivelli I added 3 tests in BatchedReadEntryProcessorTest, PTAL |
# Conflicts: # bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/DefaultEntryLogger.java
|
@dao-jun Thanks for the optimization. I went through the PR end-to-end — overall the direction is good and the framing-budget contract is clean and consistent across the storage stack. A few things I'd like to discuss before merge. OverallThe core idea is sound: today the batch-read path reads each entry from disk and only then checks whether it fits in The framing budget contract is consistent end-to-end ( Substantive concerns1. Undocumented behavior change in exception handling — } catch (Bookie.NoEntryException e) {
if (data == null) { throw e; }
break;
} catch (Throwable e) {
if (data != null) { data.release(); }
throw e;
}The old code's 2. Stat pollution in When 3. Significant code duplication in
4. The old code did Smaller things5. Inconsistent 6. 7. When VerdictDirection is good, contract is clean, tests are solid. Before merging I'd ask for: (a) the exception-handling behavior change explicitly called out in the PR description, (b) stat recording tightened for size-rejected reads, and (c) the |
|
/bkbot rerun-failure |
|
@merlimat review comment addressed, PTAL |
Motivation
Batch reads currently fetch the next entry before checking whether it can still fit within the maxSize budget. When the last entry in the batch exceeds the remaining space, the read result is discarded, but the disk IO has already happened. This creates wasted IO on the critical read path.
This change avoids that extra read while preserving the existing batch-read behavior, including returning the first entry even when a single entry alone exceeds the requested maxSize.
Changes