consider clear single key

This commit is contained in:
Xiaoxi Wang 2020-08-01 18:20:13 +00:00
parent 1f38c2f2a4
commit 92c1112c74
4 changed files with 12 additions and 6 deletions

View File

@ -80,6 +80,7 @@ struct MutationRef {
// This is stored this way for serialization purposes.
uint8_t type;
StringRef param1, param2;
bool clearSingleKey = false; // be only needed in client, so no serialization
MutationRef() {}
MutationRef( Type t, StringRef a, StringRef b ) : type(t), param1(a), param2(b) {}

View File

@ -65,8 +65,8 @@ void ClientKnobs::initialize(bool randomize) {
init( BACKOFF_GROWTH_RATE, 2.0 );
init( RESOURCE_CONSTRAINED_MAX_BACKOFF, 30.0 );
init( PROXY_COMMIT_OVERHEAD_BYTES, 23 ); //The size of serializing 7 tags (3 primary, 3 remote, 1 log router) + 2 for the tag length
init( DEFAULT_SMOOTH_AMOUNT, 1.0);
init( INIT_MEAN_SHARD_BYTES, 20000);
init( DEFAULT_SMOOTH_AMOUNT, 5.0 );
init( INIT_MEAN_SHARD_BYTES, 1024 );
init( TRANSACTION_SIZE_LIMIT, 1e7 );
init( KEY_SIZE_LIMIT, 1e4 );
@ -230,7 +230,7 @@ void ClientKnobs::initialize(bool randomize) {
// transaction tags
init( MAX_TAGS_PER_TRANSACTION, 5 );
init( MAX_TRANSACTION_TAG_LENGTH, 16 );
init( COMMIT_SAMPLE_BYTE, 50000 );
init( COMMIT_SAMPLE_BYTE, 100000 );
init( READ_TAG_SAMPLE_RATE, 0.01 ); if( randomize && BUGGIFY ) READ_TAG_SAMPLE_RATE = 1.0; // Communicated to clients from cluster
init( TAG_THROTTLE_SMOOTHING_WINDOW, 2.0 );
init( TAG_THROTTLE_RECHECK_INTERVAL, 5.0 ); if( randomize && BUGGIFY ) TAG_THROTTLE_RECHECK_INTERVAL = 0.0;

View File

@ -2985,7 +2985,7 @@ void Transaction::clear( const KeyRef& key, bool addConflictRange ) {
data[key.size()] = 0;
t.mutations.emplace_back(req.arena, MutationRef::ClearRange, KeyRef(data, key.size()),
KeyRef(data, key.size() + 1));
t.mutations.back().clearSingleKey = true;
if(addConflictRange)
t.write_conflict_ranges.emplace_back(req.arena, KeyRef(data, key.size()), KeyRef(data, key.size() + 1));
}
@ -3272,13 +3272,18 @@ ACTOR Future<Optional<ClientTrCommitCostEstimation>> estimateCommitCosts(Transac
CommitTransactionRef* transaction) {
state ClientTrCommitCostEstimation trCommitCosts;
state KeyRange keyRange;
for (int i = 0; i < transaction->mutations.size(); ++i) {
state int i = 0;
for (; i < transaction->mutations.size(); ++i) {
auto* it = &transaction->mutations[i];
if (it->type == MutationRef::Type::SetValue || it->isAtomicOp()) {
trCommitCosts.opsCount++;
trCommitCosts.writtenBytes += it->expectedSize();
} else if (it->type == MutationRef::Type::ClearRange) {
trCommitCosts.opsCount++;
if(it->clearSingleKey) {
trCommitCosts.clearIdxBytes.emplace(i, it->expectedSize()); // NOTE: whether we need a weight here?
continue;
}
keyRange = KeyRange(KeyRangeRef(it->param1, it->param2));
if (self->options.expensiveClearCostEstimation) {
StorageMetrics m = wait(self->getStorageMetrics(keyRange, std::numeric_limits<int>::max()));

View File

@ -1239,7 +1239,7 @@ void updateRate(RatekeeperData* self, RatekeeperLimits* limits) {
}
}
void updateCommitCostEstimation(RatekeeperData* self, TransactionTagMap<TransactionCommitCostEstimation> const& costEstimation) {
void updateCommitCostEstimation(RatekeeperData* self, UIDTransactionTagMap<TransactionCommitCostEstimation> const& costEstimation) {
// if(self->validSS <= 0) return;
// int opsSum = 0;
// double bytesSum = 0;