FastRestore:Sampling:Add FASTRESTORE_SAMPLING_RATE knob

This commit is contained in:
Meng Xu 2019-12-04 11:45:05 -08:00
parent 2b987d1945
commit dd91d26dfa
3 changed files with 7 additions and 4 deletions

View File

@ -531,6 +531,8 @@ ServerKnobs::ServerKnobs(bool randomize, ClientKnobs* clientKnobs) {
// Fast Restore
init( FASTRESTORE_FAILURE_TIMEOUT, 3600 );
init( FASTRESTORE_HEARTBEAT_INTERVAL, 60 );
init( FASTRESTORE_SAMPLING_RATE, 0.01 ); if( randomize && BUGGIFY ) { FASTRESTORE_SAMPLING_RATE = deterministicRandom()->random01(); } // smallest granularity is 0.01%
// clang-format on
if(clientKnobs)

View File

@ -471,6 +471,7 @@ public:
// Fast Restore
int64_t FASTRESTORE_FAILURE_TIMEOUT;
int64_t FASTRESTORE_HEARTBEAT_INTERVAL;
double FASTRESTORE_SAMPLING_RATE;
ServerKnobs(bool randomize = false, ClientKnobs* clientKnobs = NULL);
};

View File

@ -478,8 +478,8 @@ void _parseSerializedMutation(std::map<LoadingParam, VersionedMutationsMap>::ite
.detail("CommitVersion", commitVersion)
.detail("ParsedMutation", mutation.toString());
kvOps[commitVersion].push_back_deep(kvOps[commitVersion].arena(), mutation);
// Sampling 1/100 data
if (deterministicRandom()->randomInt(0, 100) < 1) {
// Sampling (FASTRESTORE_SAMPLING_RATE * 100 %) data
if (deterministicRandom()->randomInt(0, 10000) < 10000 * SERVER_KNOBS->FASTRESTORE_SAMPLING_RATE) {
samples.push_back_deep(samples.arena(), mutation);
}
ASSERT_WE_THINK(kLen >= 0 && kLen < val.size());
@ -549,8 +549,8 @@ ACTOR static Future<Void> _parseRangeFileToMutationsOnLoader(
ASSERT_WE_THINK(kvOps.find(version) != kvOps.end());
kvOps[version].push_back_deep(kvOps[version].arena(), m);
// Sampling: 1 out of 100 data
if (deterministicRandom()->randomInt(0, 100) < 1) {
// Sampling (FASTRESTORE_SAMPLING_RATE * 100 %) data
if (deterministicRandom()->randomInt(0, 10000) < 10000 * SERVER_KNOBS->FASTRESTORE_SAMPLING_RATE) {
sampleMutations.push_back_deep(sampleMutations.arena(), m);
}
}