From 778ea0214215172c75b03c6299e2d72c4903b6b1 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 5 Aug 2020 22:23:05 +0800 Subject: [PATCH] mds: avoid calling g_conf().get_val() in MDSRank::heartbeat_reset() g_conf().get_val() is expensive. Signed-off-by: "Yan, Zheng" --- src/mds/MDSRank.cc | 8 ++++++-- src/mds/MDSRank.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index fe51eea00ac4..6786aadd201a 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -531,6 +531,7 @@ MDSRank::MDSRank( server = new Server(this, &metrics_handler); locker = new Locker(this, mdcache); + heartbeat_grace = g_conf().get_val("mds_heartbeat_grace"); op_tracker.set_complaint_and_threshold(cct->_conf->mds_op_complaint_time, cct->_conf->mds_op_log_threshold); op_tracker.set_history_size_and_duration(cct->_conf->mds_op_history_size, @@ -1318,9 +1319,8 @@ void MDSRank::heartbeat_reset() // NB not enabling suicide grace, because the mon takes care of killing us // (by blacklisting us) when we fail to send beacons, and it's simpler to // only have one way of dying. - auto grace = g_conf().get_val("mds_heartbeat_grace"); g_ceph_context->get_heartbeat_map()->reset_timeout(hb, - ceph::make_timespan(grace), + ceph::make_timespan(heartbeat_grace), ceph::timespan::zero()); } @@ -3624,6 +3624,7 @@ const char** MDSRankDispatcher::get_tracked_conf_keys() const "mds_request_load_average_decay_rate", "mds_session_cache_liveness_decay_rate", "mds_replay_unsafe_with_closed_session", + "mds_heartbeat_grace", NULL }; return KEYS; @@ -3633,6 +3634,9 @@ void MDSRankDispatcher::handle_conf_change(const ConfigProxy& conf, const std::s { // XXX with or without mds_lock! + if (changed.count("mds_heartbeat_grace")) { + heartbeat_grace = conf.get_val("mds_heartbeat_grace"); + } if (changed.count("mds_op_complaint_time") || changed.count("mds_op_log_threshold")) { op_tracker.set_complaint_and_threshold(conf->mds_op_complaint_time, conf->mds_op_log_threshold); } diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index 69455993527b..9667866c6607 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -546,6 +546,7 @@ class MDSRank { int dispatch_depth = 0; ceph::heartbeat_handle_d *hb = nullptr; // Heartbeat for threads using mds_lock + double heartbeat_grace; map peer_mdsmap_epoch; -- 2.47.3