Skip to content

Commit 002893f

Browse files
authored
Apply transaction batches in periodic intervals (XRPLF#4504)
Add new transaction submission API field, "sync", which determines behavior of the server while submitting transactions: 1) sync (default): Process transactions in a batch immediately, and return only once the transaction has been processed. 2) async: Put transaction into the batch for the next processing interval and return immediately. 3) wait: Put transaction into the batch for the next processing interval and return only after it is processed.
1 parent 1d9db1b commit 002893f

24 files changed

+398
-163
lines changed

Builds/CMake/RippledCore.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ install (
199199
src/ripple/basics/StringUtilities.h
200200
src/ripple/basics/TaggedCache.h
201201
src/ripple/basics/tagged_integer.h
202+
src/ripple/basics/SubmitSync.h
202203
src/ripple/basics/ThreadSafetyAnalysis.h
203204
src/ripple/basics/ThreadUtilities.h
204205
src/ripple/basics/ToString.h

cfg/rippled-example.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@
480480
#
481481
# Configure the maximum number of transactions to have in the job queue
482482
#
483-
# Must be a number between 100 and 1000, defaults to 250
483+
# Must be a number between 1000 and 100000, defaults to 10000
484484
#
485485
#
486486
# [overlay]

cfg/rippled-reporting.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@
467467
#
468468
# Configure the maximum number of transactions to have in the job queue
469469
#
470-
# Must be a number between 100 and 1000, defaults to 250
470+
# Must be a number between 1000 and 100000, defaults to 10000
471471
#
472472
#
473473
# [overlay]

src/ripple/app/ledger/impl/LedgerMaster.cpp

+18-15
Original file line numberDiff line numberDiff line change
@@ -549,22 +549,25 @@ void
549549
LedgerMaster::applyHeldTransactions()
550550
{
551551
std::lock_guard sl(m_mutex);
552+
// It can be expensive to modify the open ledger even with no transactions
553+
// to process. Regardless, make sure to reset held transactions with
554+
// the parent.
555+
if (mHeldTransactions.size())
556+
{
557+
app_.openLedger().modify([&](OpenView& view, beast::Journal j) {
558+
bool any = false;
559+
for (auto const& it : mHeldTransactions)
560+
{
561+
ApplyFlags flags = tapNONE;
562+
auto const result =
563+
app_.getTxQ().apply(app_, view, it.second, flags, j);
564+
if (result.second)
565+
any = true;
566+
}
567+
return any;
568+
});
569+
}
552570

553-
app_.openLedger().modify([&](OpenView& view, beast::Journal j) {
554-
bool any = false;
555-
for (auto const& it : mHeldTransactions)
556-
{
557-
ApplyFlags flags = tapNONE;
558-
auto const result =
559-
app_.getTxQ().apply(app_, view, it.second, flags, j);
560-
if (result.second)
561-
any = true;
562-
}
563-
return any;
564-
});
565-
566-
// VFALCO TODO recreate the CanonicalTxSet object instead of resetting
567-
// it.
568571
// VFALCO NOTE The hash for an open ledger is undefined so we use
569572
// something that is a reasonable substitute.
570573
mHeldTransactions.reset(app_.openLedger().current()->info().parentHash);

src/ripple/app/main/Application.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,7 @@ ApplicationImp::start(bool withTimers)
15271527
{
15281528
setSweepTimer();
15291529
setEntropyTimer();
1530+
m_networkOPs->setBatchApplyTimer();
15301531
}
15311532

15321533
m_io_latency_sampler.start();

0 commit comments

Comments
 (0)