mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: update cached stats inside PollExecution (#3376)
* chore: update cached stats inside PollExecution
This commit is contained in:
parent
8a9c9adbc5
commit
181d356341
8 changed files with 19 additions and 32 deletions
|
@ -500,10 +500,13 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
|
|||
}
|
||||
|
||||
string dbg_id;
|
||||
auto run = [this, &dbg_id](Transaction* tx, bool is_ooo) -> bool /* keep */ {
|
||||
bool update_stats = false;
|
||||
|
||||
auto run = [this, &dbg_id, &update_stats](Transaction* tx, bool is_ooo) -> bool /* keep */ {
|
||||
dbg_id = VLOG_IS_ON(1) ? tx->DebugId() : "";
|
||||
bool keep = tx->RunInShard(this, is_ooo);
|
||||
DLOG_IF(INFO, !dbg_id.empty()) << dbg_id << ", keep " << keep << ", ooo " << is_ooo;
|
||||
update_stats = true;
|
||||
return keep;
|
||||
};
|
||||
|
||||
|
@ -530,6 +533,7 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
|
|||
|
||||
// Progress on the transaction queue if no transaction is running currently.
|
||||
Transaction* head = nullptr;
|
||||
|
||||
while (continuation_trans_ == nullptr && !txq_.Empty()) {
|
||||
head = get<Transaction*>(txq_.Front());
|
||||
|
||||
|
@ -579,6 +583,9 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
|
|||
if (is_ooo && !trans->IsMulti())
|
||||
DCHECK_EQ(keep, trans->DEBUG_GetTxqPosInShard(sid) != TxQueue::kEnd);
|
||||
}
|
||||
if (update_stats) {
|
||||
CacheStats();
|
||||
}
|
||||
}
|
||||
|
||||
void EngineShard::RemoveContTx(Transaction* tx) {
|
||||
|
@ -693,9 +700,11 @@ void EngineShard::RunPeriodic(std::chrono::milliseconds period_ms) {
|
|||
}
|
||||
|
||||
void EngineShard::CacheStats() {
|
||||
// mi_heap_visit_blocks(tlh, false /* visit all blocks*/, visit_cb, &sum);
|
||||
mi_stats_merge();
|
||||
uint64_t now = fb2::ProactorBase::GetMonotonicTimeNs();
|
||||
if (cache_stats_time_ + 1000000 > now) // 1ms
|
||||
return;
|
||||
|
||||
cache_stats_time_ = now;
|
||||
// Used memory for this shard.
|
||||
size_t used_mem = UsedMemory();
|
||||
DbSlice& db_slice = namespaces.GetDefaultNamespace().GetDbSlice(shard_id());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue