Skip to content

Commit

Permalink
get and set counts
Browse files Browse the repository at this point in the history
  • Loading branch information
shuaihehe authored and wuhongsong committed Dec 9, 2023
1 parent c653b74 commit abe27ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions curvefs/src/client/kvclient/kvclient_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ void KVClientManager::Uninit() {
}

void KVClientManager::Set(std::shared_ptr<SetKVCacheTask> task) {
kvClientManagerMetric_->setQueueSize << 1;
threadPool_.Enqueue([task, this]() {
std::string error_log;
task->res =
client_->Set(task->key, task->value, task->length, &error_log);
kvClientManagerMetric_->setQueueSize << -1;
if (task->res) {
kvClientManagerMetric_->count << 1;
}
Expand Down Expand Up @@ -96,12 +98,14 @@ void UpdateHitMissMetric(memcached_return_t retCode,
}

void KVClientManager::Get(std::shared_ptr<GetKVCacheTask> task) {
kvClientManagerMetric_->getQueueSize << 1;
threadPool_.Enqueue([task, this]() {
std::string error_log;
memcached_return_t retCode;
task->res = client_->Get(task->key, task->value, task->offset,
task->valueLength, &error_log, &task->length,
&retCode);
kvClientManagerMetric_->getQueueSize << -1;
UpdateHitMissMetric(retCode, kvClientManagerMetric_.get());
OnReturn(&kvClientManagerMetric_->get, task);
});
Expand Down
8 changes: 7 additions & 1 deletion curvefs/src/client/metric/client_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ struct KVClientManagerMetric {
bvar::Adder<uint64_t> hit;
// kvcache miss
bvar::Adder<uint64_t> miss;
// kvcache getQueueSize
bvar::Adder<uint64_t> getQueueSize;
// kvcache setQueueSize
bvar::Adder<uint64_t> setQueueSize;

explicit KVClientManagerMetric(const std::string& name = "")
: fsName(!name.empty() ? name
Expand All @@ -325,7 +329,9 @@ struct KVClientManagerMetric {
set(prefix, fsName + "_set"),
count(prefix, fsName + "_count"),
hit(prefix, fsName + "_hit"),
miss(prefix, fsName + "_miss") {}
miss(prefix, fsName + "_miss"),
getQueueSize(prefix, fsName + "_get_queue_size"),
setQueueSize(prefix, fsName + "_set_queue_size") {}
};

struct MemcacheClientMetric {
Expand Down

0 comments on commit abe27ed

Please sign in to comment.