-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
miner: refactor code for multiple smesher and better observability (#…
…5130) related: #5113 it drops RefBallot function, and will allow to drop that index in a followup related: #5106 it eliminates repetitive disk reads and makes potentially expensive calls more transparent. added latency of execution to the logs related: #5087 refactoring to draw a line between per-smesher data that needs to be loaded once per epoch, and calls to external components. tortoise/mesh hash are reusable for every smesher, get txs is not reusable. it makes adding support for multiple smeshers significantly simpler
- Loading branch information
Showing
18 changed files
with
1,446 additions
and
2,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package miner | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/spacemeshos/go-spacemesh/log" | ||
"github.com/spacemeshos/go-spacemesh/metrics" | ||
) | ||
|
||
var proposalBuild = metrics.NewHistogramWithBuckets( | ||
"proposal_build_seconds", | ||
"miner", | ||
"duration to build a proposal in seconds", | ||
[]string{}, | ||
prometheus.ExponentialBuckets(0.1, 2, 10), | ||
).WithLabelValues() | ||
|
||
type latencyTracker struct { | ||
start time.Time | ||
data time.Time | ||
tortoise time.Time | ||
txs time.Time | ||
hash time.Time | ||
publish time.Time | ||
} | ||
|
||
func (lt *latencyTracker) total() time.Duration { | ||
return lt.publish.Sub(lt.start) | ||
} | ||
|
||
func (lt *latencyTracker) MarshalLogObject(encoder log.ObjectEncoder) error { | ||
encoder.AddDuration("data", lt.data.Sub(lt.start)) | ||
encoder.AddDuration("tortoise", lt.tortoise.Sub(lt.data)) | ||
encoder.AddDuration("txs", lt.txs.Sub(lt.tortoise)) | ||
encoder.AddDuration("hash", lt.hash.Sub(lt.txs)) | ||
encoder.AddDuration("publish", lt.publish.Sub(lt.hash)) | ||
total := lt.total() | ||
encoder.AddDuration("total", total) | ||
// arbitrary threshold that we want to highlight as a problem | ||
if total > 10*time.Second { | ||
encoder.AddBool("LATE PROPOSAL", true) | ||
} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.