Skip to content

Commit

Permalink
Don't do extra work when verbose logging is off
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHogan committed Aug 20, 2021
1 parent 5c61a2a commit 43e5f0f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/buffer_organizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,25 @@ int MoveToTarget(SharedMemoryContext *context, RpcContext *rpc, BlobID blob_id,
return result;
}

void LocalIncrementFlushCount(SharedMemoryContext *context,
const std::string &vbkt_name) {
void LocalAdjustFlushCount(SharedMemoryContext *context,
const std::string &vbkt_name, int adjustment) {
MetadataManager *mdm = GetMetadataManagerFromContext(context);
VBucketID id = LocalGetVBucketId(context, vbkt_name.c_str());
VBucketInfo *info = LocalGetVBucketInfoById(mdm, id);
int flush_count = info->async_flush_count.fetch_add(1);
VLOG(1) << "Flush count on VBucket " << vbkt_name << " incremented to "
<< flush_count + 1 << "\n";
int flush_count = info->async_flush_count.fetch_add(adjustment);
VLOG(1) << "Flush count on VBucket " << vbkt_name
<< (adjustment > 0 ? "incremented" : "decremented") << " to "
<< flush_count + adjustment << "\n";
}

void LocalIncrementFlushCount(SharedMemoryContext *context,
const std::string &vbkt_name) {
LocalAdjustFlushCount(context, vbkt_name, 1);
}

void LocalDecrementFlushCount(SharedMemoryContext *context,
const std::string &vbkt_name) {
MetadataManager *mdm = GetMetadataManagerFromContext(context);
VBucketID id = LocalGetVBucketId(context, vbkt_name.c_str());
VBucketInfo *info = LocalGetVBucketInfoById(mdm, id);
int flush_count = info->async_flush_count.fetch_sub(1);
VLOG(1) << "Flush count on VBucket " << vbkt_name << " decremented to "
<< flush_count - 1 << "\n";
LocalAdjustFlushCount(context, vbkt_name, -1);
}

void IncrementFlushCount(SharedMemoryContext *context, RpcContext *rpc,
Expand Down

0 comments on commit 43e5f0f

Please sign in to comment.