Skip to content

metrics: count large txn groups and msigs#4833

Merged
algorandskiy merged 4 commits into
algorand:masterfrom
algorandskiy:pavel/metrics-tx-type
Nov 28, 2022
Merged

metrics: count large txn groups and msigs#4833
algorandskiy merged 4 commits into
algorand:masterfrom
algorandskiy:pavel/metrics-tx-type

Conversation

@algorandskiy
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy commented Nov 24, 2022

Summary

Add more metrics to better understand traffic.

Test Plan

Existing tests

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 24, 2022

Codecov Report

Merging #4833 (468cc32) into master (1cf857f) will decrease coverage by 0.04%.
The diff coverage is 45.45%.

@@            Coverage Diff             @@
##           master    #4833      +/-   ##
==========================================
- Coverage   53.80%   53.76%   -0.05%     
==========================================
  Files         421      421              
  Lines       53827    53849      +22     
==========================================
- Hits        28963    28952      -11     
- Misses      22516    22542      +26     
- Partials     2348     2355       +7     
Impacted Files Coverage Δ
crypto/batchverifier.go 100.00% <ø> (ø)
data/txHandler.go 31.81% <0.00%> (-0.74%) ⬇️
data/transactions/verify/txn.go 74.46% <55.55%> (-1.57%) ⬇️
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
ledger/tracker.go 74.26% <0.00%> (-4.65%) ⬇️
network/wsPeer.go 67.06% <0.00%> (-1.91%) ⬇️
catchup/peerSelector.go 98.95% <0.00%> (-1.05%) ⬇️
catchup/service.go 68.96% <0.00%> (-0.50%) ⬇️
network/wsNetwork.go 64.74% <0.00%> (ø)
ledger/blockqueue.go 88.50% <0.00%> (+2.87%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

algonautshant
algonautshant previously approved these changes Nov 24, 2022
Copy link
Copy Markdown
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Looks great.
Some minor comments and one possible bug?

Comment thread data/transactions/verify/txn.go Outdated
Comment thread data/transactions/verify/txn.go Outdated
var logicErrTotal = metrics.MakeCounter(metrics.MetricName{Name: "algod_ledger_logic_err", Description: "Total transaction scripts executed and errored"})
var msigLessOrEqual4 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_4", Description: "Total transactions with 1-4 msigs"})
var msigLessOrEqual16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_4_16", Description: "Total transactions with 4-16 msigs"})
var msigMore16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_16", Description: "Total transactions with 16+ msigs"})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: (personal preference...)

Suggested change
var msigMore16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_16", Description: "Total transactions with 16+ msigs"})
var msig17orMore = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_17", Description: "Total transactions with 17 or more msigs"})

Comment thread data/transactions/verify/txn.go Outdated
Comment thread data/transactions/verify/txn.go Outdated
var msigMore16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_16", Description: "Total transactions with 16+ msigs"})
var msigLsigLessOrEqual4 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_lsig_4", Description: "Total transaction scripts with 1-4 msigs"})
var msigLsigLessOrEqual16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_lsig_4_16", Description: "Total transaction scripts with 4-16 msigs"})
var msigLsigMore16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_lsig_16", Description: "Total transaction scripts with 16+ msigs"})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: (personal preference...)

Suggested change
var msigLsigMore16 = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_lsig_16", Description: "Total transaction scripts with 16+ msigs"})
var msigLsig17orMore = metrics.MakeCounter(metrics.MetricName{Name: "algod_verify_msig_lsig_17", Description: "Total transaction scripts with 17 or more msigs"})

Comment thread data/txHandler.go Outdated
Comment thread data/txHandler.go Outdated
Comment thread util/metrics/metrics.go Outdated
Comment thread data/txHandler.go Outdated
@algorandskiy
Copy link
Copy Markdown
Contributor Author

Removed tx group size early filtering, renamed metrics according to current state

Comment thread data/txHandler.go
if ntx == config.MaxTxGroupSize {
transactionMessageTxGroupFull.Inc(nil)
} else if ntx > config.MaxTxGroupSize {
transactionMessageTxGroupExcessive.Inc(nil)
Copy link
Copy Markdown
Contributor

@cce cce Nov 28, 2022

Choose a reason for hiding this comment

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

Could we also add a break out of the for loop above right after ntx++ (or in the for condition) if it exceeds MaxTxGroupSize?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

counter := 0
for _, subsigi := range s.Msig.Subsigs {
if (subsigi.Sig != crypto.Signature{}) {
counter++
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another way to count this would be to call batchVerifier.GetNumberOfEnqueuedSignatures() before and after the call to crypto.MultisigBatchPrep and calculate the difference

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you could also have crypto.MultisigBatchPrep return a (count, err)

Copy link
Copy Markdown
Contributor

@cce cce left a comment

Choose a reason for hiding this comment

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

looks correct, a test would be nice to prove it, and eventually we may want to build a rudimentary histogram-to-counter system that sets up buckets of value ranges (0-5, 6-10, etc) and assign them to counters so we don't have to have duplicate value-to-counter code like this start to pop up in more places

Copy link
Copy Markdown
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Looks great!

@algorandskiy algorandskiy merged commit 381a835 into algorand:master Nov 28, 2022
tmc pushed a commit to tmc/go-algorand that referenced this pull request Mar 7, 2025
@algorandskiy algorandskiy deleted the pavel/metrics-tx-type branch March 16, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants