diff --git a/validator/db/celldb.cpp b/validator/db/celldb.cpp index d997496dc..5f4e57828 100644 --- a/validator/db/celldb.cpp +++ b/validator/db/celldb.cpp @@ -468,16 +468,18 @@ void CellDb::load_cell(RootHash hash, td::Promise> promise 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) << "yus " << 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; } if (!started_) { LOG(INFO) << " load_cell: counter" << counter_ << ", 2"; - td::actor::send_closure(cell_db_read_[ranNum], &CellDbIn::load_cell, hash, std::move(promise)); + // td::actor::send_closure(cell_db_read_[ranNum], &CellDbIn::load_cell, hash, std::move(promise)); + td::actor::send_closure(cell_db_, &CellDbIn::load_cell, hash, std::move(promise)); } else { LOG(INFO) << " load_cell: counter" << counter_ << ", 3"; auto P = td::PromiseCreator::lambda( - [cell_db_in = cell_db_read_[ranNum].get(), hash, promise = std::move(promise), counter_](td::Result> R) mutable { + [cell_db_in = cell_db_.get(), hash, promise = std::move(promise), counter_](td::Result> R) mutable { LOG(INFO) << " load_cell: counter" << counter_ << ", 5"; if (R.is_error()) { LOG(DEBUG) << "yus err then send to cell db in"; @@ -512,23 +514,23 @@ void CellDb::start_up() { boc_ = vm::DynamicBagOfCellsDb::create(); boc_->set_celldb_compress_depth(opts_->get_celldb_compress_depth()); - td::RocksDbOptions db_options; - auto statistics_ = td::RocksDb::create_statistics(); - if (!opts_->get_disable_rocksdb_stats()) { - db_options.snapshot_statistics = std::make_shared(); - } - db_options.statistics = statistics_; - if (opts_->get_celldb_cache_size()) { - db_options.block_cache = td::RocksDb::create_cache(opts_->get_celldb_cache_size().value()); - LOG(WARNING) << "Set CellDb block cache size to " << td::format::as_size(opts_->get_celldb_cache_size().value()); - } - db_options.use_direct_reads = opts_->get_celldb_direct_io(); - auto rock_db = std::make_shared(td::RocksDb::open(path_, std::move(db_options)).move_as_ok()); - - cell_db_ = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_, rock_db); - for (int i = 0; i < 1000; i++) { - cell_db_read_[i] = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_, rock_db); - } + // td::RocksDbOptions db_options; + // auto statistics_ = td::RocksDb::create_statistics(); + // if (!opts_->get_disable_rocksdb_stats()) { + // db_options.snapshot_statistics = std::make_shared(); + // } + // db_options.statistics = statistics_; + // if (opts_->get_celldb_cache_size()) { + // db_options.block_cache = td::RocksDb::create_cache(opts_->get_celldb_cache_size().value()); + // LOG(WARNING) << "Set CellDb block cache size to " << td::format::as_size(opts_->get_celldb_cache_size().value()); + // } + // db_options.use_direct_reads = opts_->get_celldb_direct_io(); + // auto rock_db = std::make_shared(td::RocksDb::open(path_, std::move(db_options)).move_as_ok()); + + cell_db_ = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_, rocks_db_); + // for (int i = 0; i < 10; i++) { + // cell_db_read_[i] = td::actor::create_actor("celldbin", root_db_, actor_id(this), path_, opts_, rock_db); + // } on_load_callback_ = [actor = std::make_shared>( td::actor::create_actor("celldbmigration", cell_db_.get())), diff --git a/validator/db/celldb.hpp b/validator/db/celldb.hpp index 70220049b..8256d9fe4 100644 --- a/validator/db/celldb.hpp +++ b/validator/db/celldb.hpp @@ -171,8 +171,8 @@ class CellDb : public CellDbBase { void get_cell_db_reader(td::Promise> promise); void get_last_deleted_mc_state(td::Promise promise); - CellDb(td::actor::ActorId root_db, std::string path, td::Ref opts) - : root_db_(root_db), path_(path), opts_(opts) { + CellDb(td::actor::ActorId root_db, std::string path, td::Ref opts, std::shared_ptr rocks_db) + : root_db_(root_db), path_(path), opts_(opts), rocks_db_(rocks_db) { } void start_up() override; @@ -184,6 +184,7 @@ class CellDb : public CellDbBase { td::actor::ActorOwn cell_db_; td::actor::ActorOwn cell_db_read_[1000]; + std::shared_ptr rocks_db_; std::unique_ptr boc_; bool started_ = false; diff --git a/validator/db/rootdb.cpp b/validator/db/rootdb.cpp index d41068465..66a15abdf 100644 --- a/validator/db/rootdb.cpp +++ b/validator/db/rootdb.cpp @@ -26,6 +26,8 @@ #include "common/checksum.h" #include "validator/stats-merger.h" #include "td/actor/MultiPromise.h" +#include +#include namespace ton { @@ -248,6 +250,14 @@ void RootDb::store_block_state(BlockHandle handle, td::Ref state, } } +int getRandom(){ + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> distr(0, 99); + int random_number = distr(gen); + return random_number; +} + void RootDb::get_block_state(ConstBlockHandle handle, td::Promise> promise, std::uint64_t counter_) { LOG(INFO) << "get_block_state, counter" << counter_ << ", 1"; if (handle->inited_state_boc()) { @@ -273,7 +283,16 @@ void RootDb::get_block_state(ConstBlockHandle handle, td::Promisestate(), std::move(P), counter_); + + int ranNum = getRandom(); + 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; + ranCount = 0; + } + + td::actor::send_closure(cell_db_read_[ranNum], &CellDb::load_cell, handle->state(), std::move(P), counter_); LOG(INFO) << "get_block_state, counter" << counter_ << ", 4-1"; } else { LOG(INFO) << "get_block_state, counter" << counter_ << ", 7-0"; @@ -424,7 +443,26 @@ void RootDb::get_hardforks(td::Promise> promise) { } void RootDb::start_up() { - cell_db_ = td::actor::create_actor("celldb", actor_id(this), root_path_ + "/celldb/", opts_); + + td::RocksDbOptions db_options; + auto statistics_ = td::RocksDb::create_statistics(); + if (!opts_->get_disable_rocksdb_stats()) { + db_options.snapshot_statistics = std::make_shared(); + } + db_options.statistics = statistics_; + if (opts_->get_celldb_cache_size()) { + db_options.block_cache = td::RocksDb::create_cache(opts_->get_celldb_cache_size().value()); + LOG(WARNING) << "Set CellDb block cache size to " << td::format::as_size(opts_->get_celldb_cache_size().value()); + } + db_options.use_direct_reads = opts_->get_celldb_direct_io(); + auto path = root_path_ + "/celldb/"; + auto rock_db = std::make_shared(td::RocksDb::open(path, std::move(db_options)).move_as_ok()); + + cell_db_ = td::actor::create_actor("celldb", actor_id(this), path, opts_, rock_db); + for (int i = 0; i < 100; i++){ + cell_db_read_[i] = td::actor::create_actor("celldb", actor_id(this), path, opts_, rock_db); + } + state_db_ = td::actor::create_actor("statedb", actor_id(this), root_path_ + "/state/"); static_files_db_ = td::actor::create_actor("staticfilesdb", actor_id(this), root_path_ + "/static/"); archive_db_ = td::actor::create_actor("archive", actor_id(this), root_path_, opts_); diff --git a/validator/db/rootdb.hpp b/validator/db/rootdb.hpp index 02349c038..b8aae5bc0 100644 --- a/validator/db/rootdb.hpp +++ b/validator/db/rootdb.hpp @@ -145,6 +145,7 @@ class RootDb : public Db { td::Ref opts_; td::actor::ActorOwn cell_db_; + td::actor::ActorOwn cell_db_read_[100]; td::actor::ActorOwn state_db_; td::actor::ActorOwn static_files_db_; td::actor::ActorOwn archive_db_;