Introduce partitioned unordered maps:

This commit implements partitioned unordered maps and makes it possible
to traverse such a map in parallel, allowing for more efficient use of
CPU resources.

The `CachedSLEs`, `TaggedCache`, and `KeyCache` classes make use of the
new functionality, which should improve performance.
This commit is contained in:
Mark Travis
2021-09-17 15:48:33 -07:00
committed by seelabs
parent 7edfbbd8bd
commit 19018e8959
26 changed files with 1089 additions and 770 deletions

View File

@@ -21,9 +21,9 @@
#include <ripple/beast/clock/manual_clock.h>
#include <ripple/beast/unit_test.h>
#include <ripple/consensus/Validations.h>
#include <test/csf/Validation.h>
#include <memory>
#include <test/csf/Validation.h>
#include <test/unit_test/SuiteJournal.h>
#include <tuple>
#include <type_traits>
#include <vector>
@@ -703,6 +703,7 @@ class Validations_test : public beast::unit_test::suite
{
// Verify expiring clears out validations stored by ledger
testcase("Expire validations");
SuiteJournal j("Validations_test", *this);
LedgerHistoryHelper h;
TestHarness harness(h.oracle);
Node const a = harness.makeNode();
@@ -713,10 +714,10 @@ class Validations_test : public beast::unit_test::suite
Ledger const ledgerA = h["a"];
BEAST_EXPECT(ValStatus::current == harness.add(a.validate(ledgerA)));
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerA.id()) == 1);
harness.vals().expire();
harness.vals().expire(j);
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerA.id()) == 1);
harness.clock().advance(harness.parms().validationSET_EXPIRES);
harness.vals().expire();
harness.vals().expire(j);
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerA.id()) == 0);
// use setSeqToKeep to keep the validation from expire
@@ -725,7 +726,7 @@ class Validations_test : public beast::unit_test::suite
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerB.id()) == 1);
harness.vals().setSeqToKeep(ledgerB.seq(), ledgerB.seq() + one);
harness.clock().advance(harness.parms().validationSET_EXPIRES);
harness.vals().expire();
harness.vals().expire(j);
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerB.id()) == 1);
// change toKeep
harness.vals().setSeqToKeep(ledgerB.seq() + one, ledgerB.seq() + two);
@@ -736,7 +737,7 @@ class Validations_test : public beast::unit_test::suite
for (int i = 0; i < loops; ++i)
{
harness.clock().advance(harness.parms().validationFRESHNESS);
harness.vals().expire();
harness.vals().expire(j);
}
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerB.id()) == 0);
@@ -746,7 +747,7 @@ class Validations_test : public beast::unit_test::suite
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerC.id()) == 1);
harness.vals().setSeqToKeep(ledgerC.seq() - one, ledgerC.seq());
harness.clock().advance(harness.parms().validationSET_EXPIRES);
harness.vals().expire();
harness.vals().expire(j);
BEAST_EXPECT(harness.vals().numTrustedForLedger(ledgerC.id()) == 0);
}