change knob to be an adjustable probability instead of binary on/off

This commit is contained in:
Jon Fu 2021-11-16 13:41:19 -05:00
parent 508debd606
commit 16e551e834
3 changed files with 9 additions and 8 deletions

View File

@ -114,7 +114,7 @@ void ClientKnobs::initialize(Randomize randomize) {
init( LOG_RANGE_BLOCK_SIZE, CORE_VERSIONSPERSECOND );
init( MUTATION_BLOCK_SIZE, 10000);
init( MAX_VERSION_CACHE_LAG, 0.1 );
init( DEBUG_USE_GRV_CACHE, false );
init( DEBUG_USE_GRV_CACHE_CHANCE, -0.1 ); // Since we check <= for 100% chance at 1.0, we don't want the default to be 0. This also means 0 is not 0%.
init( GRV_CACHE_RK_COOLDOWN, 5.0 );
init( GRV_SUSTAINED_THROTTLING_THRESHOLD, 0.01 );

View File

@ -117,7 +117,7 @@ public:
int LOG_RANGE_BLOCK_SIZE;
int MUTATION_BLOCK_SIZE;
double MAX_VERSION_CACHE_LAG;
bool DEBUG_USE_GRV_CACHE; // Turn on to have all GRVs request to use the cache
double DEBUG_USE_GRV_CACHE_CHANCE; // Debug setting to change the chance for a regular GRV request to use the cache
double GRV_CACHE_RK_COOLDOWN; // Required number of seconds to pass after throttling to re-allow cache use
double GRV_SUSTAINED_THROTTLING_THRESHOLD; // Adjust what amount of time is considered "sustained" throttling on
// proxy for a GRV

View File

@ -195,11 +195,11 @@ void DatabaseContext::removeTssMapping(StorageServerInterface const& ssi) {
void DatabaseContext::updateCachedRV(double t, Version v) {
if (t > lastTimedGrv.get() && v >= cachedRv) {
// TraceEvent("CheckpointCacheUpdate")
// .detail("Version", v)
// .detail("CurTime", t)
// .detail("LastVersion", cachedRv)
// .detail("LastTime", lastTimedGrv.get());
TraceEvent("CheckpointCacheUpdate")
.detail("Version", v)
.detail("CurTime", t)
.detail("LastVersion", cachedRv)
.detail("LastTime", lastTimedGrv.get());
cachedRv = v;
lastTimedGrv = t;
}
@ -5145,6 +5145,7 @@ ACTOR static Future<Void> tryCommit(Database cx,
}
when(CommitID ci = wait(reply)) {
Version v = ci.version;
TraceEvent("DebugGrvCommitSuccess");
cx->updateCachedRV(grvTime, v);
if (v != invalidVersion) {
if (CLIENT_BUGGIFY) {
@ -5819,7 +5820,7 @@ bool rkThrottlingCooledDown(DatabaseContext* cx) {
Future<Version> Transaction::getReadVersion(uint32_t flags) {
if (!readVersion.isValid()) {
if (!options.skipGrvCache && rkThrottlingCooledDown(getDatabase().getPtr()) &&
(CLIENT_KNOBS->DEBUG_USE_GRV_CACHE || options.useGrvCache)) {
(deterministicRandom()->random01() <= CLIENT_KNOBS->DEBUG_USE_GRV_CACHE_CHANCE || options.useGrvCache)) {
TraceEvent("DebugGrvUseCache").detail("LastRV", cx->cachedRv).detail("LastTime", format("%.6f", cx->lastTimedGrv.get()));
// Upon our first request to use cached RVs, start the background updater
if (!cx->grvUpdateHandler.isValid()) {