Skip to content

Commit d574077

Browse files
committed
Add more metrics for account/storage touched/changed
1 parent 3c07b29 commit d574077

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

category/execution/ethereum/db/db_cache.hpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class DbCache final : public Db
6868
AccountsCache accounts_{10'000'000};
6969
StorageCache storage_{10'000'000};
7070
Proposals proposals_;
71+
size_t account_touched_{0};
72+
size_t account_changed_{0};
73+
size_t storage_touched_{0};
74+
size_t storage_changed_{0};
7175

7276
public:
7377
DbCache(Db &db)
@@ -216,26 +220,46 @@ class DbCache final : public Db
216220
virtual std::string print_stats() override
217221
{
218222
return db_.print_stats() + ",ac=" + accounts_.print_stats() +
219-
",sc=" + storage_.print_stats();
223+
",sc=" + storage_.print_stats() + print_read_write_stats();
220224
}
221225

222226
virtual uint64_t get_block_number() const override
223227
{
224228
return db_.get_block_number();
225229
}
226230

231+
std::string print_read_write_stats() const
232+
{
233+
return ",at=" + std::to_string(account_touched_) +
234+
",am=" + std::to_string(account_changed_) +
235+
",st=" + std::to_string(storage_touched_) +
236+
",sm=" + std::to_string(storage_changed_);
237+
}
238+
227239
private:
228240
void insert_in_lru_caches(StateDeltas const &state_deltas)
229241
{
242+
account_touched_ = 0;
243+
account_changed_ = 0;
244+
storage_touched_ = 0;
245+
storage_changed_ = 0;
230246
for (auto it = state_deltas.cbegin(); it != state_deltas.cend(); ++it) {
231247
auto const &address = it->first;
232248
auto const &account_delta = it->second.account;
233249
accounts_.insert(address, account_delta.second);
234250
auto const &storage = it->second.storage;
235251
auto const &account = account_delta.second;
236252
if (account.has_value()) {
253+
++account_touched_;
254+
if (account_delta.first != account_delta.second) {
255+
++account_changed_;
256+
}
237257
for (auto it2 = storage.cbegin(); it2 != storage.cend();
238258
++it2) {
259+
++storage_touched_;
260+
if (it2->second.first != it2->second.second) {
261+
++storage_changed_;
262+
}
239263
auto const &key = it2->first;
240264
auto const &storage_delta = it2->second;
241265
auto const incarnation = account->incarnation;

category/execution/ethereum/metrics/block_metrics.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class BlockMetrics
4646
{
4747
return tx_exec_time_;
4848
}
49+
4950
};
5051

5152
MONAD_NAMESPACE_END

cmd/monad/runloop_ethereum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Result<void> process_ethereum_block(
8585
fiber::PriorityPool &priority_pool, Block &block, bytes32_t const &block_id,
8686
bytes32_t const &parent_block_id, bool const enable_tracing)
8787
{
88-
[[maybe_unused]] auto const block_start = std::chrono::system_clock::now();
88+
[[maybe_unused]] auto const block_start = std::chrono::steady_clock::now();
8989
auto const block_begin = std::chrono::steady_clock::now();
9090

9191
// Block input validation

cmd/monad/runloop_monad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Result<BlockExecOutput> propose_block(
155155
vm::VM &vm, fiber::PriorityPool &priority_pool, bool const is_first_block,
156156
bool const enable_tracing, BlockCache &block_cache)
157157
{
158-
[[maybe_unused]] auto const block_start = std::chrono::system_clock::now();
158+
[[maybe_unused]] auto const block_start = std::chrono::steady_clock::now();
159159
auto const block_begin = std::chrono::steady_clock::now();
160160
auto const &block_hash_buffer =
161161
block_hash_chain.find_chain(consensus_header.parent_id());

0 commit comments

Comments
 (0)