Skip to content
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

Merged
merged 6 commits into from Jan 11, 2018

Conversation

ifed01
Copy link
Contributor

@ifed01 ifed01 commented Nov 22, 2017

Signed-off-by: Igor Fedotov ifedotov@suse.com

@gregsfortytwo
Copy link
Member

What about this is "more effective" at manipulating pglog entries? With the switch from eversion_t to string, it just looks slower.

@ifed01
Copy link
Contributor Author

ifed01 commented Nov 23, 2017

@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.

@ifed01 ifed01 changed the title os/PGLog: manipulate trimmed entries more effectively osd: eliminate ineffective container operations Nov 23, 2017
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);
Copy link
Contributor

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.

@ifed01
Copy link
Contributor Author

ifed01 commented Nov 23, 2017

@tchaikov - updated

@tchaikov tchaikov self-requested a review November 24, 2017 16:33
@@ -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");
Copy link
Contributor

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.

@@ -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();
Copy link
Contributor

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.

@gregsfortytwo
Copy link
Member

I'll defer to Kefu on a proper review, but I don't have other objections after a skim. :)

@ifed01
Copy link
Contributor Author

ifed01 commented Nov 29, 2017

@tchaikov - updated

@tchaikov tchaikov self-requested a review November 29, 2017 11:54
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,
Copy link
Contributor

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);
Copy link
Contributor

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 nullptrs 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,
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not addressed.

Copy link
Contributor Author

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov - ping!

Copy link
Contributor

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.

@ifed01
Copy link
Contributor Author

ifed01 commented Dec 1, 2017

@tchaikov - thanks, updated.

@liewegas
Copy link
Member

liewegas commented Dec 4, 2017

@tchaikov ping

@ifed01 ifed01 force-pushed the wip-ifed-faster-pglog branch 2 times, most recently from fb25f68 to 91008f7 Compare December 12, 2017 12:05
@tchaikov tchaikov self-requested a review December 12, 2017 14:42
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);
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov - updated

Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor

@tchaikov tchaikov left a 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);
Copy link
Contributor

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();
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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>
@liewegas liewegas merged commit c6d6676 into ceph:master Jan 11, 2018
@ifed01 ifed01 deleted the wip-ifed-faster-pglog branch January 16, 2018 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants