New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
osd: eliminate ineffective container operations #19099
Conversation
What about this is "more effective" at manipulating pglog entries? With the switch from eversion_t to string, it just looks slower. |
5cce967
to
c00944c
Compare
@gregsfortytwo This is primarily about more effective (no copy) moving trimmed/trimmed_dups containers content to to_remove one in _write_log_and_missing... methods. But you're right that tracking map of strings is less effective than map of eversion_t. Reverted this part. Thanks. |
src/osd/PG.cc
Outdated
peer_info[peer].last_epoch_started = info.last_epoch_started; | ||
peer_info[peer].last_interval_started = info.last_interval_started; | ||
peer_info[peer].history.merge(info.history); | ||
auto it = peer_info.find(peer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd suggest just s/it/peer/
. so
auto peer = peer_info.find(*i);
...
easier to read this way, IMHO.
89db4a0
to
010f247
Compare
@tchaikov - updated |
src/os/Transaction.cc
Outdated
@@ -337,6 +337,12 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f) | |||
f->dump_string("op_name", "omap_rmkeys"); | |||
f->dump_stream("collection") << cid; | |||
f->dump_stream("oid") << oid; | |||
f->open_object_section("attrs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to use open_array_section()
instead.
src/os/Transaction.cc
Outdated
@@ -337,6 +337,12 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f) | |||
f->dump_string("op_name", "omap_rmkeys"); | |||
f->dump_stream("collection") << cid; | |||
f->dump_stream("oid") << oid; | |||
f->open_object_section("attrs"); | |||
for (auto p = keys.begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could use range-based loop.
I'll defer to Kefu on a proper review, but I don't have other objections after a skim. :) |
010f247
to
22d7d0e
Compare
@tchaikov - updated |
src/osd/PGLog.cc
Outdated
@@ -621,8 +621,8 @@ void PGLog::write_log_and_missing_wo_missing( | |||
_write_log_and_missing_wo_missing( | |||
t, km, log, coll, log_oid, | |||
divergent_priors, eversion_t::max(), eversion_t(), eversion_t(), | |||
set<eversion_t>(), | |||
set<string>(), | |||
nullptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only caller of PGLog::_write_log_and_missing_wo_missing()
is PGLog::write_log_and_missing_wo_missing()
. and the latter always pass it empty trimmed
and trimmed_dups
. can we take this chance to remove them and related logic as well. as they are not used at all.
src/osd/PGLog.cc
Outdated
for (set<eversion_t>::const_iterator i = trimmed.begin(); | ||
i != trimmed.end(); | ||
set<string> to_remove; | ||
to_remove.swap(*trimmed_dups); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dereferencing a nullptr
, will crash the application. and we always pass nullptr
s to this function.
see c2e2f03#diff-2bf6ec52b400c95e6a23a186482477b6R621
src/osd/PGLog.cc
Outdated
@@ -793,8 +797,8 @@ void PGLog::_write_log_and_missing( | |||
eversion_t dirty_to, | |||
eversion_t dirty_from, | |||
eversion_t writeout_from, | |||
const set<eversion_t> &trimmed, | |||
const set<string> &trimmed_dups, | |||
set<eversion_t> *trimmed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if my argument holds, we can remove these two parameters. and remove the following code you are changing in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov - your arguments are valid for _write_log_and_missing_wo_missing - there is just a single call of it. But for _write_log_and_missing trimmed/trimmed_dups are still applicable and are used when pg log trimming occurs. Hope I haven't missed something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov - ping!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ifed01 sorry for the latency, will review it early tomorrow.
22d7d0e
to
bb003d2
Compare
@tchaikov - thanks, updated. |
@tchaikov ping |
fb25f68
to
91008f7
Compare
src/osd/PGLog.cc
Outdated
log_keys_debug->erase(i->get_key_name()); | ||
set<string> to_remove; | ||
if (trimmed_dups) { | ||
to_remove.swap(*trimmed_dups); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this changes the semantic of this method. before this change, trimmed
and trimmed_dups
are not changed after _write_log_and_missing()
returns. after this change, both of them are empty. is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's expected. they aren't used any more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if that's the case, i need to take a closer look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and i'd suggest update the commit message accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov - updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, could just
to_remove = std::move(*trimmed_dups);
as we don't care about trimmed_dups
anymore after this call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's better to leave a container in a consistent(=empty) state to avoid potential issues if code evolves.
src/osd/PGLog.cc
Outdated
to_remove.swap(*trimmed_dups); | ||
} | ||
if (trimmed) { | ||
for (auto i = trimmed->begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, might want to take this chance to use range-based loop.
91008f7
to
bd86091
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aside from some nits, lgtm. and I don't feel strong about them.
src/osd/PGLog.cc
Outdated
log_keys_debug->erase(i->get_key_name()); | ||
set<string> to_remove; | ||
if (trimmed_dups) { | ||
to_remove.swap(*trimmed_dups); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, could just
to_remove = std::move(*trimmed_dups);
as we don't care about trimmed_dups
anymore after this call.
src/osd/PGLog.cc
Outdated
} | ||
trimmed->clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, this call is not needed.
src/osd/PGLog.h
Outdated
@@ -1239,8 +1237,8 @@ struct PGLog : DoutPrefixProvider { | |||
eversion_t dirty_to, | |||
eversion_t dirty_from, | |||
eversion_t writeout_from, | |||
const set<eversion_t> &trimmed, | |||
const set<string> &trimmed_dups, | |||
set<eversion_t> *trimmed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could pass by rvalue reference, which reflects the intention of this function better. the up side of using pointer is that it saves the overhead of constructing a temporary empty set<>
, but the only case we pass nullptr
to _write_log_and_missing()
is in ceph_objectstore_tool.cc
, so I don't think that's a bottleneck we need to worry about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
histogram Signed-off-by: Igor Fedotov <ifedotov@suse.com>
…ntics whenever possible Signed-off-by: Igor Fedotov <ifedotov@suse.com>
…al_repop. Signed-off-by: Igor Fedotov <ifedotov@suse.com>
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
bd86091
to
dfcdf7c
Compare
Signed-off-by: Igor Fedotov ifedotov@suse.com