dao-jun opened a new pull request, #4741:
URL: https://github.com/apache/bookkeeper/pull/4741

   ### 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
   
     - Add a bounded-read path (readEntryIfFits / getEntryIfFits) through the 
batch-read stack, from BatchedReadEntryProcessor down to Bookie, 
LedgerDescriptor, LedgerStorage, and EntryLogger.
     - Update batch-read logic to:
         - read the first entry as before
         - compute the remaining response budget for subsequent entries
         - stop without reading the next entry when it cannot fit
     - Implement size-aware entry reads in both DefaultEntryLogger and 
DirectEntryLogger by checking entry size from metadata before loading the full 
payload.
     - Wire the bounded-read path through all storage implementations, 
including:
         - InterleavedLedgerStorage
         - SortedLedgerStorage
         - DbLedgerStorage / SingleDirectoryDbLedgerStorage
     - Keep framing semantics consistent by treating the per-entry 4-byte 
delimiter as part of the size budget.
     - Update mock batch-read behavior to match the production semantics.
     - Add regression and boundary tests covering:
         - first entry larger than maxSize
         - exact-fit remaining budget
         - oversized subsequent entries
         - default entry logger and direct entry logger paths
         - interleaved, sorted, and DB ledger storage paths
         - mock and client-facing batch-read behavior
   
   > ---
   > In order to uphold a high standard for quality for code contributions, 
Apache BookKeeper runs various precommit
   > checks for pull requests. A pull request can only be merged when it passes 
precommit checks.
   >
   > ---
   > Be sure to do all the following to help us incorporate your contribution
   > quickly and easily:
   >
   > If this PR is a BookKeeper Proposal (BP):
   >
   > - [ ] Make sure the PR title is formatted like:
   >     `<BP-#>: Description of bookkeeper proposal`
   >     `e.g. BP-1: 64 bits ledger is support`
   > - [ ] Attach the master issue link in the description of this PR.
   > - [ ] Attach the google doc link if the BP is written in Google Doc.
   >
   > Otherwise:
   > 
   > - [ ] Make sure the PR title is formatted like:
   >     `<Issue #>: Description of pull request`
   >     `e.g. Issue 123: Description ...`
   > - [ ] Make sure tests pass via `mvn clean apache-rat:check install 
spotbugs:check`.
   > - [ ] Replace `<Issue #>` in the title with the actual Issue number.
   > 
   > ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to