Merge PR #42256 into master

* refs/pull/42256/head:
	mds: update META_POP_READDIR/FETCH/STORE and cache_hit_rate for dump loads

Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2021-07-23 11:18:13 -07:00
commit a54e2a66c1
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
4 changed files with 19 additions and 2 deletions

View File

@ -28,6 +28,7 @@
#include "Locker.h"
#include "MDLog.h"
#include "LogSegment.h"
#include "MDBalancer.h"
#include "common/bloom_filter.hpp"
#include "include/Context.h"
@ -1577,6 +1578,8 @@ void CDir::fetch(MDSContext *c, std::string_view want_dn, bool ignore_authpinnab
if (mdcache->mds->logger) mdcache->mds->logger->inc(l_mds_dir_fetch);
mdcache->mds->balancer->hit_dir(this, META_POP_FETCH);
std::set<dentry_key_t> empty;
_omap_fetch(NULL, empty);
}
@ -1602,6 +1605,8 @@ void CDir::fetch(MDSContext *c, const std::set<dentry_key_t>& keys)
auth_pin(this);
if (mdcache->mds->logger) mdcache->mds->logger->inc(l_mds_dir_fetch);
mdcache->mds->balancer->hit_dir(this, META_POP_FETCH);
_omap_fetch(c, keys);
}
@ -2552,6 +2557,8 @@ void CDir::_commit(version_t want, int op_prio)
if (mdcache->mds->logger) mdcache->mds->logger->inc(l_mds_dir_commit);
mdcache->mds->balancer->hit_dir(this, META_POP_STORE);
_omap_commit(op_prio);
}

View File

@ -300,6 +300,8 @@ mds_load_t MDBalancer::get_load()
}
uint64_t num_requests = mds->get_num_requests();
uint64_t num_traverse = mds->logger->get(l_mds_traverse);
uint64_t num_traverse_hit = mds->logger->get(l_mds_traverse_hit);
uint64_t cpu_time = 1;
{
@ -331,13 +333,17 @@ mds_load_t MDBalancer::get_load()
load.req_rate = (num_requests - last_num_requests) / el;
if (cpu_time > last_cpu_time)
load.cpu_load_avg = (cpu_time - last_cpu_time) / el;
if (num_traverse > last_num_traverse && num_traverse_hit > last_num_traverse_hit)
load.cache_hit_rate = (double)(num_traverse_hit - last_num_traverse_hit) / (num_traverse - last_num_traverse);
} else {
auto p = mds_load.find(mds->get_nodeid());
if (p != mds_load.end()) {
load.req_rate = p->second.req_rate;
load.cpu_load_avg = p->second.cpu_load_avg;
load.cache_hit_rate = p->second.cache_hit_rate;
}
if (num_requests >= last_num_requests && cpu_time >= last_cpu_time)
if (num_requests >= last_num_requests && cpu_time >= last_cpu_time &&
num_traverse >= last_num_traverse && num_traverse_hit >= last_num_traverse_hit)
update_last = false;
}
}
@ -346,6 +352,8 @@ mds_load_t MDBalancer::get_load()
last_num_requests = num_requests;
last_cpu_time = cpu_time;
last_get_load = now;
last_num_traverse = num_traverse;
last_num_traverse_hit = num_traverse_hit;
}
dout(15) << load << dendl;

View File

@ -137,6 +137,8 @@ private:
time last_get_load = clock::zero();
uint64_t last_num_requests = 0;
uint64_t last_cpu_time = 0;
uint64_t last_num_traverse = 0;
uint64_t last_num_traverse_hit = 0;
// Dirfrags which are marked to be passed on to MDCache::[split|merge]_dir
// just as soon as a delayed context comes back and triggers it.

View File

@ -4760,7 +4760,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
mdr->reply_extra_bl = dirbl;
// bump popularity. NOTE: this doesn't quite capture it.
mds->balancer->hit_dir(dir, META_POP_IRD, -1, numfiles);
mds->balancer->hit_dir(dir, META_POP_READDIR, -1, numfiles);
// reply
mdr->tracei = diri;