diff --git a/validator/db/celldb.cpp b/validator/db/celldb.cpp index b1293bf0f..f7da83c68 100644 --- a/validator/db/celldb.cpp +++ b/validator/db/celldb.cpp @@ -65,10 +65,10 @@ void CellDbBase::execute_sync(std::function f) { } CellDbIn::CellDbIn(td::actor::ActorId root_db, td::actor::ActorId parent, std::string path, - td::Ref opts) - : root_db_(root_db), parent_(parent), path_(std::move(path)), opts_(opts), std::shared_ptr cell_db{ + td::Ref opts, std::shared_ptr cell_db) + : root_db_(root_db), parent_(parent), path_(std::move(path)), opts_(opts){ if (cell_db != NULL) { - LOG(INFO) << "zjg: using provided KeyValue"; + LOG(INFO) << "Using provided cell_db"; cell_db_ = cell_db; } } @@ -102,7 +102,7 @@ void CellDbIn::start_up() { } db_options.use_direct_reads = opts_->get_celldb_direct_io(); if (cell_db_ == NULL){ - LOG(INFO) << "zjg: using new KeyValue"; + LOG(INFO) << "CellDbIn using a new rocksdb instance"; cell_db_ = std::make_shared(td::RocksDb::open(path_, std::move(db_options)).move_as_ok()); } @@ -444,20 +444,12 @@ void CellDbIn::migrate_cells() { } } -int GetRandom(){ - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<> distr(0, THREAD_COUNTS -1 ); - int random_number = distr(gen); - return random_number; -} - void CellDb::load_cell(RootHash hash, td::Promise> promise) { - int ranNum = GetRandom(); + int ranNum = GetDBRandomNum(); static int64_t ranCount = 0; ranCount++; if (ranCount % 1000 == 0) { - LOG(ERROR) << "yus " << this->get_name() << " " << this->get_actor_info_ptr()->mailbox().reader().calc_size() << ", ranNum: " << ranNum; + LOG(ERROR) << "CellDb mailbox: " << this->get_name() << " " << this->get_actor_info_ptr()->mailbox().reader().calc_size() << ", ranNum: " << ranNum; // LOG(ERROR) << "yus " << this->get_name() << " " << this->get_actor_info_ptr()->mailbox().reader().calc_size(); ranCount = 0; } @@ -492,7 +484,7 @@ void CellDb::start_up() { CellDbBase::start_up(); boc_ = vm::DynamicBagOfCellsDb::create(); boc_->set_celldb_compress_depth(opts_->get_celldb_compress_depth()); - cell_db_ = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_); + cell_db_ = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_, rocks_db_); // cell_db_ = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_, rocks_db_); for (int i = 0; i < THREAD_COUNTS; i++) { diff --git a/validator/db/celldb.hpp b/validator/db/celldb.hpp index 69810b80b..86901e226 100644 --- a/validator/db/celldb.hpp +++ b/validator/db/celldb.hpp @@ -28,19 +28,12 @@ #include "validator.h" #include "db-utils.h" #include "td/db/RocksDb.h" -#include -#include namespace rocksdb { class Statistics; } namespace ton { - -const int THREAD_COUNTS = 20; - -int GetRandom(); - namespace validator { class RootDb; @@ -74,7 +67,7 @@ class CellDbIn : public CellDbBase { void flush_db_stats(); CellDbIn(td::actor::ActorId root_db, td::actor::ActorId parent, std::string path, - td::Ref opts, std::shared_ptr cell_db, std::shared_ptr); + td::Ref opts, std::shared_ptr cell_db); void start_up() override; void alarm() override; diff --git a/validator/db/db-utils.cpp b/validator/db/db-utils.cpp index 9375f97e6..2e9d1f852 100644 --- a/validator/db/db-utils.cpp +++ b/validator/db/db-utils.cpp @@ -19,6 +19,8 @@ #include "td/utils/logging.h" #include +#include +#include namespace ton::validator { @@ -51,4 +53,12 @@ void PercentileStats::clear() { values_.clear(); } +int GetDBRandomNum(){ + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> distr(0, THREAD_COUNTS -1); + int random_number = distr(gen); + return random_number; +} + } // namespace ton::validator \ No newline at end of file diff --git a/validator/db/db-utils.h b/validator/db/db-utils.h index 8ffbf5c97..359fce80c 100644 --- a/validator/db/db-utils.h +++ b/validator/db/db-utils.h @@ -30,4 +30,8 @@ class PercentileStats { std::multiset values_; }; +const int THREAD_COUNTS = 10; +int GetDBRandomNum(); + + } // namespace ton::validator \ No newline at end of file diff --git a/validator/db/rootdb.cpp b/validator/db/rootdb.cpp index f7bc2b423..1f3ae0ab5 100644 --- a/validator/db/rootdb.cpp +++ b/validator/db/rootdb.cpp @@ -265,11 +265,11 @@ void RootDb::get_block_state(ConstBlockHandle handle, td::Promiseget_name() << " " << this->get_actor_info_ptr()->mailbox().reader().calc_size() << ", ranNum: " << ranNum; + LOG(ERROR) << "RootDb mailbox: " << this->get_name() << " " << this->get_actor_info_ptr()->mailbox().reader().calc_size() << ", ranNum: " << ranNum; ranCount = 0; }