Skip to content

Commit 39a12b5

Browse files
committed
osd: avoid costly md_config_t::get_val<>() when preparing stats
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]: ceph#60278 (comment) Fixes: https://tracker.ceph.com/issues/69657 Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent 8dc4de1 commit 39a12b5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/osd/PeeringState.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,17 +3930,15 @@ std::optional<pg_stat_t> PeeringState::prepare_stats_for_publish(
39303930
// when there is no change in osdmap,
39313931
// update info.stats.reported_epoch by the number of time seconds.
39323932
utime_t cutoff_time = now;
3933-
cutoff_time -=
3934-
cct->_conf.get_val<int64_t>("osd_pg_stat_report_interval_max_seconds");
3933+
cutoff_time -= *osd_pg_stat_report_interval_max_seconds;
39353934
const bool is_time_expired = cutoff_time > info.stats.last_fresh;
39363935

39373936
// 500 epoch osdmaps are also the minimum number of osdmaps that mon must retain.
39383937
// if info.stats.reported_epoch less than current osdmap epoch exceeds 500 osdmaps,
39393938
// it can be considered that the one reported by pgid is too old and needs to be updated.
39403939
// to facilitate mon trim osdmaps
39413940
epoch_t cutoff_epoch = info.stats.reported_epoch;
3942-
cutoff_epoch +=
3943-
cct->_conf.get_val<int64_t>("osd_pg_stat_report_interval_max_epochs");
3941+
cutoff_epoch += *osd_pg_stat_report_interval_max_epochs;
39443942
const bool is_epoch_behind = cutoff_epoch < get_osdmap_epoch();
39453943

39463944
if (pg_stats_publish && pre_publish == *pg_stats_publish &&

src/osd/PeeringState.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "OSDMap.h"
2626
#include "MissingLoc.h"
2727
#include "osd/osd_perf_counters.h"
28+
#include "common/config_cacher.h"
2829
#include "common/ostream_temp.h"
2930

3031
struct PGPool {
@@ -1391,6 +1392,10 @@ class PeeringState : public MissingLoc::MappingInfo {
13911392

13921393
PGStateHistory state_history;
13931394
CephContext* cct;
1395+
md_config_cacher_t<int64_t> osd_pg_stat_report_interval_max_seconds{
1396+
cct->_conf, "osd_pg_stat_report_interval_max_seconds" };
1397+
md_config_cacher_t<int64_t> osd_pg_stat_report_interval_max_epochs{
1398+
cct->_conf, "osd_pg_stat_report_interval_max_epochs" };
13941399
spg_t spgid;
13951400
DoutPrefixProvider *dpp;
13961401
PeeringListener *pl;

0 commit comments

Comments
 (0)