Commit 4738e257 authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Implement command to show per-compaction-level compression ratio

parent d463b749
Pipeline #419299 passed with stages
in 29 minutes and 54 seconds
......@@ -126,6 +126,7 @@ struct cmdMapInit {
redis_cmd_map["quarkdb_invalid_command"] = {RedisCommand::QUARKDB_INVALID_COMMAND, CommandType::QUARKDB};
redis_cmd_map["quarkdb_manual_compaction"] = {RedisCommand::QUARKDB_MANUAL_COMPACTION, CommandType::QUARKDB};
redis_cmd_map["quarkdb_level_stats"] = {RedisCommand::QUARKDB_LEVEL_STATS, CommandType::QUARKDB};
redis_cmd_map["quarkdb_compression_stats"] = {RedisCommand::QUARKDB_COMPRESSION_STATS, CommandType::QUARKDB};
redis_cmd_map["recovery_info"] = {RedisCommand::RECOVERY_INFO, CommandType::RECOVERY};
redis_cmd_map["recovery_set"] = {RedisCommand::RECOVERY_SET, CommandType::RECOVERY};
......
......@@ -128,6 +128,7 @@ enum class RedisCommand {
QUARKDB_INVALID_COMMAND, // used in tests
QUARKDB_MANUAL_COMPACTION,
QUARKDB_LEVEL_STATS,
QUARKDB_COMPRESSION_STATS,
RECOVERY_GET,
RECOVERY_SET,
......
......@@ -208,6 +208,21 @@ LinkStatus Shard::dispatch(Connection *conn, RedisRequest &req) {
return conn->status(stateMachine->levelStats());
}
case RedisCommand::QUARKDB_COMPRESSION_STATS: {
if(req.size() != 1) return conn->errArgs(req[0]);
InFlightRegistration registration(inFlightTracker);
if(!registration.ok()) {
return conn->err("unavailable");
}
std::ostringstream ss;
std::vector<std::string> stats = stateMachine->compressionStats();
for(size_t i = 0; i < stats.size(); i++) {
ss << "Level " << i << ": " << stats[i] << std::endl;
}
return conn->status(ss.str());
}
default: {
if(req.getCommandType() == CommandType::QUARKDB) {
qdb_critical("Unable to dispatch command '" << req[0] << "' of type QUARKDB");
......
......@@ -1229,6 +1229,18 @@ std::string StateMachine::levelStats() {
return stats;
}
std::vector<std::string> StateMachine::compressionStats() {
std::vector<std::string> results;
for(size_t i = 0; i <= 6; i++) {
std::string tmp;
db->GetProperty(SSTR(rocksdb::DB::Properties::kCompressionRatioAtLevelPrefix << i), &tmp);
results.emplace_back(tmp);
}
return results;
}
rocksdb::Status StateMachine::noop(LogIndex index) {
StagingArea stagingArea(*this);
return stagingArea.commit(index);
......
......@@ -173,6 +173,11 @@ public:
//----------------------------------------------------------------------------
std::string levelStats();
//----------------------------------------------------------------------------
// Get compression stats
//----------------------------------------------------------------------------
std::vector<std::string> compressionStats();
bool inBulkLoad() const {
return bulkLoad;
}
......
......@@ -937,6 +937,7 @@ TEST_F(Raft_e2e, smove) {
ASSERT_REPLY(tunnel(leaderID)->exec("smembers", "set2"), make_vec("i1", "t1", "t2", "t3", "t4", "t5"));
ASSERT_REPLY(tunnel(leaderID)->exec("quarkdb-manual-compaction"), "OK");
qdb_info(qclient::describeRedisReply(tunnel(leaderID)->exec("quarkdb-level-stats").get()));
qdb_info(qclient::describeRedisReply(tunnel(leaderID)->exec("quarkdb-compression-stats").get()));
}
TEST_F(Raft_e2e, sscan) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment