DbLedgerStorage -- ReadCache#843
Closed
merlimat wants to merge 2 commits into
Closed
Conversation
sijie
approved these changes
Dec 13, 2017
Member
sijie
left a comment
There was a problem hiding this comment.
LGTM +1
one question: I think this ReadCache is general can be shared with different ledger storage implementations, right?
| private final List<ConcurrentLongLongPairHashMap> cacheIndexes; | ||
|
|
||
| private int currentSegmentIdx; | ||
| private AtomicInteger currentSegmentOffset = new AtomicInteger(0); |
Contributor
Author
There was a problem hiding this comment.
yes, I thought it was being reassigned but it's not.
Contributor
Author
Yes, same for |
Member
|
@merlimat we can consider sharing the components with other implementations once the db ledger storage change is merged. |
Member
|
merging this now to unblock subsequent db ledger storage changes. |
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.
Adds a
ReadCacheclass to be used from LedgerStorage.The read cache is used when doing read-ahead caching after reading one entry.
The idea is that entries for the same ledger as stored in order (for each flush cycle, eg: 1min). When reading 1 entry, we expect the client to read all subsequent entries. We can then skip the RocksDb
get()to fetch the index of the entries, by just keep reading from the entryLog, and exploiting page cache and seqeuential reads. The entries are then added to this ReadCache, where they will looked when the request for next entry comes in.This implementation is based on dividing the memory into multiple segments. Whenever the read cache is full, the oldest segment gets recycled and overwritten with new entries.