MCPcopy Create free account
hub / github.com/apple/foundationdb / WriteDuringReadWorkload

Class WriteDuringReadWorkload

fdbserver/workloads/WriteDuringRead.actor.cpp:33–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include "flow/actorcompiler.h" // This must be the last #include.
32
33struct WriteDuringReadWorkload : TestWorkload {
34 double testDuration, slowModeStart;
35 int numOps;
36 bool rarelyCommit, adjacentKeys;
37 PerfIntCounter transactions, retries;
38 std::map<Key, Value> memoryDatabase;
39 std::map<Key, Value> lastCommittedDatabase;
40 KeyRangeMap<int> changeCount;
41 int minNode, nodes;
42 double initialKeyDensity;
43 AsyncTrigger finished;
44 KeyRange conflictRange;
45 std::pair<int, int> valueSizeRange;
46 int maxClearSize;
47 CoalescedKeyRangeMap<bool> addedConflicts;
48 bool useSystemKeys;
49 std::string keyPrefix;
50 int64_t maximumTotalData;
51 int64_t maximumDataWritten;
52
53 int64_t dataWritten = 0;
54
55 bool success;
56 Database extraDB;
57 bool useExtraDB;
58
59 WriteDuringReadWorkload(WorkloadContext const& wcx)
60 : TestWorkload(wcx), transactions("Transactions"), retries("Retries"), success(true) {
61 testDuration = getOption(options, LiteralStringRef("testDuration"), 60.0);
62 slowModeStart = getOption(options, LiteralStringRef("slowModeStart"), 1000.0);
63 numOps = getOption(options, LiteralStringRef("numOps"), 21);
64 rarelyCommit = getOption(options, LiteralStringRef("rarelyCommit"), false);
65 maximumTotalData = getOption(options, LiteralStringRef("maximumTotalData"), 3e6);
66 maximumDataWritten =
67 getOption(options, LiteralStringRef("maximumDataWritten"), std::numeric_limits<int64_t>::max());
68 minNode = getOption(options, LiteralStringRef("minNode"), 0);
69 useSystemKeys = getOption(options, LiteralStringRef("useSystemKeys"), deterministicRandom()->random01() < 0.5);
70 adjacentKeys = deterministicRandom()->random01() < 0.5;
71 initialKeyDensity = deterministicRandom()->random01(); // This fraction of keys are present before the first
72 // transaction (and after an unknown result)
73 valueSizeRange = std::make_pair(
74 0,
75 std::min<int>(deterministicRandom()->randomInt(0, 4 << deterministicRandom()->randomInt(0, 16)),
76 CLIENT_KNOBS->VALUE_SIZE_LIMIT * 1.2));
77 if (adjacentKeys) {
78 nodes = std::min<int64_t>(deterministicRandom()->randomInt(1, 4 << deterministicRandom()->randomInt(0, 14)),
79 CLIENT_KNOBS->KEY_SIZE_LIMIT * 1.2);
80 } else {
81 nodes = deterministicRandom()->randomInt(1, 4 << deterministicRandom()->randomInt(0, 20));
82 }
83
84 dataWritten = 0;
85 int newNodes = std::min<int>(nodes, maximumTotalData / (getKeyForIndex(nodes).size() + valueSizeRange.second));
86 minNode = std::max(minNode, nodes - newNodes);
87 nodes = newNodes;
88
89 CODE_PROBE(adjacentKeys && (nodes + minNode) > CLIENT_KNOBS->KEY_SIZE_LIMIT,
90 "WriteDuringReadWorkload testing large keys");

Callers

nothing calls this directly

Calls 3

reachedByMethod · 0.80
KeyValueRefClass · 0.50
push_back_deepMethod · 0.45

Tested by

no test coverage detected