-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[TIEREDSTORAGE] Only seek when reading unexpected entry #5356
Conversation
The normal pattern from reading from an offloaded ledger is that the reader will read the ledger sequentially from start to end. This means that once a user reads an entry, we should expect that the next entry they read will be the next entry in the ledger. The initial implementation of the BlobStoreBackedReadHandleImpl (and the S3 variant that preceeded it) didn't take this into account. Instead it did a lookup in the index each time, to find the block that contained the entry, and then read forward in the block until it found the entry requested. This is fine for the first few entries in the block, not so much for the last. This PR changes the read behaviour to only seek if entryId read from the block is either: - greater than the entry we were expecting to read, in which case we need to seek backwards in the block. - less than the entry expected, but also belonging to a different block to the expected entry, in which case we need to seek to the correct block. This change improves read performance significantly. Adhoc benchmarks shows that we can read from offloaded topics at ~160MB/s whereas previously we could only manage <10MB/s.
@@ -116,7 +116,7 @@ public int read(byte[] b, int off, int len) throws IOException { | |||
|
|||
@Override | |||
public void seek(long position) { | |||
log.debug("Seeking to {} on {}/{}, current position {}", position, bucket, key, cursor); | |||
log.info("Seeking to {} on {}/{}, current position {} (bufStart:{}, bufEnd:{})", position, bucket, key, cursor, bufferOffsetStart, bufferOffsetEnd); |
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.
Can this be annoying?
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.
ah yes, should be debug
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.
@ivankelly can you change it to debug please?
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.
@ivankelly This is a very important change we are rooting for in 2.4.2. Merging this would be great.
@ivankelly can you address the comments |
I reverted |
run cpp tests |
* [TIEREDSTORAGE] Only seek when reading unexpected entry The normal pattern from reading from an offloaded ledger is that the reader will read the ledger sequentially from start to end. This means that once a user reads an entry, we should expect that the next entry they read will be the next entry in the ledger. The initial implementation of the BlobStoreBackedReadHandleImpl (and the S3 variant that preceeded it) didn't take this into account. Instead it did a lookup in the index each time, to find the block that contained the entry, and then read forward in the block until it found the entry requested. This is fine for the first few entries in the block, not so much for the last. This PR changes the read behaviour to only seek if entryId read from the block is either: - greater than the entry we were expecting to read, in which case we need to seek backwards in the block. - less than the entry expected, but also belonging to a different block to the expected entry, in which case we need to seek to the correct block. This change improves read performance significantly. Adhoc benchmarks shows that we can read from offloaded topics at ~160MB/s whereas previously we could only manage <10MB/s. * Revert it back to debug
1. PR 4196 (2019/5/29 Merli) Configure static PulsarByteBufAllocator to handle OOM errors (apache#4196) 2. PR 5356 (2019/10/30 Kelly) [TIEREDSTORAGE] Only seek when reading unexpected entry (apache#5356) 3. PR 4433 (2019/6/4 Higham) [tiered-storage] Add support for AWS instance and role creds (apache#4433)
1. PR 4196 (2019/5/29 Merli) Configure static PulsarByteBufAllocator to handle OOM errors (apache#4196) 2. PR 5356 (2019/10/30 Kelly) [TIEREDSTORAGE] Only seek when reading unexpected entry (apache#5356) 3. PR 4433 (2019/6/4 Higham) [tiered-storage] Add support for AWS instance and role creds (apache#4433)
# Motivation The PR #6335 lost some PR changes, related PRs as below. 1. PR 4196 (2019/5/29 Merli) Configure static PulsarByteBufAllocator to handle OOM errors (#4196) 2. PR 5356 (2019/10/30 Kelly) [TIEREDSTORAGE] Only seek when reading unexpected entry (#5356) 3. PR 4433 (2019/6/4 Higham) [tiered-storage] Add support for AWS instance and role creds (#4433)
# Motivation The PR #6335 lost some PR changes, related PRs as below. 1. PR 4196 (2019/5/29 Merli) Configure static PulsarByteBufAllocator to handle OOM errors (#4196) 2. PR 5356 (2019/10/30 Kelly) [TIEREDSTORAGE] Only seek when reading unexpected entry (#5356) 3. PR 4433 (2019/6/4 Higham) [tiered-storage] Add support for AWS instance and role creds (#4433) (cherry picked from commit 68759ff)
…ache#8630) # Motivation The PR apache#6335 lost some PR changes, related PRs as below. 1. PR 4196 (2019/5/29 Merli) Configure static PulsarByteBufAllocator to handle OOM errors (#4196) 2. PR 5356 (2019/10/30 Kelly) [TIEREDSTORAGE] Only seek when reading unexpected entry (#5356) 3. PR 4433 (2019/6/4 Higham) [tiered-storage] Add support for AWS instance and role creds (#4433) (cherry picked from commit 68759ff) (cherry picked from commit 8793963)
…ache#8630) # Motivation The PR apache#6335 lost some PR changes, related PRs as below. 1. PR 4196 (2019/5/29 Merli) Configure static PulsarByteBufAllocator to handle OOM errors (#4196) 2. PR 5356 (2019/10/30 Kelly) [TIEREDSTORAGE] Only seek when reading unexpected entry (#5356) 3. PR 4433 (2019/6/4 Higham) [tiered-storage] Add support for AWS instance and role creds (#4433) (cherry picked from commit 68759ff) (cherry picked from commit 8793963) (cherry picked from commit 0388a1a)
The normal pattern from reading from an offloaded ledger is that the
reader will read the ledger sequentially from start to end. This means
that once a user reads an entry, we should expect that the next entry
they read will be the next entry in the ledger.
The initial implementation of the BlobStoreBackedReadHandleImpl (and
the S3 variant that preceeded it) didn't take this into
account. Instead it did a lookup in the index each time, to find the
block that contained the entry, and then read forward in the block
until it found the entry requested. This is fine for the first few
entries in the block, not so much for the last.
This PR changes the read behaviour to only seek if entryId read
from the block is either:
need to seek backwards in the block.
block to the expected entry, in which case we need to seek to the
correct block.
This change improves read performance significantly. Adhoc benchmarks
shows that we can read from offloaded topics at ~160MB/s whereas
previously we could only manage <10MB/s.