]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: avoid costly md_config_t::get_val<>() when preparing stats 60610/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 4 Nov 2024 15:29:22 +0000 (15:29 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Sat, 25 Jan 2025 16:50:16 +0000 (16:50 +0000)
It's know that the `md_config_t::get_val<>()` method template
is costly and should be avoided on hot paths.

Recent profiling[1] by Mark Kogani has shown that, on RGW's bucket
listing, an OSD had burnt 2,87% of CPU cycles on `get_val<long>()`
in `PG::prepare_stats_for_publish()`.

[1]: https://github.com/ceph/ceph/pull/60278#issuecomment-2415718353

Fixes: https://tracker.ceph.com/issues/69657
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/PeeringState.cc
src/osd/PeeringState.h

index 334d202d207a9148f9be4607d38c0da71a51f706..8eff6fd8110e4a3c087059de0eeed6f0561048d2 100644 (file)
@@ -3930,8 +3930,7 @@ std::optional<pg_stat_t> PeeringState::prepare_stats_for_publish(
   // when there is no change in osdmap,
   // update info.stats.reported_epoch by the number of time seconds.
   utime_t cutoff_time = now;
-  cutoff_time -=
-      cct->_conf.get_val<int64_t>("osd_pg_stat_report_interval_max_seconds");
+  cutoff_time -= *osd_pg_stat_report_interval_max_seconds;
   const bool is_time_expired = cutoff_time > info.stats.last_fresh;
 
   // 500 epoch osdmaps are also the minimum number of osdmaps that mon must retain.
@@ -3939,8 +3938,7 @@ std::optional<pg_stat_t> PeeringState::prepare_stats_for_publish(
   // it can be considered that the one reported by pgid is too old and needs to be updated.
   // to facilitate mon trim osdmaps
   epoch_t cutoff_epoch = info.stats.reported_epoch;
-  cutoff_epoch +=
-      cct->_conf.get_val<int64_t>("osd_pg_stat_report_interval_max_epochs");
+  cutoff_epoch += *osd_pg_stat_report_interval_max_epochs;
   const bool is_epoch_behind = cutoff_epoch < get_osdmap_epoch();
 
   if (pg_stats_publish && pre_publish == *pg_stats_publish &&
index 4b5285b18786f03cc456ac6b4a729699313a3b4a..ddeae2e1673726281bd4182b3dfcc6f7929bd9a8 100644 (file)
@@ -25,6 +25,7 @@
 #include "OSDMap.h"
 #include "MissingLoc.h"
 #include "osd/osd_perf_counters.h"
+#include "common/config_cacher.h"
 #include "common/ostream_temp.h"
 
 struct PGPool {
@@ -1391,6 +1392,10 @@ public:
 
   PGStateHistory state_history;
   CephContext* cct;
+  md_config_cacher_t<int64_t> osd_pg_stat_report_interval_max_seconds{
+    cct->_conf, "osd_pg_stat_report_interval_max_seconds" };
+  md_config_cacher_t<int64_t> osd_pg_stat_report_interval_max_epochs{
+    cct->_conf, "osd_pg_stat_report_interval_max_epochs" };
   spg_t spgid;
   DoutPrefixProvider *dpp;
   PeeringListener *pl;