1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Improve validator session stats

* Collator stats: block limits, number of processed external messages
* Collator and validator work time
* Last key block seqno
* Approvers and signers
This commit is contained in:
SpyCheese 2024-08-19 18:35:50 +03:00
parent 06515c3735
commit 0ca022cc72
15 changed files with 276 additions and 24 deletions

View file

@ -91,4 +91,47 @@ double PerfWarningTimer::elapsed() const {
return Time::now() - start_at_;
}
static double thread_cpu_clock() {
#if defined(CLOCK_THREAD_CPUTIME_ID)
timespec ts;
int result = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
CHECK(result == 0);
return (double)ts.tv_sec + (double)ts.tv_nsec * 1e-9;
#else
return 0.0; // TODO: MacOS and Windows support (currently cpu timer is used only in validators)
#endif
}
ThreadCpuTimer::ThreadCpuTimer(bool is_paused) : is_paused_(is_paused) {
if (is_paused_) {
start_time_ = 0;
} else {
start_time_ = thread_cpu_clock();
}
}
void ThreadCpuTimer::pause() {
if (is_paused_) {
return;
}
elapsed_ += thread_cpu_clock() - start_time_;
is_paused_ = true;
}
void ThreadCpuTimer::resume() {
if (!is_paused_) {
return;
}
start_time_ = thread_cpu_clock();
is_paused_ = false;
}
double ThreadCpuTimer::elapsed() const {
double res = elapsed_;
if (!is_paused_) {
res += thread_cpu_clock() - start_time_;
}
return res;
}
} // namespace td