Skip to content

Commit

Permalink
[improve][ms] Bvars add the FDB get_count_normalized indicator (#44036)
Browse files Browse the repository at this point in the history
### 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 <[email protected]>
  • Loading branch information
2 people authored and Your Name committed Nov 20, 2024
1 parent 55a06fd commit 9b71e32
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cloud/src/common/bvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t> g_bvar_txn_kv_get_count_normalized("txn_kv", "get_count_normalized");

bvar::Adder<int64_t> g_bvar_txn_kv_commit_error_counter;
bvar::Window<bvar::Adder<int64_t> > g_bvar_txn_kv_commit_error_counter_minute(
"txn_kv", "commit_error", &g_bvar_txn_kv_commit_error_counter, 60);
Expand Down
1 change: 1 addition & 0 deletions cloud/src/common/bvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ extern bvar::LatencyRecorder g_bvar_txn_kv_batch_get;

extern bvar::Adder<int64_t> g_bvar_txn_kv_commit_error_counter;
extern bvar::Adder<int64_t> g_bvar_txn_kv_commit_conflict_counter;
extern bvar::Adder<int64_t> g_bvar_txn_kv_get_count_normalized;

extern const int64_t BVAR_FDB_INVALID_VALUE;
extern bvar::Status<int64_t> g_bvar_fdb_client_count;
Expand Down
3 changes: 3 additions & 0 deletions cloud/src/meta-service/txn_kv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -434,6 +435,7 @@ TxnErrorCode Transaction::get(std::string_view begin, std::string_view end,

std::unique_ptr<RangeGetIterator> ret(new RangeGetIterator(fut));
RETURN_IF_ERROR(ret->init());
g_bvar_txn_kv_get_count_normalized << ret->size();

*(iter) = std::move(ret);

Expand Down Expand Up @@ -619,6 +621,7 @@ TxnErrorCode Transaction::batch_get(std::vector<std::optional<std::string>>* res

size_t num_keys = keys.size();
res->reserve(keys.size());
g_bvar_txn_kv_get_count_normalized << keys.size();
std::vector<std::unique_ptr<FDBFuture, FDBFutureDelete>> futures;
futures.reserve(opts.concurrency);
for (size_t i = 0; i < num_keys; i += opts.concurrency) {
Expand Down

0 comments on commit 9b71e32

Please sign in to comment.