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

os/bluestore: kvdb histogram #12620

Merged
merged 6 commits into from Jan 25, 2017
Merged

Conversation

varadakari
Copy link
Contributor

Generates a histogram of key value distribution for kvdb(rocksdb for now)

@@ -313,6 +313,8 @@ class RocksDBStore : public KeyValueDB {
bufferlist value();
bufferptr value_as_ptr();
int status();
size_t key_size();
Copy link
Contributor

@ifed01 ifed01 Dec 22, 2016

Choose a reason for hiding this comment

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

add 'override' keyword for this and the next declarations?

@@ -1770,6 +1770,7 @@ class BlueStore : public ObjectStore,
}

void get_db_statistics(Formatter *f);
void get_db_histogram(Formatter *f);
Copy link
Contributor

Choose a reason for hiding this comment

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

'override' here?

@@ -150,6 +150,8 @@ class RocksDBStore : public KeyValueDB {

void close();

void split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, char delim);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need this form of split?

@@ -150,6 +150,8 @@ class RocksDBStore : public KeyValueDB {

void close();

void split(const std::string &s, char delim, std::vector<std::string> &elems);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest to rename to split_stats or something to improve readability.

@varadakari
Copy link
Contributor Author

@ifed01 fixed the review comments, please review again.

@varadakari
Copy link
Contributor Author

sample output of the histogram is below:

{
"prefix": "B",
"key-hist": {
"[0,32)": 208,
"max_len": 17,
"value-hist": {
"[0,64)": 208,
"max_len": 16
}
},
"prefix": "C",
"key-hist": {
"[0,32)": 9,
"max_len": 10,
"value-hist": {
"[0,64)": 9,
"max_len": 10
}
},
"prefix": "M",
"key-hist": {
"[0,32)": 47,
"max_len": 26,
"value-hist": {
"[0,64)": 31,
"max_len": 25,
"[128,192)": 8,
"max_len": 186,
"[832,896)": 8,
"max_len": 847
},
"[32,64)": 12807,
"max_len": 42,
"value-hist": {
"[128,192)": 12807,
"max_len": 182
}
},

Copy link
Contributor

@ifed01 ifed01 left a comment

Choose a reason for hiding this comment

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

@varadakari sorry for splitting my review into 2 parts - didn't have enough time for complete review yesterday.

//histogram
struct value_dist
{
uint64_t count;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to initialize struct members with 0 here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ifed01 these are part of the histogram, don't need to specifically initialize to 0, if the value doesn't exist in the map, it will be initialized to 0 by default.

uint64_t count;
uint32_t max_len;
};
typedef struct value_dist value_dist_t;
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO one can simply define struct value_dist_t above - no need for duplicate type definitions(value_dist & value_dist_t) here.

uint32_t max_len;
map<int, value_dist_t> val_map; // slab id to count and others
};
typedef struct key_dist key_dist_t;
Copy link
Contributor

Choose a reason for hiding this comment

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

The same here

pair<string,string> key(iter->raw_key());

if (key.first == PREFIX_SUPER) {
key_hist[PREFIX_SUPER][key_slab].count++;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest to introduce a helper func to update a specific key_hist entry in a single call.
e.g.
update_entry( key_hist, PREFIX_SUPER, key_size, value_size);

}
else if (key.first == PREFIX_OBJ) {
if (key.second.back() == ONODE_KEY_SUFFIX) {
key_hist["o"][key_slab].count++;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest to use symbolic names instead of explicit literals: "o", "x", etc

@varadakari
Copy link
Contributor Author

@ifed01 addressed the comments, please review again. Have to move the local variables(maps for the histogram) to make the updates as a function. Otherwise rest of the logic is same.

Copy link
Contributor

@ifed01 ifed01 left a comment

Choose a reason for hiding this comment

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

LGTM except code style violation for 'else' statements in void BlueStore::get_db_histogram

@varadakari
Copy link
Contributor Author

@ifed01 Thanks for review, fixed the styling of if-else.

@varadakari
Copy link
Contributor Author

i am not hitting this compilation error in my local copy. will rebase and try it again.

@varadakari
Copy link
Contributor Author

Fixed all the issues and all tests are passing now.

@liewegas liewegas changed the title BlueStore kvdb histogram os/bluestore: kvdb histogram Dec 29, 2016
@varadakari
Copy link
Contributor Author

jenkins retest this please

@varadakari
Copy link
Contributor Author

@liewegas could you please take look at this?


const string PREFIX_ONODE = "o";
const string PREFIX_ONODE_SHARD = "x";
const string PREFIX_OTHER = "Z";
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps instead of #defineing more of these we should just use strings ("onode", "other", etc.)?


map<string, map<int, struct key_dist> > key_hist;
map<int, uint64_t> value_hist; // only value distribution histogram
Copy link
Member

Choose a reason for hiding this comment

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

Can we put the histogram bits into a class? Should be able to include update_hist_entry?

@@ -1939,6 +1939,8 @@ bool OSD::asok_command(string command, cmdmap_t& cmdmap, string format,
store->get_db_statistics(f);
} else if (command == "dump_scrubs") {
service.dumps_scrub(f);
} else if (command == "dump_objectstore_db_histogram") {
Copy link
Member

Choose a reason for hiding this comment

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

It might be a good idea to rename this something like "calculate_objectstore_db_histogram" to better suggest/convey that this is a very slow operation?

Varada Kari added 3 commits January 12, 2017 13:52
Signed-off-by: Varada Kari <varada.kari@sandisk.com>
Improves the presentation of rocksdb dump statistics

Signed-off-by: Varada Kari <varada.kari@sandisk.com>
Avoids converting the key and value to string or bufferlist

Signed-off-by: Varada Kari <varada.kari@sandisk.com>
@varadakari
Copy link
Contributor Author

@liewegas Made the changes and repushed after rebasing, could you please review again?

@varadakari
Copy link
Contributor Author

jenkins retest this please

Copy link
Member

@liewegas liewegas left a comment

Choose a reason for hiding this comment

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

Few more nits, but otherwise looks good!

f->dump_unsigned("total_value_size", total_value_size);
f->close_section();

f->open_object_section("rocksdb value distribution");
Copy link
Member

Choose a reason for hiding this comment

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

no spaces in formatter fields names please

f->open_object_section("rocksdb key-value histogram");
for (auto i : hist.key_hist) {
f->dump_string("prefix", i.first);
f->open_object_section("key-hist");
Copy link
Member

Choose a reason for hiding this comment

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

_ not -

f->close_section();

f->open_object_section("rocksdb key-value histogram");
for (auto i : hist.key_hist) {
Copy link
Member

Choose a reason for hiding this comment

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

the dump of the histogram itself should be DBHistogram::dump()

@@ -1496,6 +1496,30 @@ class BlueStore : public ObjectStore,
}
};

struct DBHistogram {
struct value_dist
{
Copy link
Member

Choose a reason for hiding this comment

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

{ on previous line

{
uint64_t count;
uint32_t max_len;
map<int, struct value_dist> val_map; // slab id to count and others
Copy link
Member

Choose a reason for hiding this comment

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

these comments should be like ///< so the doc generation can do its thing

Adding a asok to command to dump the key value distribution in a
histogram fashion.

Signed-off-by: Varada Kari <varada.kari@sandisk.com>
@varadakari
Copy link
Contributor Author

@liewegas Addressed the comments. Please have relook at the changes.

@liewegas
Copy link
Member

Can you add a test to store_test.cc that triggers this so that the code path is tested?

@liewegas liewegas removed the needs-qa label Jan 13, 2017
@liewegas
Copy link
Member

@varadakari ping

Varada Kari added 2 commits January 18, 2017 14:28
Signed-off-by: Varada Kari <varada.kari@sandisk.com>
Signed-off-by: Varada Kari <varada.kari@sandisk.com>
@varadakari
Copy link
Contributor Author

@liewegas Added the unit test cases for stats and histogram. Please have a look.

@ceph-jenkins
Copy link
Collaborator

submodules for project are unmodified

@varadakari
Copy link
Contributor Author

@liewegas if the tests are complete, could you merge this please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants