Express block validation, cpu/mem usage via OpenCensus
This commit is contained in:
parent
b1f66b181c
commit
2cd6347a13
@ -528,8 +528,17 @@ func blockSanityChecks(h *types.BlockHeader) error {
|
|||||||
|
|
||||||
// ValidateBlock should match up with 'Semantical Validation' in validation.md in the spec
|
// ValidateBlock should match up with 'Semantical Validation' in validation.md in the spec
|
||||||
func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) error {
|
func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) error {
|
||||||
|
validationStart := time.Now()
|
||||||
|
defer func() {
|
||||||
|
dur := time.Since(validationStart)
|
||||||
|
durMilli := dur.Seconds() * float64(1000)
|
||||||
|
stats.Record(ctx, metrics.BlockValidationDurationMilliseconds.M(durMilli))
|
||||||
|
log.Infow("block validation", "took", dur, "height", b.Header.Height)
|
||||||
|
}()
|
||||||
|
|
||||||
ctx, span := trace.StartSpan(ctx, "validateBlock")
|
ctx, span := trace.StartSpan(ctx, "validateBlock")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
if build.InsecurePoStValidation {
|
if build.InsecurePoStValidation {
|
||||||
log.Warn("insecure test validation is enabled, if you see this outside of a test, it is a severe bug!")
|
log.Warn("insecure test validation is enabled, if you see this outside of a test, it is a severe bug!")
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
"go.opencensus.io/plugin/runmetrics"
|
||||||
"go.opencensus.io/stats"
|
"go.opencensus.io/stats"
|
||||||
"go.opencensus.io/stats/view"
|
"go.opencensus.io/stats/view"
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
@ -114,6 +115,13 @@ var DaemonCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
|
err := runmetrics.Enable(runmetrics.RunMetricOptions{
|
||||||
|
EnableCPU: true,
|
||||||
|
EnableMemory: true,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("enabling runtime metrics: %w", err)
|
||||||
|
}
|
||||||
if prof := cctx.String("pprof"); prof != "" {
|
if prof := cctx.String("pprof"); prof != "" {
|
||||||
profile, err := os.Create(prof)
|
profile, err := os.Create(prof)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,6 +31,7 @@ var (
|
|||||||
BlockReceived = stats.Int64("block/received", "Counter for total received blocks", stats.UnitDimensionless)
|
BlockReceived = stats.Int64("block/received", "Counter for total received blocks", stats.UnitDimensionless)
|
||||||
BlockValidationFailure = stats.Int64("block/failure", "Counter for block validation failures", stats.UnitDimensionless)
|
BlockValidationFailure = stats.Int64("block/failure", "Counter for block validation failures", stats.UnitDimensionless)
|
||||||
BlockValidationSuccess = stats.Int64("block/success", "Counter for block validation successes", stats.UnitDimensionless)
|
BlockValidationSuccess = stats.Int64("block/success", "Counter for block validation successes", stats.UnitDimensionless)
|
||||||
|
BlockValidationDurationMilliseconds = stats.Float64("block/validation_ms", "Duration for Block Validation in ms", stats.UnitMilliseconds)
|
||||||
PeerCount = stats.Int64("peer/count", "Current number of FIL peers", stats.UnitDimensionless)
|
PeerCount = stats.Int64("peer/count", "Current number of FIL peers", stats.UnitDimensionless)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,6 +64,10 @@ var (
|
|||||||
Measure: BlockValidationSuccess,
|
Measure: BlockValidationSuccess,
|
||||||
Aggregation: view.Count(),
|
Aggregation: view.Count(),
|
||||||
}
|
}
|
||||||
|
BlockValidationDurationView = &view.View{
|
||||||
|
Measure: BlockValidationDurationMilliseconds,
|
||||||
|
Aggregation: view.Sum(),
|
||||||
|
}
|
||||||
MessageReceivedView = &view.View{
|
MessageReceivedView = &view.View{
|
||||||
Measure: MessageReceived,
|
Measure: MessageReceived,
|
||||||
Aggregation: view.Count(),
|
Aggregation: view.Count(),
|
||||||
@ -90,6 +95,7 @@ var DefaultViews = append([]*view.View{
|
|||||||
BlockReceivedView,
|
BlockReceivedView,
|
||||||
BlockValidationFailureView,
|
BlockValidationFailureView,
|
||||||
BlockValidationSuccessView,
|
BlockValidationSuccessView,
|
||||||
|
BlockValidationDurationView,
|
||||||
MessageReceivedView,
|
MessageReceivedView,
|
||||||
MessageValidationFailureView,
|
MessageValidationFailureView,
|
||||||
MessageValidationSuccessView,
|
MessageValidationSuccessView,
|
||||||
|
Loading…
Reference in New Issue
Block a user