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

core/consensus: add histogram metric for consensus duration #1526

Merged
merged 9 commits into from
Dec 13, 2022

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Dec 8, 2022

Adds a histogram metric to report consensus duration for each consensus instance.

category: feature
ticket: #1247

@codecov
Copy link

codecov bot commented Dec 8, 2022

Codecov Report

Base: 54.21% // Head: 54.30% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (5d8fa51) compared to base (d74f679).
Patch coverage: 80.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1526      +/-   ##
==========================================
+ Coverage   54.21%   54.30%   +0.08%     
==========================================
  Files         152      153       +1     
  Lines       19379    19414      +35     
==========================================
+ Hits        10506    10542      +36     
+ Misses       7450     7449       -1     
  Partials     1423     1423              
Impacted Files Coverage Δ
core/consensus/component.go 59.58% <76.47%> (+0.39%) ⬆️
core/consensus/metrics.go 100.00% <100.00%> (ø)
core/scheduler/scheduler.go 72.53% <0.00%> (-0.14%) ⬇️
app/eth2wrap/synthproposer.go 73.17% <0.00%> (ø)
testutil/validatormock/validatormock.go 33.66% <0.00%> (+0.44%) ⬆️
core/consensus/transport.go 65.77% <0.00%> (+0.67%) ⬆️
app/app.go 64.59% <0.00%> (+0.79%) ⬆️
cmd/cmd.go 81.73% <0.00%> (+3.82%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -301,6 +301,11 @@ func (c *Component) propose(ctx context.Context, duty core.Duty, value proto.Mes
Receive: t.recvBuffer,
}

startTime := time.Now()
defer func() {
Copy link
Contributor

@corverroos corverroos Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use time.Since not time.Until, and use more concise defer pattern

defer func(t0 time.Time() {
consensusDuration.WithLabelValues(duty.Type.String()).Observe(time.Since(to)).Seconds())
}(time.Now())

Copy link
Contributor

@corverroos corverroos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This measures the incorrect thing

@@ -54,7 +54,7 @@ func Protocols() []protocol.ID {
type subscriber func(ctx context.Context, duty core.Duty, value proto.Message) error

// newDefinition returns a qbft definition (this is constant across all consensus instances).
func newDefinition(nodes int, subs func() []subscriber) qbft.Definition[core.Duty, [32]byte] {
func newDefinition(nodes int, subs func() []subscriber, startTime time.Time) qbft.Definition[core.Duty, [32]byte] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read the newDefinition godoc, this still instruments the wrong thing.

if err != nil && !isContextErr(err) {
err = qbft.Run[core.Duty, [32]byte](ctx, def, qt, duty, peerIdx, hash)
if isContextErr(err) {
consensusTimeout.WithLabelValues(duty.String()).Inc()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think about this one some more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increase consensus timeout specifically for "context deadline exceeded" and not for both "context deadline exceeded" and "context canceled"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. The Run function only exits when the context is closed. So the context is always closed, does that mean we always timeout?

Copy link
Contributor Author

@dB2510 dB2510 Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We timeout when context is closed but we haven't DECIDED

@dB2510 dB2510 added the merge when ready Indicates bulldozer bot may merge when all checks pass label Dec 13, 2022
@obol-bulldozer obol-bulldozer bot merged commit df62aff into main Dec 13, 2022
@obol-bulldozer obol-bulldozer bot deleted the dhruv/consensusdelay branch December 13, 2022 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants