add tenant kvcahe hold at SYSSTAT

This commit is contained in:
obdev 2024-02-07 10:58:37 +00:00 committed by ob-robot
parent c173c1713d
commit 1ee1ad37e4
6 changed files with 25 additions and 0 deletions

View File

@ -86,6 +86,16 @@ int64_t get_tenant_memory_hold(const uint64_t tenant_id, const uint64_t ctx_id)
return bytes;
}
int64_t get_tenant_cache_hold(uint64_t tenant_id)
{
int64_t bytes = 0;
ObMallocAllocator *allocator = ObMallocAllocator::get_instance();
if (!OB_ISNULL(allocator)) {
bytes = allocator->get_tenant_cache_hold(tenant_id);
}
return bytes;
}
int64_t get_tenant_memory_remain(uint64_t tenant_id)
{
int64_t bytes = 0;

View File

@ -36,6 +36,7 @@ void set_tenant_memory_limit(uint64_t tenant_id, int64_t bytes);
int64_t get_tenant_memory_limit(uint64_t tenant_id);
int64_t get_tenant_memory_hold(uint64_t tenant_id);
int64_t get_tenant_memory_hold(const uint64_t tenant_id, const uint64_t ctx_id);
int64_t get_tenant_cache_hold(uint64_t tenant_id);
int64_t get_tenant_memory_remain(uint64_t tenant_id);
void get_tenant_label_memory(
uint64_t tenant_id, ObLabel &label, common::ObLabelItem &item);

View File

@ -440,6 +440,16 @@ int64_t ObMallocAllocator::get_tenant_hold(uint64_t tenant_id)
return hold;
}
int64_t ObMallocAllocator::get_tenant_cache_hold(uint64_t tenant_id)
{
int64_t cache_hold = 0;
with_resource_handle_invoke(tenant_id, [&cache_hold](ObTenantMemoryMgr *mgr) {
cache_hold = mgr->get_cache_hold();
return OB_SUCCESS;
});
return cache_hold;
}
int64_t ObMallocAllocator::get_tenant_remain(uint64_t tenant_id)
{
int64_t remain = 0;

View File

@ -125,6 +125,7 @@ public:
int set_tenant_limit(uint64_t tenant_id, int64_t bytes);
int64_t get_tenant_limit(uint64_t tenant_id);
int64_t get_tenant_hold(uint64_t tenant_id);
int64_t get_tenant_cache_hold(uint64_t tenant_id);
int64_t get_tenant_remain(uint64_t tenant_id);
int64_t get_tenant_ctx_hold(const uint64_t tenant_id, const uint64_t ctx_id) const;
void get_tenant_label_usage(uint64_t tenant_id, ObLabel &label, common::ObLabelItem &item) const;

View File

@ -548,6 +548,7 @@ STAT_EVENT_SET_DEF(MEMORY_LIMIT, "effective observer memory limit", ObStatClassI
STAT_EVENT_SET_DEF(SYSTEM_MEMORY, "effective system memory", ObStatClassIds::RESOURCE, 140015, false, true, true)
STAT_EVENT_SET_DEF(HIDDEN_SYS_MEMORY, "effective hidden sys memory", ObStatClassIds::RESOURCE, 140016, false, true, true)
STAT_EVENT_SET_DEF(MAX_SESSION_NUM, "max session num", ObStatClassIds::RESOURCE, 140017, false, true, true)
STAT_EVENT_SET_DEF(KV_CACHE_HOLD, "kvcache hold", ObStatClassIds::RESOURCE, 140018, false, true, true)
//CLOG

View File

@ -208,6 +208,8 @@ int ObAllVirtualSysStat::update_all_stats_(const int64_t tenant_id, ObStatEventS
= static_cast<int64_t>(cpu_usage * 100);
stat_events.get(ObStatEventIds::MEMORY_USAGE - ObStatEventIds::STAT_EVENT_ADD_END -1)->stat_value_
= lib::get_tenant_memory_hold(tenant_id);
stat_events.get(ObStatEventIds::KV_CACHE_HOLD - ObStatEventIds::STAT_EVENT_ADD_END -1)->stat_value_
= lib::get_tenant_cache_hold(tenant_id);
} else {
// it is ok to not have any records
}