Merge pull request #9795 from sfc-gh-ajbeamon/speed-up-storefront

Speed up the storefront tests
This commit is contained in:
Jingyu Zhou 2023-03-27 17:10:21 -07:00 committed by GitHub
commit d719155462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 69 deletions

View File

@ -33,7 +33,7 @@ typedef uint64_t orderID;
struct StorefrontWorkload : TestWorkload {
static constexpr auto NAME = "Storefront";
double testDuration, transactionsPerSecond, minExpectedTransactionsPerSecond;
double testDuration, transactionsPerSecond;
int actorCount, itemCount, maxOrderSize;
// bool isFulfilling;
@ -50,7 +50,6 @@ struct StorefrontWorkload : TestWorkload {
actorCount = getOption(options, "actorsPerClient"_sr, std::max((int)(transactionsPerSecond / 100), 1));
maxOrderSize = getOption(options, "maxOrderSize"_sr, 20);
itemCount = getOption(options, "itemCount"_sr, transactionsPerSecond * clientCount * maxOrderSize);
minExpectedTransactionsPerSecond = transactionsPerSecond * getOption(options, "expectedRate"_sr, 0.9);
}
Future<Void> setup(Database const& cx) override { return bulkSetup(cx, this, itemCount, Promise<double>()); }
@ -175,61 +174,6 @@ struct StorefrontWorkload : TestWorkload {
}
}
ACTOR Future<std::vector<int>> orderAccumulator(Database cx, StorefrontWorkload* self, KeyRangeRef keyRange) {
state std::vector<int> result(self->itemCount);
state Transaction tr(cx);
state int fetched = 10000;
state KeySelectorRef begin = firstGreaterThan(keyRange.begin);
state KeySelectorRef end = lastLessThan(keyRange.end);
while (fetched == 10000) {
RangeResult values = wait(tr.getRange(begin, end, 10000));
int orderIdx;
for (orderIdx = 0; orderIdx < values.size(); orderIdx++) {
std::vector<int> saved;
BinaryReader br(values[orderIdx].value, AssumeVersion(g_network->protocolVersion()));
br >> saved;
for (int c = 0; c < saved.size(); c++)
result[saved[c]]++;
}
fetched = values.size();
begin = begin + fetched;
}
return result;
}
ACTOR Future<bool> tableBalancer(Database cx, StorefrontWorkload* self, KeyRangeRef keyRange) {
state std::vector<Future<std::vector<int>>> accumulators;
accumulators.push_back(self->orderAccumulator(cx, self, KeyRangeRef("/orders/f"_sr, "/orders0"_sr)));
for (int c = 0; c < 15; c++)
accumulators.push_back(self->orderAccumulator(
cx, self, KeyRangeRef(Key(format("/orders/%x", c)), Key(format("/orders/%x", c + 1)))));
Transaction tr(cx);
state Future<RangeResult> values =
tr.getRange(KeyRangeRef(self->itemKey(0), self->itemKey(self->itemCount)), self->itemCount + 1);
wait(waitForAll(accumulators));
state std::vector<int> totals(self->itemCount);
for (int c = 0; c < accumulators.size(); c++) {
std::vector<int> subTotals = accumulators[c].get();
for (int i = 0; i < subTotals.size(); i++)
totals[i] += subTotals[i];
}
RangeResult inventory = wait(values);
for (int c = 0; c < inventory.size(); c++) {
if (self->valueToInt(inventory[c].value) != totals[c]) {
TraceEvent(SevError, "TestFailure")
.detail("Reason", "OrderTotalMismatch")
.detail("Item", c)
.detail("OrderTotal", totals[c])
.detail("RecordedInventory", self->valueToInt(inventory[c].value));
return false;
}
}
return true;
}
ACTOR Future<bool> orderChecker(Database cx, StorefrontWorkload* self, std::vector<orderID> ids) {
state Transaction tr(cx);
state int idx = 0;

View File

@ -1,8 +1,9 @@
testTitle=StorefrontTest
clearAfterTest=false
testName=Storefront
actorsPerClient=50
itemCount=100000
actorsPerClient=20
transactionsPerSecond=200
itemCount=20000
maxOrderSize=4
testName=SaveAndKill
restartInfoLocation=simfdb/restartInfo.ini

View File

@ -1,6 +1,7 @@
testTitle=StorefrontTest
runSetup=false
testName=Storefront
actorsPerClient=50
itemCount=100000
actorsPerClient=20
transactionsPerSecond=200
itemCount=20000
maxOrderSize=4

View File

@ -2,8 +2,9 @@ storageEngineExcludeTypes=3
testTitle=StorefrontTest
clearAfterTest=false
testName=Storefront
actorsPerClient=50
itemCount=100000
actorsPerClient=20
transactionsPerSecond=200
itemCount=20000
maxOrderSize=4
testName=SaveAndKill
restartInfoLocation=simfdb/restartInfo.ini

View File

@ -1,6 +1,7 @@
testTitle=StorefrontTest
runSetup=false
testName=Storefront
actorsPerClient=50
itemCount=100000
actorsPerClient=20
transactionsPerSecond=200
itemCount=20000
maxOrderSize=4

View File

@ -3,8 +3,9 @@ testTitle = 'CloggedStorefrontTest'
[[test.workload]]
testName = 'Storefront'
actorsPerClient = 50
itemCount = 100000
actorsPerClient = 20
transactionsPerSecond = 200
itemCount = 20000
maxOrderSize = 6
testDuration = 30.0

View File

@ -3,6 +3,7 @@ testTitle = 'StorefrontTest'
[[test.workload]]
testName = 'Storefront'
actorsPerClient = 50
itemCount = 100000
actorsPerClient = 20
transactionsPerSecond = 200
itemCount = 20000
maxOrderSize = 4