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,compressor: Expose compression algorithms via MOSDBoot. #20558
osd,compressor: Expose compression algorithms via MOSDBoot. #20558
Conversation
042eb2b
to
8515dd5
Compare
src/osd/OSD.cc
Outdated
@@ -12,14 +12,19 @@ | |||
* Foundation. See file COPYING. | |||
* | |||
*/ | |||
#include "acconfig.h" |
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.
Is there a reason you reordered these include orders? There are some annoyingly delicate dependencies and the cross-platform stuff won't get picked up in our own testing.
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.
Hm, I didn't know about the cross-platform issue! I have to say it's almost become reflexive. Sage has asked before that headers be tidied up "while we're in there", but perhaps acconfig wasn't on the menu. I've moved it back to the top. I can also revert all the re-ordering if that's the best thing to do.
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.
Well, I'm not saying there definitely is a problem; like I said the issues are fragile. And while our config header is a good guess for which one matters, it'll really be anything that inherits any kind of definition where we override or conflict with the standard ones. (We see the same thing with our own definition of assert, for instance, although that one's markedly less fragile.)
But in general I get queasy around seeing headers rearranged; the cosmetics aren't worth it in a system with as cross-unit dependencies and invariants as Ceph has.
src/osd/OSD.cc
Outdated
string s(os.str()); | ||
|
||
// No ostream_joiner yet, so we'll need to do some trimming: | ||
if(s[s.size()] == ',') |
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 should probably be size() - 1
?
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.
Good catch! "Someone" didn't have enough coffee! Thanks.
6fa22e5
to
f5d102e
Compare
jenkins test make check |
@chardan, these are real build errors. Looks like _collect_compression_algorithms() doesn't match the declaration and implementation params |
f5d102e
to
544429e
Compare
@gregsfortytwo Should be addressed now, thank you! |
src/compressor/Compressor.cc
Outdated
|
||
return boost::optional<CompressionAlgorithm>(); | ||
for (int pos = 0; pos != sizeof(compression_algorithm_names); ++pos) { |
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.
Why != instead of <= in this loop? I thought that was generally considered bad because if the loop mutates and you accidentally skip over the end condition, you're in trouble...
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.
@gregsfortytwo Should be < instead of <=
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 a static array mutates, you're in real trouble! ;-)
Reviewed-by: Greg Farnum gfarnum@redhat.com |
src/compressor/Compressor.cc
Outdated
|
||
return boost::optional<CompressionAlgorithm>(); | ||
for (int pos = 0; pos != sizeof(compression_algorithm_names); ++pos) { | ||
if(compression_algorithm_names[pos] == s) |
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.
add a space after if
, also you could put
auto found = find(begin(compression_algorithm_names), end(compression_algorithm_names), s);
if (found == end(compression_algorithm_names)) {
return {};
} else {
return found - begin(compression_algorithm_names);
}
src/compressor/Compressor.cc
Outdated
default: return "???"; | ||
} | ||
|
||
if(a < 0 || a >= COMP_ALG_LAST) |
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.
add a space after if
.
src/compressor/Compressor.h
Outdated
|
||
// The names in this array must match the above values: | ||
constexpr static char const* const compression_algorithm_names[] = { | ||
"none", |
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.
please note our tab-width is 8. and the indent offset is 2. so this indent does not follow the style guide.
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.
It matches all the code around it...
src/osd/OSD.cc
Outdated
const auto& compression_algorithm_names = Compressor::compression_algorithm_names; | ||
const auto& plugin_registry = cct->get_plugin_registry()->plugins; | ||
|
||
if(0 == plugin_registry.size()) |
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.
please use empty()
instead, if what you are interested is the emptiness instead of of the actual size.
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.
+1
src/osd/OSD.cc
Outdated
@@ -5536,6 +5541,28 @@ void OSD::_send_boot() | |||
set_state(STATE_BOOTING); | |||
} | |||
|
|||
std::string OSD::_collect_compression_algorithms() | |||
{ | |||
const auto& compression_algorithm_names = Compressor::compression_algorithm_names; |
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 use a shorter name.
src/osd/OSD.cc
Outdated
|
||
string s(os.str()); | ||
|
||
s.erase(s.find_last_of(',')); |
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 just use
std::copy(begin(names), end(names), std::experimental::make_ostream_joiner(os, ", "));
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.
Agreed, are we feeling ok with things in std::experimental in general, though?
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.
we used to use facilities in the TS namespace before they are included by the std namespace. i think as long as it's part of standard, there is no reason not using it.
src/osd/OSD.cc
Outdated
@@ -5544,6 +5571,7 @@ void OSD::_collect_metadata(map<string,string> *pm) | |||
// not applicable for bluestore | |||
(*pm)["osd_journal"] = journal_path; | |||
} | |||
|
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.
please avoid adding empty lines.
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 think it vastly improves readability.
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.
see https://github.com/ceph/ceph/blob/master/CodingStyle and https://google.github.io/styleguide/cppguide.html#Vertical_Whitespace. also it'd be better not changing the area your are not touching.
src/osd/OSD.h
Outdated
@@ -1927,6 +1927,7 @@ class OSD : public Dispatcher, | |||
void _preboot(epoch_t oldest, epoch_t newest); | |||
void _send_boot(); | |||
void _collect_metadata(map<string,string> *pmeta); | |||
std::string _collect_compression_algorithms(); |
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.
wrong indent.
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.
It's to show that this function depends on/is only used by the other function.
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 follow our coding style before we enforce yours.
|
src/compressor/Compressor.cc
Outdated
auto p = std::find_if(std::cbegin(compression_algorithms), std::cend(compression_algorithms), | ||
[a](const auto& kv) { return kv.second == a; }); | ||
|
||
if(std::cend(compression_algorithms) == p) |
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.
again, please add a space after if
.
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 couple of formatting issues, lgtm.
1d76263
to
2d3842f
Compare
could you prefix the title of your commit message with the subcomponent your are changing ? see https://github.com/ceph/ceph/blob/master/SubmittingPatches.rst#3-describe-your-changes |
retest this please. |
2d3842f
to
d0c5c2e
Compare
d0c5c2e
to
52243cf
Compare
retest this please. |
@yuriw Real errors, sorry-- working on them, I'm juggling a bunch of stuff right now! I'll update soon. |
52243cf
to
16c3552
Compare
Modifies Compressor to expose a set of strings (already hardcoded) that are accessible elsewhere. Adds metadata to MOSDBoost containing a list of compression algorithms made available via the plugin interface. Fixes: http://tracker.ceph.com/issues/22420 Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
@yuriw Thanks for your patience! |
#21106 adds the zstd compressor back. it was removed in this change. |
@chardan it looks like this patch is not working as intended, because the plugin registry is only populated at the point a plugin is loaded for use, so we're getting empty lists in this metadata field in practice. This needs a follow up change to enable PluginRegistry to scan its plugin dir at init time (probably what the unimplemented |
since the plugin registry check just confirms that the shared library is present/loadable - but if we have control over packaging/installation, can't we just assume they are? the manager itself has access to |
agreed, and probably it's more practical / useful to have a single "compression_algorithms" report on monitor instead from osd. as in a large scale cluster, it's tedious to check every OSD nodes and calculate the intersection of the compression_algorithm of them, and then decide which compression(s) is available. |
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.
sorry for belated review
COMP_ALG_LAST //the last value for range checks | ||
}; | ||
|
||
inline static const std::map<const std::string, const CompressionAlgorithm> compression_algorithms { |
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 opened #21801 to make this a constexpr initializer_list
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 exposes compression_algorithms
directly as an interface to determine which are enabled. consider extending the static functions to do this instead. for example:
static constexpr std::optional<const char*> get_comp_alg_name(int a);
static constexpr std::optional<CompressionAlgorithm> get_comp_alg_type(std::string_view s);
the caller can loop over [0,COMP_ALG_LAST)
and call get_comp_alg_name(i)
to include the names of each algorithm enabled. these functions can be constexpr thanks to initializer_list and the constexpr constructors of std::optional and std::string_view. std::find_if() isn't constexpr until c++20, but a ranged-for loop would work instead
(this would also address the comment return "???"; // It would be nice to revise this...
)
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.
Yeah, 'return "???"' was what the prior code did, and frankly I'm not a fan of that. I decided to lift up only a single level of abstraction because I didn't know how much other code might be using it, but there's certainly no reason it can't be revisited! Thanks for your thoughtful comments.
ostringstream os; | ||
|
||
copy_if(begin(compression_algorithms), end(compression_algorithms), | ||
make_ostream_joiner(os, ", "), |
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.
it looks like this will print pairs instead of just the names
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.
Modifies Compressor to expose a set of strings (already hardcoded)
that are accessible elsewhere.
Adds metadata to MOSDBoost containing a list of compression algorithms
made available via the plugin interface.
http://tracker.ceph.com/issues/22420
Signed-off-by: Jesse Williamson jwilliamson@suse.de