Skip to content

Commit

Permalink
Add PrintTerarkCacheState
Browse files Browse the repository at this point in the history
  • Loading branch information
vrofze committed Sep 26, 2018
1 parent 542ec65 commit e7c3c01
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/engine/src/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <terark/util/autoclose.hpp>
#include <terark/util/linebuf.hpp>
#include <terark/util/profiling.hpp>
#include "analysis_worker.h"

using namespace terark;

Expand All @@ -30,8 +31,10 @@ void Benchmark::adjustThreadNum(uint32_t target, const std::atomic<std::vector<b
state->whichPlan.store(0,std::memory_order_relaxed);
threads.emplace_back(std::thread([=](){ReadWhileWriting(state);}), state);
}
for (size_t i = target; i < threads.size(); ++i){
threads[i].second->STOP.store(true);
}
while (target < threads.size()){
threads.back().second->STOP.store(true);
threads.back().first.join();
delete threads.back().second;
threads.pop_back();
Expand Down Expand Up @@ -468,3 +471,8 @@ void Benchmark::checkExecutePlan() {
eachThread.second->whichPlan.store(!which);
}
};

void Benchmark::PrintCacheState()
{
fprintf(stderr, "%s\n", "There no cache state to print");
}
2 changes: 2 additions & 0 deletions src/engine/src/Benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class Benchmark : boost::noncopyable {

virtual std::string HandleMessage(const std::string &msg);

virtual void PrintCacheState(void);

private:
terark::Auto_fclose _shufKeyIfs;
};
Expand Down
2 changes: 1 addition & 1 deletion src/engine/src/RocksDbBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class RocksDbBenchmark : public Benchmark {
private:
rocksdb::DB *db;
rocksdb::WriteOptions write_options;
rocksdb::ReadOptions read_options;
void setRocksDBOptions(Setting& set);
protected:
rocksdb::DB *db;
rocksdb::Options options;
public:
~RocksDbBenchmark();
Expand Down
7 changes: 6 additions & 1 deletion src/engine/src/TcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ void Session::read_line_handler(const boost::system::error_code& ec,std::size_t
std::getline(is, line);
fprintf(stderr, "Get: %s\n", line.c_str());
std::string message;
message = setting->setBaseSetting(line);
if (!line.compare("print cache state")) {
benchmark->PrintCacheState();
message = "print cache state success\n";
} else {
message = setting->setBaseSetting(line);
}
message += "\nEND\r\n";
do_write(message);
}
Expand Down
19 changes: 19 additions & 0 deletions src/engine/src/TerocksBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ TerocksBenchmark::TerocksBenchmark(Setting& set) : RocksDbBenchmark(set) {
setting.dbdirs.push_back(opt.localTempDir);
}

void TerocksBenchmark::Close()
{
PrintTerarkdbCacheState();
RocksDbBenchmark::Close();
}

void TerocksBenchmark::PrintCacheState()
{
PrintTerarkdbCacheState();
}

void TerocksBenchmark::PrintTerarkdbCacheState()
{
FILE *file = fopen("/dev/stderr", "w");
fprintf(stderr, "%s\n", "call TerarkZipTablePrintCacheStat");
rocksdb::TerarkZipTablePrintCacheStat(db->GetOptions().table_factory.get(), file);
fclose(file);
}

std::string TerocksBenchmark::HandleMessage(const std::string &msg) {
std::stringstream ss;
if (msg.empty())
Expand Down
4 changes: 4 additions & 0 deletions src/engine/src/TerocksBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ class TerocksBenchmark : public RocksDbBenchmark {
std::string getIndexNestLevel(void);
bool setEstimateCompressionRatio(const std::string &);
std::string getEstimateCompressionRatio(void);

void PrintTerarkdbCacheState();
public:
TerocksBenchmark(Setting& set);
void Close() override;
void PrintCacheState() override ;
};


Expand Down

0 comments on commit e7c3c01

Please sign in to comment.