From 9b71e325fccecdc8bbf241d7b94407db2845a844 Mon Sep 17 00:00:00 2001 From: jw-sun <55874234+Sjwhello@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:07:18 +0800 Subject: [PATCH] [improve][ms] Bvars add the FDB get_count_normalized indicator (#44036) ### What problem does this PR solve? Bvars add the FDB get_count_normalized indicator - g_bvar_txn_kv_ get_count_normalized Co-authored-by: sunjiangwei --- cloud/src/common/bvars.cpp | 2 ++ cloud/src/common/bvars.h | 1 + cloud/src/meta-service/txn_kv.cpp | 3 +++ 3 files changed, 6 insertions(+) diff --git a/cloud/src/common/bvars.cpp b/cloud/src/common/bvars.cpp index 2e2e312d0c1413..507acb00dff0b0 100644 --- a/cloud/src/common/bvars.cpp +++ b/cloud/src/common/bvars.cpp @@ -102,6 +102,8 @@ bvar::LatencyRecorder g_bvar_txn_kv_get_read_version("txn_kv", "get_read_version bvar::LatencyRecorder g_bvar_txn_kv_get_committed_version("txn_kv", "get_committed_version"); bvar::LatencyRecorder g_bvar_txn_kv_batch_get("txn_kv", "batch_get"); +bvar::Adder g_bvar_txn_kv_get_count_normalized("txn_kv", "get_count_normalized"); + bvar::Adder g_bvar_txn_kv_commit_error_counter; bvar::Window > g_bvar_txn_kv_commit_error_counter_minute( "txn_kv", "commit_error", &g_bvar_txn_kv_commit_error_counter, 60); diff --git a/cloud/src/common/bvars.h b/cloud/src/common/bvars.h index c2e21c66daad0d..373a3a63ff2703 100644 --- a/cloud/src/common/bvars.h +++ b/cloud/src/common/bvars.h @@ -198,6 +198,7 @@ extern bvar::LatencyRecorder g_bvar_txn_kv_batch_get; extern bvar::Adder g_bvar_txn_kv_commit_error_counter; extern bvar::Adder g_bvar_txn_kv_commit_conflict_counter; +extern bvar::Adder g_bvar_txn_kv_get_count_normalized; extern const int64_t BVAR_FDB_INVALID_VALUE; extern bvar::Status g_bvar_fdb_client_count; diff --git a/cloud/src/meta-service/txn_kv.cpp b/cloud/src/meta-service/txn_kv.cpp index f40bee76f7a441..ea31d5cb97bc11 100644 --- a/cloud/src/meta-service/txn_kv.cpp +++ b/cloud/src/meta-service/txn_kv.cpp @@ -377,6 +377,7 @@ TxnErrorCode Transaction::get(std::string_view key, std::string* val, bool snaps approximate_bytes_ += key.size() * 2; // See fdbclient/ReadYourWrites.actor.cpp for details auto* fut = fdb_transaction_get(txn_, (uint8_t*)key.data(), key.size(), snapshot); + g_bvar_txn_kv_get_count_normalized << 1; auto release_fut = [fut, &sw](int*) { fdb_future_destroy(fut); g_bvar_txn_kv_get << sw.elapsed_us(); @@ -434,6 +435,7 @@ TxnErrorCode Transaction::get(std::string_view begin, std::string_view end, std::unique_ptr ret(new RangeGetIterator(fut)); RETURN_IF_ERROR(ret->init()); + g_bvar_txn_kv_get_count_normalized << ret->size(); *(iter) = std::move(ret); @@ -619,6 +621,7 @@ TxnErrorCode Transaction::batch_get(std::vector>* res size_t num_keys = keys.size(); res->reserve(keys.size()); + g_bvar_txn_kv_get_count_normalized << keys.size(); std::vector> futures; futures.reserve(opts.concurrency); for (size_t i = 0; i < num_keys; i += opts.concurrency) {