Delete code to test resolvers' performance, simplify the workload to only test correctness

This commit is contained in:
chaoguang 2020-03-13 01:48:55 -07:00
parent 6f90228a0b
commit 7118759dfa
2 changed files with 27 additions and 67 deletions

View File

@ -31,9 +31,7 @@ struct ReportConflictingKeysWorkload : TestWorkload {
double testDuration, transactionsPerSecond, addReadConflictRangeProb, addWriteConflictRangeProb;
Key keyPrefix;
int nodeCountPerPrefix, actorCount, keyBytes, valueBytes, readConflictRangeCount, writeConflictRangeCount;
bool reportConflictingKeys, skipCorrectnessCheck;
uint64_t keyPrefixBytes, prefixCount;
int nodeCount, actorCount, keyBytes, valueBytes, readConflictRangeCount, writeConflictRangeCount;
PerfIntCounter invalidReports, commits, conflicts, retries, xacts;
@ -41,8 +39,8 @@ struct ReportConflictingKeysWorkload : TestWorkload {
: TestWorkload(wcx), invalidReports("InvalidReports"), conflicts("Conflicts"), retries("Retries"),
commits("Commits"), xacts("Transactions") {
testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0);
transactionsPerSecond = getOption(options, LiteralStringRef("transactionsPerSecond"), 5000.0) / clientCount;
actorCount = getOption(options, LiteralStringRef("actorsPerClient"), transactionsPerSecond / 5);
// transactionsPerSecond = getOption(options, LiteralStringRef("transactionsPerSecond"), 5000.0) / clientCount;
actorCount = getOption(options, LiteralStringRef("actorsPerClient"), 1);
keyPrefix = unprintable(
getOption(options, LiteralStringRef("keyPrefix"), LiteralStringRef("ReportConflictingKeysWorkload"))
.toString());
@ -53,18 +51,8 @@ struct ReportConflictingKeysWorkload : TestWorkload {
// modeled by geometric distribution: (1 - prob) / prob = mean
addReadConflictRangeProb = readConflictRangeCount / (readConflictRangeCount + 1.0);
addWriteConflictRangeProb = writeConflictRangeCount / (writeConflictRangeCount + 1.0);
// If true, store key ranges conflicting with other txs
reportConflictingKeys = getOption(options, LiteralStringRef("reportConflictingKeys"), false);
skipCorrectnessCheck = getOption(options, LiteralStringRef("skipCorrectnessCheck"), false);
// used for generating keyPrefix
keyPrefixBytes = getOption(options, LiteralStringRef("keyPrefixBytes"), 0);
if (keyPrefixBytes) {
prefixCount = 255 * std::round(std::exp2(8 * (keyPrefixBytes - 1)));
ASSERT(keyPrefixBytes + 16 <= keyBytes);
} else {
ASSERT(keyPrefix.size() + 16 <= keyBytes); // make sure the string format is valid
}
nodeCountPerPrefix = getOption(options, LiteralStringRef("nodeCountPerPrefix"), 100);
ASSERT(keyPrefix.size() + 16 <= keyBytes); // make sure the string format is valid
nodeCount = getOption(options, LiteralStringRef("nodeCount"), 100);
}
std::string description() override { return "ReportConflictingKeysWorkload"; }
@ -74,12 +62,8 @@ struct ReportConflictingKeysWorkload : TestWorkload {
Future<Void> start(const Database& cx) override { return _start(cx->clone(), this); }
ACTOR Future<Void> _start(Database cx, ReportConflictingKeysWorkload* self) {
std::vector<Future<Void>> clients;
for (int c = 0; c < self->actorCount; ++c) {
clients.push_back(self->conflictingClient(cx, self, self->actorCount / self->transactionsPerSecond, c));
}
wait(timeout(waitForAll(clients), self->testDuration, Void()));
if (self->clientId == 0)
wait(timeout(self->conflictingClient(cx, self), self->testDuration, Void()));
return Void();
}
@ -101,68 +85,48 @@ struct ReportConflictingKeysWorkload : TestWorkload {
double getCheckTimeout() override { return std::numeric_limits<double>::max(); }
// Copied from tester.actor.cpp, added parameter to determine the key's length
Key keyForIndex(int prefixIdx, int n) {
double p = (double)n / nodeCountPerPrefix;
int paddingLen = keyBytes - 16 - keyPrefixBytes;
Key keyForIndex(int n) {
double p = (double)n / nodeCount;
int paddingLen = keyBytes - 16 - keyPrefix.size();
// left padding by zero
return StringRef(format("%0*llx", paddingLen, *(uint64_t*)&p))
.withPrefix(prefixIdx >= 0 ? keyPrefixForIndex(prefixIdx) : keyPrefix);
}
Key keyPrefixForIndex(uint64_t n) {
Key prefix = makeString(keyPrefixBytes);
uint8_t* head = mutateString(prefix);
memset(head, 0, keyPrefixBytes);
int offset = keyPrefixBytes - 1;
while (n) {
*(head + offset) = static_cast<uint8_t>(n % 256);
n /= 256;
offset -= 1;
}
return prefix;
.withPrefix(keyPrefix);
}
void addRandomReadConflictRange(ReadYourWritesTransaction* tr, std::vector<KeyRange>& readConflictRanges) {
int startIdx, endIdx, startPrefixIdx, endPrefixIdx;
int startIdx, endIdx;
Key startKey, endKey;
while (deterministicRandom()->random01() < addReadConflictRangeProb) {
startPrefixIdx = keyPrefixBytes ? deterministicRandom()->randomInt(0, prefixCount) : -1;
endPrefixIdx = keyPrefixBytes ? deterministicRandom()->randomInt(startPrefixIdx, prefixCount) : -1;
startIdx = deterministicRandom()->randomInt(0, nodeCountPerPrefix);
endIdx = deterministicRandom()->randomInt(startPrefixIdx < endPrefixIdx ? 0 : startIdx, nodeCountPerPrefix);
startKey = keyForIndex(startPrefixIdx, startIdx);
endKey = keyForIndex(endPrefixIdx, endIdx);
startIdx = deterministicRandom()->randomInt(0, nodeCount);
endIdx = deterministicRandom()->randomInt(startIdx, nodeCount);
startKey = keyForIndex(startIdx);
endKey = keyForIndex(endIdx);
tr->addReadConflictRange(KeyRangeRef(startKey, endKey));
readConflictRanges.push_back(KeyRangeRef(startKey, endKey));
}
}
void addRandomWriteConflictRange(ReadYourWritesTransaction* tr) {
int startIdx, endIdx, startPrefixIdx, endPrefixIdx;
int startIdx, endIdx;
Key startKey, endKey;
while (deterministicRandom()->random01() < addWriteConflictRangeProb) {
startPrefixIdx = keyPrefixBytes ? deterministicRandom()->randomInt(0, prefixCount) : -1;
endPrefixIdx = keyPrefixBytes ? deterministicRandom()->randomInt(startPrefixIdx, prefixCount) : -1;
startIdx = deterministicRandom()->randomInt(0, nodeCountPerPrefix);
endIdx = deterministicRandom()->randomInt(startPrefixIdx < endPrefixIdx ? 0 : startIdx, nodeCountPerPrefix);
startKey = keyForIndex(startPrefixIdx, startIdx);
endKey = keyForIndex(endPrefixIdx, endIdx);
startIdx = deterministicRandom()->randomInt(0, nodeCount);
endIdx = deterministicRandom()->randomInt(startIdx, nodeCount);
startKey = keyForIndex(startIdx);
endKey = keyForIndex(endIdx);
tr->addWriteConflictRange(KeyRangeRef(startKey, endKey));
}
}
ACTOR Future<Void> conflictingClient(Database cx, ReportConflictingKeysWorkload* self, double delay,
int actorIndex) {
ACTOR Future<Void> conflictingClient(Database cx, ReportConflictingKeysWorkload* self) {
state ReadYourWritesTransaction tr(cx);
state double lastTime = now();
state ReadYourWritesTransaction tr2(cx);
state std::vector<KeyRange> readConflictRanges;
loop {
try {
// used for throttling
wait(poisson(&lastTime, delay));
if (self->reportConflictingKeys) tr.setOption(FDBTransactionOptions::REPORT_CONFLICTING_KEYS);
tr.setOption(FDBTransactionOptions::REPORT_CONFLICTING_KEYS);
// If READ_YOUR_WRITES_DISABLE set, it behaves like native transaction object
// where overlapped conflict ranges are not merged.
if (deterministicRandom()->random01() < 0.5)
@ -183,7 +147,7 @@ struct ReportConflictingKeysWorkload : TestWorkload {
}
wait(tr.onError(e));
// check API correctness
if (!self->skipCorrectnessCheck && self->reportConflictingKeys && isConflict) {
if (isConflict) {
// \xff\xff/transaction/conflicting_keys is always false, we skip it here for simplicity
state KeyRange ckr = KeyRangeRef(keyAfter(LiteralStringRef("").withPrefix(conflictingKeysAbsolutePrefix)),
LiteralStringRef("\xff\xff").withPrefix(conflictingKeysAbsolutePrefix));

View File

@ -1,12 +1,8 @@
testTitle=ReportConflictingKeysTest
testName=ReportConflictingKeys
testDuration=10.0
transactionsPerSecond=100000
nodeCountPerPrefix=10000
actorsPerClient=256
nodeCount=10000
keyPrefix=RCK
keyBytes=64
readConflictRangeCountPerTx=1
writeConflictRangeCountPerTx=1
reportConflictingKeys=true
skipCorrectnessCheck=false
writeConflictRangeCountPerTx=1