Skip to content

common/perf_counters: enabling 'find()' by logger name#60426

Merged
ronen-fr merged 3 commits intoceph:mainfrom
ronen-fr:wip-rf-svwperf
Feb 2, 2025
Merged

common/perf_counters: enabling 'find()' by logger name#60426
ronen-fr merged 3 commits intoceph:mainfrom
ronen-fr:wip-rf-svwperf

Conversation

@ronen-fr
Copy link
Contributor

@ronen-fr ronen-fr commented Oct 22, 2024

Multiple style and performance tweaks. The important one:
Modifying reset() to directly locate the named logger.
As most of the code here predates C++14, "transparent
comparators" were not used. Instead, we looped through
the list of loggers.
With the updated C++ we are using today, the comparator
can be fixed to allow a find() based on the name.

Also: avoiding the use of 3 consecutive 'bool's as arguments to
some dump functions.

@ronen-fr
Copy link
Contributor Author

ronen-fr commented Oct 23, 2024

Failing on a C++-20 feature... That's strange.

Update: the feature was added in p0408.
It requires gcc 11 and clang (libstdc) 17. MSFT 19.29 (16.10)

  • update Jan 25: removing those changes for now.

@github-actions github-actions bot added the stale label Dec 26, 2024
@ronen-fr ronen-fr removed the stale label Dec 29, 2024
@ronen-fr ronen-fr force-pushed the wip-rf-svwperf branch 2 times, most recently from d9cb256 to 61cc850 Compare January 21, 2025 06:01
@ronen-fr ronen-fr changed the title common/perf_counters: a minor API tweak common/perf_counters: enabling 'find()' by logger name Jan 21, 2025
@ronen-fr ronen-fr marked this pull request as ready for review January 21, 2025 12:57
@ronen-fr ronen-fr requested review from a team as code owners January 21, 2025 12:57
@ronen-fr ronen-fr requested review from badone and rzarzynski January 21, 2025 13:00
@ceph ceph deleted a comment from github-actions bot Jan 21, 2025
@ronen-fr ronen-fr requested a review from batrick January 21, 2025 14:21
Copy link
Contributor

@rzarzynski rzarzynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically LGTM; just a question to ensure understanding.

ceph_assert(i != m_loggers.end());
m_loggers.erase(i);
[[maybe_unused]] const auto rm_cnt = m_loggers.erase(l);
ceph_assert(rm_cnt > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks there is a change in behavior. Previously remove() was dropping only a single item from m_loggers; now it must be at least 1. Is this intentional?

UPDATE: it seems just confusing; as the name should already be unique, I don't expect to remove more than 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not wish to change the 'erase', but I'll change the assert to make it plain.

while (i != m_loggers.end()) {
ostringstream ss;
ss << l->get_name() << "-" << (void*)l;
l->set_name(ss.str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, we were extending the name by the -{address} even indefinitely, till the uniqueness is achieved.

l->set_name(ss.str());
i = m_loggers.find(l);
while (m_loggers.contains(l)) {
l->set_name(fmt::format("{}-{:p}", l->get_name(), (void *)l));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, no change; same algorithm.

} else {
// dump only specified logger
auto l = m_loggers.find(logger);
if (l != m_loggers.end()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if (auto l = ...; ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it would be an improvement. The outer block ends immediately after the 'if', so the variable
scope is limited anyway. And it's easier to read this way.

Multiple style and performance tweaks. The important one:
Modifying reset() to directly locate the named logger.
As most of the code here predates C++14, "transparent
comparators" were not used. Instead, we looped through
the list of loggers.
With the updated C++ we are using today, the comparator
can be fixed to allow a find() based on the name.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
Some counters' dump functions accept 3 bool parameters to
determine some dumping behavior. And multiple 'bool' parameters
are considered a code smell.
This is a minor refactor to replace one of these bools
with a 'select_labeled_t' enum.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
@ronen-fr
Copy link
Contributor Author

jenkins test api

@ronen-fr
Copy link
Contributor Author

ronen-fr commented Feb 2, 2025

Passed formal QA. Also tested on my Teu runs, including in the jumbo wip-rf-combined-30j

@ronen-fr ronen-fr merged commit 05bdd9f into ceph:main Feb 2, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants