diff --git a/fdbclient/Knobs.cpp b/fdbclient/Knobs.cpp index d9d49a5a9c..b664454f1d 100644 --- a/fdbclient/Knobs.cpp +++ b/fdbclient/Knobs.cpp @@ -232,7 +232,7 @@ void ClientKnobs::initialize(bool randomize) { init( TAG_THROTTLE_RECHECK_INTERVAL, 5.0 ); if( randomize && BUGGIFY ) TAG_THROTTLE_RECHECK_INTERVAL = 0.0; init( TAG_THROTTLE_EXPIRATION_INTERVAL, 60.0 ); if( randomize && BUGGIFY ) TAG_THROTTLE_EXPIRATION_INTERVAL = 1.0; - init( COMMIT_CLEAR_COST_ESTIMATE_METHOD, 0.0); + init( EXPENSIVE_COMMIT_COST_ESTIMATION_FRAC, 0.0); // clang-format on } diff --git a/fdbclient/Knobs.h b/fdbclient/Knobs.h index 037e848867..1dba21357d 100644 --- a/fdbclient/Knobs.h +++ b/fdbclient/Knobs.h @@ -219,7 +219,7 @@ public: double TAG_THROTTLE_RECHECK_INTERVAL; double TAG_THROTTLE_EXPIRATION_INTERVAL; - double COMMIT_CLEAR_COST_ESTIMATE_METHOD; // 0 --> estimate through shard-map; 1 --> estimate by asking StorageServer + double EXPENSIVE_COMMIT_COST_ESTIMATION_FRAC; // 0 --> estimate through shard-map; 1 --> estimate by asking StorageServer // (more accurate but more expensive) ClientKnobs(); diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index a035682736..b8ecf57313 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -3269,7 +3269,8 @@ ACTOR Future estimateCommitCosts(Transaction* s trCommitCosts.bytesAtomicWrite += it->expectedSize(); trCommitCosts.numAtomicWrite++; } else if (it->type == MutationRef::Type::ClearRange) { - if (deterministicRandom()->random01() < CLIENT_KNOBS->COMMIT_CLEAR_COST_ESTIMATE_METHOD) { + trCommitCosts.numClear ++; + if (deterministicRandom()->random01() < CLIENT_KNOBS->EXPENSIVE_COMMIT_COST_ESTIMATION_FRAC) { try { StorageMetrics m = wait(self->getStorageMetrics(KeyRangeRef(it->param1, it->param2), -1)); trCommitCosts.bytesClearEst += m.bytes; diff --git a/fdbserver/MasterProxyServer.actor.cpp b/fdbserver/MasterProxyServer.actor.cpp index 7dac686d0d..257d707129 100644 --- a/fdbserver/MasterProxyServer.actor.cpp +++ b/fdbserver/MasterProxyServer.actor.cpp @@ -447,6 +447,7 @@ struct ProxyCommitData { NotifiedDouble lastCommitTime; vector commitComputePerOperation; + TransactionTagMap transactionTagCommitCostEst; //The tag related to a storage server rarely change, so we keep a vector of tags for each key range to be slightly more CPU efficient. //When a tag related to a storage server does change, we empty out all of these vectors to signify they must be repopulated. @@ -805,9 +806,11 @@ ACTOR Future releaseResolvingAfter(ProxyCommitData* self, Future rel } // Commit one batch of transactions trs -ACTOR Future commitBatch(ProxyCommitData* self, vector trs, - int currentBatchMemBytesCount, - TransactionTagMap* transactionTagCommitCostEst) { +ACTOR Future commitBatch( + ProxyCommitData* self, + vector trs, + int currentBatchMemBytesCount) +{ //WARNING: this code is run at a high priority (until the first delay(0)), so it needs to do as little work as possible state int64_t localBatchNumber = ++self->localCommitBatchesStarted; state LogPushData toCommit(self->logSystem); @@ -1338,7 +1341,7 @@ ACTOR Future commitBatch(ProxyCommitData* self, vectortransactionTagCommitCostEst)[tag] += trs[t].commitCostEstimation; } } else if (committed[t] == ConflictBatch::TransactionTooOld) { @@ -1545,10 +1548,12 @@ ACTOR Future sendGrvReplies(Future replyFuture, std:: } ACTOR static Future transactionStarter( - MasterProxyInterface proxy, Reference> db, PromiseStream> addActor, - ProxyCommitData* commitData, GetHealthMetricsReply* healthMetricsReply, - GetHealthMetricsReply* detailedHealthMetricsReply, - TransactionTagMap* transactionTagCommitCostEst) { + MasterProxyInterface proxy, + Reference> db, + PromiseStream> addActor, + ProxyCommitData* commitData, GetHealthMetricsReply* healthMetricsReply, + GetHealthMetricsReply* detailedHealthMetricsReply) +{ state double lastGRVTime = 0; state PromiseStream GRVTimer; state double GRVBatchTime = SERVER_KNOBS->START_TRANSACTION_BATCH_INTERVAL_MIN; @@ -1571,7 +1576,7 @@ ACTOR static Future transactionStarter( addActor.send(getRate(proxy.id(), db, &transactionCount, &batchTransactionCount, &normalRateInfo, &batchRateInfo, healthMetricsReply, detailedHealthMetricsReply, &transactionTagCounter, &throttledTags, - transactionTagCommitCostEst)); + &(commitData->transactionTagCommitCostEst))); addActor.send(queueTransactionStartRequests(db, &systemQueue, &defaultQueue, &batchQueue, proxy.getConsistentReadVersion.getFuture(), GRVTimer, &lastGRVTime, &GRVBatchTime, replyTimes.getFuture(), &commitData->stats, &batchRateInfo, &transactionTagCounter)); @@ -2070,8 +2075,6 @@ ACTOR Future masterProxyServerCore( state GetHealthMetricsReply healthMetricsReply; state GetHealthMetricsReply detailedHealthMetricsReply; - state TransactionTagMap transactionTagCommitCostEst; - addActor.send( waitFailureServer(proxy.waitFailure.getFuture()) ); addActor.send( traceRole(Role::MASTER_PROXY, proxy.id()) ); @@ -2105,7 +2108,7 @@ ACTOR Future masterProxyServerCore( TraceEvent(SevInfo, "CommitBatchesMemoryLimit").detail("BytesLimit", commitBatchesMemoryLimit); addActor.send(monitorRemoteCommitted(&commitData)); - addActor.send(transactionStarter(proxy, commitData.db, addActor, &commitData, &healthMetricsReply, &detailedHealthMetricsReply, &transactionTagCommitCostEst)); + addActor.send(transactionStarter(proxy, commitData.db, addActor, &commitData, &healthMetricsReply, &detailedHealthMetricsReply)); addActor.send(readRequestServer(proxy, addActor, &commitData)); addActor.send(rejoinServer(proxy, &commitData)); addActor.send(healthMetricsRequestServer(proxy, &healthMetricsReply, &detailedHealthMetricsReply)); @@ -2149,7 +2152,7 @@ ACTOR Future masterProxyServerCore( lastCommit = now(); if (trs.size() || lastCommitComplete.isReady()) { - lastCommitComplete = commitBatch(&commitData, trs, batchBytes, &transactionTagCommitCostEst); + lastCommitComplete = commitBatch(&commitData, trs, batchBytes); addActor.send(lastCommitComplete); } } diff --git a/fdbserver/Ratekeeper.actor.cpp b/fdbserver/Ratekeeper.actor.cpp index d9ba23df3e..748d838695 100644 --- a/fdbserver/Ratekeeper.actor.cpp +++ b/fdbserver/Ratekeeper.actor.cpp @@ -1282,15 +1282,16 @@ ACTOR Future ratekeeper(RatekeeperInterface rkInterf, Reference 0) { diff --git a/fdbserver/RatekeeperInterface.h b/fdbserver/RatekeeperInterface.h index 5c6f35ab51..f3b83f0a87 100644 --- a/fdbserver/RatekeeperInterface.h +++ b/fdbserver/RatekeeperInterface.h @@ -78,18 +78,20 @@ struct ClientTagThrottleLimits { struct TransactionCommitCostEstimation { int64_t numWrite = 0; int64_t numAtomicWrite = 0; + int64_t numClear = 0; unsigned long bytesWrite = 0; unsigned long bytesClearEst = 0; unsigned long bytesAtomicWrite = 0; template void serialize(Ar& ar) { - serializer(ar, bytesWrite, bytesClearEst, bytesAtomicWrite, numWrite, numAtomicWrite); + serializer(ar, bytesWrite, bytesClearEst, bytesAtomicWrite, numWrite, numAtomicWrite, numClear); } TransactionCommitCostEstimation& operator += (const TransactionCommitCostEstimation& other) { numWrite += other.numWrite; numAtomicWrite += other.numAtomicWrite; + numClear += other.numClear; bytesWrite += other.bytesWrite; bytesClearEst += other.bytesClearEst; bytesAtomicWrite += other.numAtomicWrite;