Skip to content

DbLedgerStorage -- ReadCache#843

Closed
merlimat wants to merge 2 commits into
apache:masterfrom
merlimat:read-cache
Closed

DbLedgerStorage -- ReadCache#843
merlimat wants to merge 2 commits into
apache:masterfrom
merlimat:read-cache

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Adds a ReadCache class 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.

Copy link
Copy Markdown
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: final

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I thought it was being reassigned but it's not.

@merlimat
Copy link
Copy Markdown
Contributor Author

one question: I think this ReadCache is general can be shared with different ledger storage implementations, right?

Yes, same for WriteCache or even for KeyValueStorage if that's needed in any other component.

@sijie
Copy link
Copy Markdown
Member

sijie commented Dec 13, 2017

@merlimat we can consider sharing the components with other implementations once the db ledger storage change is merged.

@sijie
Copy link
Copy Markdown
Member

sijie commented Dec 13, 2017

merging this now to unblock subsequent db ledger storage changes.

@sijie sijie closed this in e87bf7c Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants