Repository navigation
[TIEREDSTORAGE] Only seek when reading unexpected entry - #5356
Merged
Merged
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.
sijie
requested changes
Oct 10, 2019
| @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); |
Contributor
Author
There was a problem hiding this comment.
ah yes, should be debug
Contributor
There was a problem hiding this comment.
@ivankelly This is a very important change we are rooting for in 2.4.2. Merging this would be great.
merlimat
approved these changes
Oct 10, 2019
Contributor
|
@ivankelly can you address the comments |
sijie
approved these changes
Oct 24, 2019
Member
|
I reverted |
Member
|
run cpp tests |
jerrypeng
pushed a commit
to jerrypeng/incubator-pulsar
that referenced
this pull request
Dec 17, 2019
* [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
codelipenghui
pushed a commit
that referenced
this pull request
Nov 21, 2020
# 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)
codelipenghui
pushed a commit
that referenced
this pull request
Nov 21, 2020
# 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)
codelipenghui
referenced
this pull request
in streamnative/pulsar-archived
Nov 21, 2020
…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)
codelipenghui
referenced
this pull request
in streamnative/pulsar-archived
Nov 21, 2020
…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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.