From 9a007bccde74140ef0c25d0af850cfd8e758a8b9 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Sun, 9 Oct 2022 17:55:26 -0700 Subject: [PATCH 1/2] Add more parallel TX latency --- app/app.go | 9 ++++++-- utils/metrics/labels.go | 2 ++ utils/metrics/metrics_util.go | 39 +++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/app.go b/app/app.go index a2c1147196..84f8761d67 100644 --- a/app/app.go +++ b/app/app.go @@ -924,11 +924,13 @@ func (app *App) DeliverTxWithResult(ctx sdk.Context, tx []byte) *abci.ExecTxResu } func (app *App) ProcessBlockSynchronous(ctx sdk.Context, txs [][]byte) []*abci.ExecTxResult { + defer metrics.BlockProcessLatency(time.Now(), metrics.SYNCHRONOUS) + txResults := []*abci.ExecTxResult{} for _, tx := range txs { txResults = append(txResults, app.DeliverTxWithResult(ctx, tx)) + metrics.IncrTxProcessTypeCounter(metrics.SYNCHRONOUS) } - metrics.IncrTxProcessTypeCounter(metrics.SYNCHRONOUS) return txResults } @@ -978,6 +980,8 @@ func (app *App) ProcessBlockConcurrent( completionSignalingMap map[int]acltypes.MessageCompletionSignalMapping, blockingSignalsMap map[int]acltypes.MessageCompletionSignalMapping, ) []*abci.ExecTxResult { + defer metrics.BlockProcessLatency(time.Now(), metrics.CONCURRENT) + var waitGroup sync.WaitGroup resultChan := make(chan ChannelResult) txResults := []*abci.ExecTxResult{} @@ -1075,10 +1079,11 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ case acltypes.ErrGovMsgInBlock: ctx.Logger().Info(fmt.Sprintf("Gov msg found while building DAG, processing synchronously: %s", err)) txResults = app.ProcessBlockSynchronous(ctx, txs) - + metrics.IncrDagBuildErrorCounter(metrics.GovMsgInBlock) default: ctx.Logger().Error(fmt.Sprintf("Error while building DAG, processing synchronously: %s", err)) txResults = app.ProcessBlockSynchronous(ctx, txs) + metrics.IncrDagBuildErrorCounter(metrics.FailedToBuild) } endBlockResp := app.EndBlock(ctx, abci.RequestEndBlock{ diff --git a/utils/metrics/labels.go b/utils/metrics/labels.go index 85d8ff122b..219810cd37 100644 --- a/utils/metrics/labels.go +++ b/utils/metrics/labels.go @@ -3,4 +3,6 @@ package metrics const ( CONCURRENT = "concurrent" SYNCHRONOUS = "synchronous" + GovMsgInBlock = "gov-msg-in-block" + FailedToBuild = "failed-to-build" ) diff --git a/utils/metrics/metrics_util.go b/utils/metrics/metrics_util.go index db7daa5aa7..514b2651c7 100644 --- a/utils/metrics/metrics_util.go +++ b/utils/metrics/metrics_util.go @@ -19,6 +19,32 @@ func IncrTxProcessTypeCounter(processType string) { ) } +// Measures the time taken to process a block by the process type +// Metric Names: +// +// sei_process_block_miliseconds +// sei_process_block_miliseconds_count +// sei_process_block_miliseconds_sum +func BlockProcessLatency(start time.Time, processType string) { + metrics.MeasureSinceWithLabels( + []string{"sei", "process", "block", "milliseconds"}, + start.UTC(), + []metrics.Label{telemetry.NewLabel("type", processType)}, + ) +} + +// Measures the time taken to execute a sudo msg +// Metric Names: +// +// sei_tx_process_type_count +func IncrDagBuildErrorCounter(reason string) { + metrics.IncrCounterWithLabels( + []string{"sei", "dag", "build", "error"}, + 1, + []metrics.Label{telemetry.NewLabel("reason", reason)}, + ) +} + // Measures the time taken to execute a sudo msg // Metric Names: // @@ -32,16 +58,3 @@ func MeasureDeliverTxDuration(start time.Time) { ) } -// Measures the time taken to execute a sudo msg -// Metric Names: -// -// sei_dag_build_duration_miliseconds -// sei_dag_build_duration_miliseconds_count -// sei_dag_build_duration_miliseconds_sum -func MeasureBuildDagDuration(start time.Time, method string) { - metrics.MeasureSinceWithLabels( - []string{"sei", "dag", "build", "milliseconds"}, - start.UTC(), - []metrics.Label{telemetry.NewLabel("method", method)}, - ) -} From fe7b2aa15ecf3263dbc7f45fcd5bc1f23c383e76 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Sun, 9 Oct 2022 18:49:48 -0700 Subject: [PATCH 2/2] lint --- utils/metrics/labels.go | 4 ++-- utils/metrics/metrics_util.go | 1 - x/oracle/simulation/operations.go | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/utils/metrics/labels.go b/utils/metrics/labels.go index 219810cd37..282c97d060 100644 --- a/utils/metrics/labels.go +++ b/utils/metrics/labels.go @@ -1,8 +1,8 @@ package metrics const ( - CONCURRENT = "concurrent" - SYNCHRONOUS = "synchronous" + CONCURRENT = "concurrent" + SYNCHRONOUS = "synchronous" GovMsgInBlock = "gov-msg-in-block" FailedToBuild = "failed-to-build" ) diff --git a/utils/metrics/metrics_util.go b/utils/metrics/metrics_util.go index 514b2651c7..005c50e873 100644 --- a/utils/metrics/metrics_util.go +++ b/utils/metrics/metrics_util.go @@ -57,4 +57,3 @@ func MeasureDeliverTxDuration(start time.Time) { start.UTC(), ) } - diff --git a/x/oracle/simulation/operations.go b/x/oracle/simulation/operations.go index 6b3dc6c946..e7af90f2a9 100644 --- a/x/oracle/simulation/operations.go +++ b/x/oracle/simulation/operations.go @@ -83,7 +83,7 @@ func WeightedOperations( } // SimulateMsgAggregateExchangeRatePrevote generates a MsgAggregateExchangeRatePrevote with random values. -//nolint: funlen +// nolint: funlen func SimulateMsgAggregateExchangeRatePrevote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -146,7 +146,7 @@ func SimulateMsgAggregateExchangeRatePrevote(ak types.AccountKeeper, bk types.Ba } // SimulateMsgAggregateExchangeRateVote generates a MsgAggregateExchangeRateVote with random values. -//nolint: funlen +// nolint: funlen func SimulateMsgAggregateExchangeRateVote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -213,7 +213,7 @@ func SimulateMsgAggregateExchangeRateVote(ak types.AccountKeeper, bk types.BankK } // SimulateMsgDelegateFeedConsent generates a MsgDelegateFeedConsent with random values. -//nolint: funlen +// nolint: funlen func SimulateMsgDelegateFeedConsent(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,