Skip to content

Commit

Permalink
Apply transaction batches in periodic intervals. (XRPLF#4504)
Browse files Browse the repository at this point in the history
Add new transaction submission API field, "sync", which
determines behavior of the server while submitting transactions:
 - sync (default): Process transactions in a batch immediately,
   and return only once the transaction has been processed.
 - async: Put transaction into the batch for the next processing
   interval and return immediately.
 - wait: Put transaction into the batch for the next processing
   interval and return only after it is processed.

Signed-off-by: Manoj Doshi <[email protected]>
  • Loading branch information
mtrippled authored and manojsdoshi committed Aug 18, 2023
1 parent 7add3ab commit e9eb813
Show file tree
Hide file tree
Showing 24 changed files with 398 additions and 163 deletions.
1 change: 1 addition & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ install (
src/ripple/basics/StringUtilities.h
src/ripple/basics/TaggedCache.h
src/ripple/basics/tagged_integer.h
src/ripple/basics/SubmitSync.h
src/ripple/basics/ThreadSafetyAnalysis.h
src/ripple/basics/ToString.h
src/ripple/basics/UnorderedContainers.h
Expand Down
2 changes: 1 addition & 1 deletion cfg/rippled-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
#
# Configure the maximum number of transactions to have in the job queue
#
# Must be a number between 100 and 1000, defaults to 250
# Must be a number between 1000 and 100000, defaults to 10000
#
#
# [overlay]
Expand Down
2 changes: 1 addition & 1 deletion cfg/rippled-reporting.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
#
# Configure the maximum number of transactions to have in the job queue
#
# Must be a number between 100 and 1000, defaults to 250
# Must be a number between 1000 and 100000, defaults to 10000
#
#
# [overlay]
Expand Down
33 changes: 18 additions & 15 deletions src/ripple/app/ledger/impl/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,22 +549,25 @@ void
LedgerMaster::applyHeldTransactions()
{
std::lock_guard sl(m_mutex);
// It can be expensive to modify the open ledger even with no transactions
// to process. Regardless, make sure to reset held transactions with
// the parent.
if (mHeldTransactions.size())
{
app_.openLedger().modify([&](OpenView& view, beast::Journal j) {
bool any = false;
for (auto const& it : mHeldTransactions)
{
ApplyFlags flags = tapNONE;
auto const result =
app_.getTxQ().apply(app_, view, it.second, flags, j);
if (result.second)
any = true;
}
return any;
});
}

app_.openLedger().modify([&](OpenView& view, beast::Journal j) {
bool any = false;
for (auto const& it : mHeldTransactions)
{
ApplyFlags flags = tapNONE;
auto const result =
app_.getTxQ().apply(app_, view, it.second, flags, j);
if (result.second)
any = true;
}
return any;
});

// VFALCO TODO recreate the CanonicalTxSet object instead of resetting
// it.
// VFALCO NOTE The hash for an open ledger is undefined so we use
// something that is a reasonable substitute.
mHeldTransactions.reset(app_.openLedger().current()->info().parentHash);
Expand Down
1 change: 1 addition & 0 deletions src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ ApplicationImp::start(bool withTimers)
{
setSweepTimer();
setEntropyTimer();
m_networkOPs->setBatchApplyTimer();
}

m_io_latency_sampler.start();
Expand Down
Loading

0 comments on commit e9eb813

Please sign in to comment.