Skip to content

Commit ab574ca

Browse files
committed
node: log MDBX commit latency
1 parent fc1316f commit ab574ca

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

silkworm/node/db/mdbx.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <stdexcept>
2020

21+
#include <silkworm/infra/common/log.hpp>
2122
#include <silkworm/node/db/util.hpp>
2223

2324
namespace silkworm::db {
@@ -32,6 +33,21 @@ namespace detail {
3233
dump.append(std::to_string(bool(result.value)));
3334
return dump;
3435
}
36+
37+
log::Args log_args_for_commit_latency(const MDBX_commit_latency& commit_latency) {
38+
return {
39+
"preparation",
40+
std::to_string(commit_latency.preparation),
41+
"write",
42+
std::to_string(commit_latency.write),
43+
"sync",
44+
std::to_string(commit_latency.sync),
45+
"ending",
46+
std::to_string(commit_latency.ending),
47+
"whole",
48+
std::to_string(commit_latency.whole),
49+
};
50+
}
3551
} // namespace detail
3652

3753
//! \brief Returns data of current cursor position or moves it to the beginning or the end of the table based on
@@ -285,13 +301,15 @@ void RWTxnUnmanaged::commit_and_stop() {
285301
}
286302

287303
void RWTxnUnmanaged::commit() {
288-
const ::mdbx::error err = static_cast<MDBX_error_t>(::mdbx_txn_commit(handle_));
304+
MDBX_commit_latency commit_latency{};
305+
const ::mdbx::error err = static_cast<MDBX_error_t>(::mdbx_txn_commit_ex(handle_, &commit_latency));
289306
if (err.code() != MDBX_THREAD_MISMATCH) {
290307
handle_ = nullptr;
291308
}
292309
if (err.code() != MDBX_SUCCESS) {
293310
err.throw_exception();
294311
}
312+
SILK_TRACE << "Commit latency" << detail::log_args_for_commit_latency(commit_latency);
295313
}
296314

297315
thread_local ObjectPool<MDBX_cursor, detail::cursor_handle_deleter> PooledCursor::handles_pool_{};

0 commit comments

Comments
 (0)