mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add more stats to validator getstats
1) Liteserver queries count 2) Collated/validated blocks count, number of active sessions 3) Persistent state sizes 4) Initial sync progress
This commit is contained in:
parent
ce6c29941e
commit
9d94e04d20
26 changed files with 365 additions and 45 deletions
|
@ -1196,6 +1196,30 @@ void ArchiveManager::set_async_mode(bool mode, td::Promise<td::Unit> promise) {
|
|||
}
|
||||
}
|
||||
|
||||
void ArchiveManager::prepare_stats(td::Promise<std::vector<std::pair<std::string, std::string>>> promise) {
|
||||
std::vector<std::pair<std::string, std::string>> stats;
|
||||
{
|
||||
std::map<BlockSeqno, td::uint64> states;
|
||||
for (auto &[key, file] : perm_states_) {
|
||||
BlockSeqno seqno = key.first;
|
||||
auto r_stat = td::stat(db_root_ + "/archive/states/" + file.filename_short());
|
||||
if (r_stat.is_error()) {
|
||||
LOG(WARNING) << "Cannot stat persistent state file " << file.filename_short() << " : " << r_stat.move_as_error();
|
||||
} else {
|
||||
states[seqno] += r_stat.move_as_ok().size_;
|
||||
}
|
||||
}
|
||||
td::StringBuilder sb;
|
||||
for (auto &[seqno, size] : states) {
|
||||
sb << seqno << ":" << td::format::as_size(size) << " ";
|
||||
}
|
||||
if (!sb.as_cslice().empty()) {
|
||||
stats.emplace_back("persistent_states", sb.as_cslice().str());
|
||||
}
|
||||
}
|
||||
promise.set_value(std::move(stats));
|
||||
}
|
||||
|
||||
void ArchiveManager::truncate(BlockSeqno masterchain_seqno, ConstBlockHandle handle, td::Promise<td::Unit> promise) {
|
||||
index_->begin_transaction().ensure();
|
||||
td::MultiPromise mp;
|
||||
|
|
|
@ -81,6 +81,8 @@ class ArchiveManager : public td::actor::Actor {
|
|||
cur_shard_split_depth_ = value;
|
||||
}
|
||||
|
||||
void prepare_stats(td::Promise<std::vector<std::pair<std::string, std::string>>> promise);
|
||||
|
||||
static constexpr td::uint32 archive_size() {
|
||||
return 20000;
|
||||
}
|
||||
|
|
|
@ -158,6 +158,17 @@ void CellDbIn::start_up() {
|
|||
},
|
||||
td::Timestamp::now());
|
||||
}
|
||||
|
||||
{
|
||||
std::string key = "stats.last_deleted_mc_seqno", value;
|
||||
auto R = cell_db_->get(td::as_slice(key), value);
|
||||
R.ensure();
|
||||
if (R.ok() == td::KeyValue::GetStatus::Ok) {
|
||||
auto r_value = td::to_integer_safe<BlockSeqno>(value);
|
||||
r_value.ensure();
|
||||
last_deleted_mc_state_ = r_value.move_as_ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CellDbIn::load_cell(RootHash hash, td::Promise<td::Ref<vm::DataCell>> promise) {
|
||||
|
@ -452,6 +463,11 @@ void CellDbIn::gc_cont2(BlockHandle handle) {
|
|||
cell_db_->erase(get_key(key_hash)).ensure();
|
||||
set_block(F.prev, std::move(P));
|
||||
set_block(F.next, std::move(N));
|
||||
if (handle->id().is_masterchain()) {
|
||||
last_deleted_mc_state_ = handle->id().seqno();
|
||||
std::string key = "stats.last_deleted_mc_seqno", value = td::to_string(last_deleted_mc_state_);
|
||||
cell_db_->set(td::as_slice(key), td::as_slice(value));
|
||||
}
|
||||
cell_db_->commit_write_batch().ensure();
|
||||
alarm_timestamp() = td::Timestamp::now();
|
||||
timer_write_batch.reset();
|
||||
|
@ -475,9 +491,6 @@ void CellDbIn::gc_cont2(BlockHandle handle) {
|
|||
if (!opts_->get_disable_rocksdb_stats()) {
|
||||
cell_db_statistics_.gc_cell_time_.insert(timer.elapsed() * 1e6);
|
||||
}
|
||||
if (handle->id().is_masterchain()) {
|
||||
last_deleted_mc_state_ = handle->id().seqno();
|
||||
}
|
||||
LOG(DEBUG) << "Deleted state " << handle->id().to_str();
|
||||
timer_finish.reset();
|
||||
timer_all.reset();
|
||||
|
|
|
@ -438,6 +438,7 @@ void RootDb::allow_block_gc(BlockIdExt block_id, td::Promise<bool> promise) {
|
|||
void RootDb::prepare_stats(td::Promise<std::vector<std::pair<std::string, std::string>>> promise) {
|
||||
auto merger = StatsMerger::create(std::move(promise));
|
||||
td::actor::send_closure(cell_db_, &CellDb::prepare_stats, merger.make_promise("celldb."));
|
||||
td::actor::send_closure(archive_db_, &ArchiveManager::prepare_stats, merger.make_promise("archive."));
|
||||
}
|
||||
|
||||
void RootDb::truncate(BlockSeqno seqno, ConstBlockHandle handle, td::Promise<td::Unit> promise) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue