mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
Log number of LS queries by type (#891)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
c38b2928ec
commit
e723213d5c
6 changed files with 73 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "td/utils/tl_storers.h"
|
||||
#include "td/utils/crypto.h"
|
||||
#include "crypto/common/bitstring.h"
|
||||
#include <map>
|
||||
|
||||
namespace ton {
|
||||
|
||||
|
@ -129,4 +130,37 @@ td::Bits256 get_tl_object_sha_bits256(const lite_api::Object *T) {
|
|||
return id256;
|
||||
}
|
||||
|
||||
std::string lite_query_name_by_id(int id) {
|
||||
static std::map<int, std::string> names = {
|
||||
{lite_api::liteServer_getMasterchainInfo::ID, "getMasterchainInfo"},
|
||||
{lite_api::liteServer_getMasterchainInfoExt::ID, "getMasterchainInfoExt"},
|
||||
{lite_api::liteServer_getTime::ID, "getTime"},
|
||||
{lite_api::liteServer_getVersion::ID, "getVersion"},
|
||||
{lite_api::liteServer_getBlock::ID, "getBlock"},
|
||||
{lite_api::liteServer_getState::ID, "getState"},
|
||||
{lite_api::liteServer_getBlockHeader::ID, "getBlockHeader"},
|
||||
{lite_api::liteServer_sendMessage::ID, "sendMessage"},
|
||||
{lite_api::liteServer_getAccountState::ID, "getAccountState"},
|
||||
{lite_api::liteServer_getAccountStatePrunned::ID, "getAccountStatePrunned"},
|
||||
{lite_api::liteServer_runSmcMethod::ID, "runSmcMethod"},
|
||||
{lite_api::liteServer_getShardInfo::ID, "getShardInfo"},
|
||||
{lite_api::liteServer_getAllShardsInfo::ID, "getAllShardsInfo"},
|
||||
{lite_api::liteServer_getOneTransaction::ID, "getOneTransaction"},
|
||||
{lite_api::liteServer_getTransactions::ID, "getTransactions"},
|
||||
{lite_api::liteServer_lookupBlock::ID, "lookupBlock"},
|
||||
{lite_api::liteServer_listBlockTransactions::ID, "listBlockTransactions"},
|
||||
{lite_api::liteServer_listBlockTransactionsExt::ID, "listBlockTransactionsExt"},
|
||||
{lite_api::liteServer_getBlockProof::ID, "getBlockProof"},
|
||||
{lite_api::liteServer_getConfigAll::ID, "getConfigAll"},
|
||||
{lite_api::liteServer_getConfigParams::ID, "getConfigParams"},
|
||||
{lite_api::liteServer_getValidatorStats::ID, "getValidatorStats"},
|
||||
{lite_api::liteServer_getLibraries::ID, "getLibraries"},
|
||||
{lite_api::liteServer_getShardBlockProof::ID, "getShardBlockProof"}};
|
||||
auto it = names.find(id);
|
||||
if (it == names.end()) {
|
||||
return "unknown";
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
} // namespace ton
|
||||
|
|
|
@ -46,4 +46,6 @@ template <class Tp, std::enable_if_t<std::is_base_of<lite_api::Object, Tp>::valu
|
|||
td::Bits256 get_tl_object_sha_bits256(const Tp &T) {
|
||||
return get_tl_object_sha_bits256(static_cast<const lite_api::Object *>(&T));
|
||||
}
|
||||
|
||||
std::string lite_query_name_by_id(int id);
|
||||
} // namespace ton
|
||||
|
|
|
@ -131,9 +131,11 @@ void LiteQuery::start_up() {
|
|||
|
||||
auto F = fetch_tl_object<ton::lite_api::Function>(std::move(query_), true);
|
||||
if (F.is_error()) {
|
||||
td::actor::send_closure(manager_, &ValidatorManager::add_lite_query_stats, 0); // unknown
|
||||
abort_query(F.move_as_error());
|
||||
return;
|
||||
}
|
||||
td::actor::send_closure(manager_, &ValidatorManager::add_lite_query_stats, F.ok()->get_id());
|
||||
|
||||
lite_api::downcast_call(
|
||||
*F.move_as_ok().get(),
|
||||
|
|
|
@ -178,6 +178,9 @@ class ValidatorManager : public ValidatorManagerInterface {
|
|||
virtual void get_block_by_seqno_from_db_for_litequery(AccountIdPrefixFull account, BlockSeqno seqno,
|
||||
td::Promise<ConstBlockHandle> promise) = 0;
|
||||
|
||||
virtual void add_lite_query_stats(int lite_query_id) {
|
||||
}
|
||||
|
||||
static bool is_persistent_state(UnixTime ts, UnixTime prev_ts) {
|
||||
return ts / (1 << 17) != prev_ts / (1 << 17);
|
||||
}
|
||||
|
|
|
@ -401,6 +401,7 @@ void ValidatorManagerImpl::add_external_message(td::Ref<ExtMessage> msg) {
|
|||
}
|
||||
}
|
||||
void ValidatorManagerImpl::check_external_message(td::BufferSlice data, td::Promise<td::Ref<ExtMessage>> promise) {
|
||||
++ls_stats_check_ext_messages_;
|
||||
auto state = do_get_last_liteserver_state();
|
||||
if (state.is_null()) {
|
||||
promise.set_error(td::Status::Error(ErrorCode::notready, "not ready"));
|
||||
|
@ -2466,6 +2467,29 @@ void ValidatorManagerImpl::alarm() {
|
|||
}
|
||||
}
|
||||
alarm_timestamp().relax(check_shard_clients_);
|
||||
|
||||
if (log_ls_stats_at_.is_in_past()) {
|
||||
if (!ls_stats_.empty() || ls_stats_check_ext_messages_ != 0) {
|
||||
td::StringBuilder sb;
|
||||
sb << "Liteserver stats (1 minute):";
|
||||
td::uint32 total = 0;
|
||||
for (const auto &p : ls_stats_) {
|
||||
sb << " " << lite_query_name_by_id(p.first) << ":" << p.second;
|
||||
total += p.second;
|
||||
}
|
||||
if (total > 0) {
|
||||
sb << " TOTAL:" << total;
|
||||
}
|
||||
if (ls_stats_check_ext_messages_ > 0) {
|
||||
sb << " checkExtMessage:" << ls_stats_check_ext_messages_;
|
||||
}
|
||||
LOG(WARNING) << sb.as_cslice();
|
||||
}
|
||||
ls_stats_.clear();
|
||||
ls_stats_check_ext_messages_ = 0;
|
||||
log_ls_stats_at_ = td::Timestamp::in(60.0);
|
||||
}
|
||||
alarm_timestamp().relax(log_ls_stats_at_);
|
||||
}
|
||||
|
||||
void ValidatorManagerImpl::update_shard_client_state(BlockIdExt masterchain_block_id, td::Promise<td::Unit> promise) {
|
||||
|
|
|
@ -575,6 +575,10 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
td::Result<ConstBlockHandle> r_handle,
|
||||
td::Promise<ConstBlockHandle> promise);
|
||||
|
||||
void add_lite_query_stats(int lite_query_id) override {
|
||||
++ls_stats_[lite_query_id];
|
||||
}
|
||||
|
||||
private:
|
||||
td::Timestamp resend_shard_blocks_at_;
|
||||
td::Timestamp check_waiters_at_;
|
||||
|
@ -640,6 +644,10 @@ class ValidatorManagerImpl : public ValidatorManager {
|
|||
private:
|
||||
std::map<BlockSeqno, WaitList<td::actor::Actor, td::Unit>> shard_client_waiters_;
|
||||
td::actor::ActorOwn<QueueSizeCounter> queue_size_counter_;
|
||||
|
||||
td::Timestamp log_ls_stats_at_;
|
||||
std::map<int, td::uint32> ls_stats_; // lite_api ID -> count, 0 for unknown
|
||||
td::uint32 ls_stats_check_ext_messages_{0};
|
||||
};
|
||||
|
||||
} // namespace validator
|
||||
|
|
Loading…
Reference in a new issue