Skip to content
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

Simplified prefetcher api #1988

Merged
merged 5 commits into from Apr 11, 2019

Conversation

marta-lokhova
Copy link
Contributor

@marta-lokhova marta-lokhova commented Mar 2, 2019

Resolves #1859

Take 2 at the prefetcher implementation; this one is a much simpler version that avoids any queueing, and simply prefetches a set of unique keys in batches.

I did some preliminary performance testing, and it looks like on postgres, catchup and applying ledger chain for 2000 ledgers took 175 s with prefetching and 230 without. With 5000 ledgers, same test took 548.59 with prefetching, and 650 s without.

res) {
for (auto const& item : res)
{
putInEntryCache(item.first, item.second, LoadType::PREFETCH);
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this overwrite a LoadType::IMMEDIATE with a LoadType::PREFETCH?

(I doubt it's critical either way, just checking if it's intentional either way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this wouldn't happen since insertIfNotLoaded checks if a key already exists in the cache.

@graydon
Copy link
Contributor

graydon commented Mar 2, 2019

Just a couple nits, otherwise looks good! Thanks for taking a more-minimized go at this, it feels much easier to me to understand/predict how it's going to behave (and glad to hear it still gives some perf wins in this form!)

Copy link
Contributor

@jonjove jonjove left a comment

Choose a reason for hiding this comment

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

Overall, this looks really good and I like the clean and simple approach a lot. Mostly a bunch of minor comments and nitpicks.

src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerTxn.h Outdated Show resolved Hide resolved
@@ -802,7 +804,8 @@ LedgerManagerImpl::closeLedger(LedgerCloseData const& ledgerData)
// sorted such that sequence numbers are respected
vector<TransactionFramePtr> txs = ledgerData.getTxSet()->sortForApply();

// first, charge fees
// first, prefetch source accounts fot txset, then charge fees
prefetchTxSourceIds(txs);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the benefit of prefetching just the transaction source accounts before prefetching everything else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no benefit, but it's mostly to accommodate how mOperations in TransactionFrame is populated. Before fees are processed, mOperations is empty (and is populated via a private resetResults method)

src/main/Config.h Show resolved Hide resolved
src/ledger/LedgerManagerImpl.cpp Outdated Show resolved Hide resolved
src/transactions/ManageOfferOpFrame.cpp Outdated Show resolved Hide resolved
src/transactions/OperationFrame.h Outdated Show resolved Hide resolved
src/transactions/ManageDataOpFrame.cpp Outdated Show resolved Hide resolved
src/transactions/CreateAccountOpFrame.cpp Outdated Show resolved Hide resolved
@marta-lokhova marta-lokhova force-pushed the simplified_prefetcher_api branch 2 times, most recently from f0dd4a6 to c365fb3 Compare March 19, 2019 21:35
src/transactions/ManageOfferOpFrame.cpp Outdated Show resolved Hide resolved
src/transactions/PathPaymentOpFrame.cpp Outdated Show resolved Hide resolved
src/transactions/OperationFrame.h Outdated Show resolved Hide resolved
src/ledger/LedgerManagerImpl.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerTxn.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerManagerImpl.cpp Show resolved Hide resolved
@marta-lokhova marta-lokhova added this to In progress in v11.1.0 via automation Apr 2, 2019
@marta-lokhova marta-lokhova removed this from In progress in v11.1.0 Apr 2, 2019
@marta-lokhova marta-lokhova added this to To do in v11.0.0 via automation Apr 2, 2019
@marta-lokhova
Copy link
Contributor Author

Updated.

Copy link
Contributor

@MonsieurNicolas MonsieurNicolas left a comment

Choose a reason for hiding this comment

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

noticed "one last improvement" to the prefetching API, to avoid churn, and I think it will be good to merge

src/ledger/LedgerManagerImpl.cpp Outdated Show resolved Hide resolved
@MonsieurNicolas
Copy link
Contributor

you also need to rebase

@marta-lokhova
Copy link
Contributor Author

Updated and rebased (most notable change from the rebase is ManageOfferOpFrameBase::insertLedgerKeysToPrefetch to accommodate CAP006 changes)

@MonsieurNicolas
Copy link
Contributor

r+ 9b6f3a9

latobarita added a commit that referenced this pull request Apr 10, 2019
Simplified prefetcher api

Reviewed-by: MonsieurNicolas
@marta-lokhova
Copy link
Contributor Author

need to fix clang-format

@MonsieurNicolas MonsieurNicolas moved this from To do to In progress in v11.0.0 Apr 10, 2019
@marta-lokhova
Copy link
Contributor Author

This is now updated.

@MonsieurNicolas
Copy link
Contributor

r+ 72db3e6

latobarita added a commit that referenced this pull request Apr 11, 2019
Simplified prefetcher api

Reviewed-by: MonsieurNicolas
@latobarita latobarita merged commit 72db3e6 into stellar:master Apr 11, 2019
v11.0.0 automation moved this from In progress to Done Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v11.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

data access: pre-fetching of data
6 participants