mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
celldb in-memory mode, stats for actors, perf counters, minor fix in rldp2 (#1164)
* getactorstats query for validator-engine-console * celldb in-memory mode (--celldb-in-memory option) * rldp2: bugfix - do not estimate speed while nothing is sent * add simple ed25519 benchmark * fix compilation errors of different platforms and move to c++20 * fix some warnings * turn on TON_USE_ABSEIL for glibc 2.27 nix build --------- Co-authored-by: birydrad <>
This commit is contained in:
parent
5f51d3d04f
commit
72020c04c4
100 changed files with 3407 additions and 359 deletions
|
@ -137,4 +137,55 @@ class NamedThreadSafeCounter {
|
|||
Counter counter_;
|
||||
};
|
||||
|
||||
// another class for simplicity, it
|
||||
struct NamedPerfCounter {
|
||||
public:
|
||||
static NamedPerfCounter &get_default() {
|
||||
static NamedPerfCounter res;
|
||||
return res;
|
||||
}
|
||||
struct PerfCounterRef {
|
||||
NamedThreadSafeCounter::CounterRef count;
|
||||
NamedThreadSafeCounter::CounterRef duration;
|
||||
};
|
||||
PerfCounterRef get_counter(Slice name) {
|
||||
return {.count = counter_.get_counter(PSLICE() << name << ".count"),
|
||||
.duration = counter_.get_counter(PSLICE() << name << ".duration")};
|
||||
}
|
||||
|
||||
struct ScopedPerfCounterRef : public NoCopyOrMove {
|
||||
PerfCounterRef perf_counter;
|
||||
uint64 started_at_ticks{td::Clocks::rdtsc()};
|
||||
|
||||
~ScopedPerfCounterRef() {
|
||||
perf_counter.count.add(1);
|
||||
perf_counter.duration.add(td::Clocks::rdtsc() - started_at_ticks);
|
||||
}
|
||||
};
|
||||
|
||||
template <class F>
|
||||
void for_each(F &&f) const {
|
||||
counter_.for_each(f);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
counter_.clear();
|
||||
}
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &sb, const NamedPerfCounter &counter) {
|
||||
return sb << counter.counter_;
|
||||
}
|
||||
private:
|
||||
NamedThreadSafeCounter counter_;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
||||
#define TD_PERF_COUNTER(name) \
|
||||
static auto perf_##name = td::NamedPerfCounter::get_default().get_counter(td::Slice(#name)); \
|
||||
auto scoped_perf_##name = td::NamedPerfCounter::ScopedPerfCounterRef{.perf_counter = perf_##name};
|
||||
|
||||
#define TD_PERF_COUNTER_SINCE(name, since) \
|
||||
static auto perf_##name = td::NamedPerfCounter::get_default().get_counter(td::Slice(#name)); \
|
||||
auto scoped_perf_##name = \
|
||||
td::NamedPerfCounter::ScopedPerfCounterRef{.perf_counter = perf_##name, .started_at_ticks = since};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue