Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db: match batch_state_size calculation with Erigon #1944

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions silkworm/db/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void Buffer::update_account(const evmc::address& address, std::optional<Account>
}

if (equal) {
batch_state_size_ += kAddressLength + (current ? current->encoding_length_for_storage() : 0);
return;
}
auto it{accounts_.find(address)};
Expand Down Expand Up @@ -158,7 +159,7 @@ void Buffer::write_history_to_db(bool write_change_sets) {
}
}
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Append Account Changes", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand Down Expand Up @@ -192,7 +193,7 @@ void Buffer::write_history_to_db(bool write_change_sets) {
}
}
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Append Storage Changes", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand All @@ -210,7 +211,7 @@ void Buffer::write_history_to_db(bool write_change_sets) {
}
receipts_.clear();
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Append Receipts", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand All @@ -227,7 +228,7 @@ void Buffer::write_history_to_db(bool write_change_sets) {
}
logs_.clear();
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Append Logs", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand All @@ -249,15 +250,15 @@ void Buffer::write_history_to_db(bool write_change_sets) {
}
call_traces_.clear();
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Append Call Traces", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
}

batch_history_size_ = 0;
auto [finish_time, _]{sw.stop()};
if (should_trace) {
if (should_trace) [[unlikely]] {
log::Trace("Flushed history",
{"size", human_size(total_written_size), "in", StopWatch::format(sw.since_start(finish_time))});
}
Expand Down Expand Up @@ -287,7 +288,7 @@ void Buffer::write_state_to_db() {
}
incarnations_.clear();
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Incarnations updated", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand All @@ -302,7 +303,7 @@ void Buffer::write_state_to_db() {
}
hash_to_code_.clear();
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Code updated", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand All @@ -317,7 +318,7 @@ void Buffer::write_state_to_db() {
}
storage_prefix_to_code_hash_.clear();
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Code Hashes updated", {"size", human_size(written_size), "in", StopWatch::format(duration)});
}
Expand All @@ -333,7 +334,7 @@ void Buffer::write_state_to_db() {
addresses.insert(x.first);
}

if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Sorted addresses", {"in", StopWatch::format(duration)});
}
Expand Down Expand Up @@ -371,7 +372,7 @@ void Buffer::write_state_to_db() {
}
}
total_written_size += written_size;
if (should_trace) {
if (should_trace) [[unlikely]] {
auto [_, duration]{sw.lap()};
log::Trace("Updated accounts and storage",
{"size", human_size(written_size), "in", StopWatch::format(duration)});
Expand Down
Loading