-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: Report MDBX commit latency metrics #5668
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot, really clean change! Just a few comments.
match this.inner.commit().map_err(|e| DatabaseError::Commit(e.into())) { | ||
Ok((v, latency)) => (Ok(v), Some(latency)), | ||
Err(e) => (Err(e), None), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks a bit weird, feels like it would be better to put the latency into Ok
variant and make it non-optional. But then we'd need to replace the Ok
variant in execute_with_close_transaction_metric
. What do you think is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shekhirin i'm not sure if it is ok to make it non-optional, since abort
function does not provide any latencies.
We can however introduce a method to CommitLatency
that requires self-invocation (thus, it must be called after passing an inner pointer to some FFI method). This change would make getter methods return Some(Duration)
instead of None
(so the getters' return type must also be altered). However, this could lead to less readable code due to the need for additional checks within each metric during record. To mitigate this, we could employ a useful macro.
Additionally, we could employ the proposed method to set an internal flag, checked during transaction metric recording. Yet, I'm concerned this might not be a best practice.
Each of these approaches would enable the initialization of a new CommitLatency
struct within the abort
function, allowing us to pass it as part of the Ok
variant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, you're right about the abort
method. Ok, current impl is fine with me!
match this.inner.commit().map_err(|e| DatabaseError::Commit(e.into())) { | ||
Ok((v, latency)) => (Ok(v), Some(latency)), | ||
Err(e) => (Err(e), None), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, you're right about the abort
method. Ok, current impl is fine with me!
LGTM, pending @mattsse |
Verified that it works ubuntu@reth3:~/reth$ curl -s localhost:9001 | grep '^reth_database_transaction_commit' | grep whole
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="0"} 0.000015258
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="0.5"} 0.000015256574364089644
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="0.9"} 0.000015256574364089644
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="0.95"} 0.000015256574364089644
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="0.99"} 0.000015256574364089644
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="0.999"} 0.000015256574364089644
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="commit",quantile="1"} 0.000015258
reth_database_transaction_commit_whole_duration_seconds_sum{mode="read-only",outcome="commit"} 0.00044248199999999985
reth_database_transaction_commit_whole_duration_seconds_count{mode="read-only",outcome="commit"} 29
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="0"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="0.5"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="0.9"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="0.95"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="0.99"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="0.999"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",quantile="1"} 0
reth_database_transaction_commit_whole_duration_seconds_sum{mode="read-only"} 0
reth_database_transaction_commit_whole_duration_seconds_count{mode="read-only"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="0"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="0.5"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="0.9"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="0.95"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="0.99"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="0.999"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-only",outcome="drop",quantile="1"} 0
reth_database_transaction_commit_whole_duration_seconds_sum{mode="read-only",outcome="drop"} 0
reth_database_transaction_commit_whole_duration_seconds_count{mode="read-only",outcome="drop"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="0"} 0.05485251
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="0.5"} 0.06518668725510515
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="0.9"} 0.06667667989030134
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="0.95"} 0.06667667989030134
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="0.99"} 0.06667667989030134
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="0.999"} 0.06667667989030134
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",outcome="commit",quantile="1"} 0.080699562
reth_database_transaction_commit_whole_duration_seconds_sum{mode="read-write",outcome="commit"} 1.2210061919999997
reth_database_transaction_commit_whole_duration_seconds_count{mode="read-write",outcome="commit"} 13
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="0"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="0.5"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="0.9"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="0.95"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="0.99"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="0.999"} 0
reth_database_transaction_commit_whole_duration_seconds{mode="read-write",quantile="1"} 0
reth_database_transaction_commit_whole_duration_seconds_sum{mode="read-write"} 0
reth_database_transaction_commit_whole_duration_seconds_count{mode="read-write"} 0 |
Implements an enhancement described in #5458