From 679c4183e7e3865e1fe12da345bc67ab1865fff7 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Mon, 31 Aug 2020 16:37:18 -0700 Subject: [PATCH 1/8] add a simple command to watch messages sitting in the mempool --- cmd/lotus-shed/main.go | 1 + cmd/lotus-shed/mempool-stats.go | 79 +++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 cmd/lotus-shed/mempool-stats.go diff --git a/cmd/lotus-shed/main.go b/cmd/lotus-shed/main.go index 2d0d7c3a0..4944b67aa 100644 --- a/cmd/lotus-shed/main.go +++ b/cmd/lotus-shed/main.go @@ -33,6 +33,7 @@ func main() { mpoolCmd, genesisVerifyCmd, mathCmd, + mpoolStatsCmd, } app := &cli.App{ diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go new file mode 100644 index 000000000..d2651a826 --- /dev/null +++ b/cmd/lotus-shed/mempool-stats.go @@ -0,0 +1,79 @@ +package main + +import ( + "fmt" + "time" + + "github.com/ipfs/go-cid" + logging "github.com/ipfs/go-log" + "github.com/urfave/cli/v2" + + lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/types" + lcli "github.com/filecoin-project/lotus/cli" +) + +type msgInfo struct { + msg *types.SignedMessage + seen time.Time +} + +var mpoolStatsCmd = &cli.Command{ + Name: "mpool-stats", + Action: func(cctx *cli.Context) error { + logging.SetLogLevel("rpc", "ERROR") + + api, closer, err := lcli.GetFullNodeAPI(cctx) + if err != nil { + return err + } + + defer closer() + ctx := lcli.ReqContext(cctx) + + updates, err := api.MpoolSub(ctx) + if err != nil { + return err + } + + tracker := make(map[cid.Cid]*msgInfo) + tick := time.Tick(time.Second) + for { + select { + case u := <-updates: + switch u.Type { + case lapi.MpoolAdd: + tracker[u.Message.Cid()] = &msgInfo{ + msg: u.Message, + seen: time.Now(), + } + case lapi.MpoolRemove: + mi, ok := tracker[u.Message.Cid()] + if !ok { + continue + } + fmt.Printf("%s was in the mempool for %s (feecap=%s, prem=%s)\n", u.Message.Cid(), time.Since(mi.seen), u.Message.Message.GasFeeCap, u.Message.Message.GasPremium) + delete(tracker, u.Message.Cid()) + default: + return fmt.Errorf("unrecognized mpool update state: %d", u.Type) + } + case <-tick: + if len(tracker) == 0 { + continue + } + var avg time.Duration + var oldest time.Duration + for _, v := range tracker { + age := time.Since(v.seen) + if age > oldest { + oldest = age + } + + avg += age + } + fmt.Printf("%d messages in mempool for average of %s, max=%s\n", len(tracker), avg/time.Duration(len(tracker)), oldest) + } + } + return nil + }, +} From 47ad7ccb5f7546367c86fd7cbe862c878b3f1288 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 1 Sep 2020 12:40:42 -0700 Subject: [PATCH 2/8] some more stats --- cmd/lotus-shed/mempool-stats.go | 63 ++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index d2651a826..320ba31a5 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "sort" "time" "github.com/ipfs/go-cid" @@ -58,22 +59,68 @@ var mpoolStatsCmd = &cli.Command{ return fmt.Errorf("unrecognized mpool update state: %d", u.Type) } case <-tick: + var ages []time.Duration if len(tracker) == 0 { continue } - var avg time.Duration - var oldest time.Duration for _, v := range tracker { age := time.Since(v.seen) - if age > oldest { - oldest = age - } - - avg += age + ages = append(ages, age) } - fmt.Printf("%d messages in mempool for average of %s, max=%s\n", len(tracker), avg/time.Duration(len(tracker)), oldest) + + st := ageStats(ages) + fmt.Printf("%d messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) } } return nil }, } + +type ageStat struct { + Average time.Duration + Max time.Duration + Perc40 time.Duration + Perc50 time.Duration + Perc60 time.Duration + Perc70 time.Duration + Perc80 time.Duration + Perc90 time.Duration + Perc95 time.Duration + Count int +} + +func ageStats(ages []time.Duration) *ageStat { + sort.Slice(ages, func(i, j int) bool { + return ages[i] < ages[j] + }) + + st := ageStat{ + Count: len(ages), + } + var sum time.Duration + for _, a := range ages { + sum += a + if a > st.Max { + st.Max = a + } + } + st.Average = sum / time.Duration(len(ages)) + + p40 := (4 * len(ages)) / 10 + p50 := len(ages) / 2 + p60 := (6 * len(ages)) / 10 + p70 := (7 * len(ages)) / 10 + p80 := (4 * len(ages)) / 5 + p90 := (9 * len(ages)) / 10 + p95 := (19 * len(ages)) / 20 + + st.Perc40 = ages[p40] + st.Perc50 = ages[p50] + st.Perc60 = ages[p60] + st.Perc70 = ages[p70] + st.Perc80 = ages[p80] + st.Perc90 = ages[p90] + st.Perc95 = ages[p95] + + return &st +} From 7d1d690eb720626c5b202cc7c6185705a8185e11 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 1 Sep 2020 14:09:14 -0700 Subject: [PATCH 3/8] lets get some metrics --- cmd/lotus-shed/mempool-stats.go | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index 320ba31a5..d7408b9cb 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -2,18 +2,52 @@ package main import ( "fmt" + "net/http" "sort" "time" + "contrib.go.opencensus.io/exporter/prometheus" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log" "github.com/urfave/cli/v2" + "go.opencensus.io/stats" + "go.opencensus.io/stats/view" + "go.opencensus.io/tag" lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" ) +var ( + MpoolAge = stats.Float64("mpoolage", "Age of messages in the mempool", stats.UnitSeconds) + MpoolSize = stats.Int64("mpoolsize", "Number of messages in mempool", stats.UnitDimensionless) + MpoolInboundRate = stats.Int64("inbound", "Counter for inbound messages", stats.UnitDimensionless) +) + +var ( + LeTag, _ = tag.NewKey("le") +) + +var ( + AgeView = &view.View{ + Name: "mpool-age", + Measure: MpoolAge, + TagKeys: []tag.Key{LeTag}, + Aggregation: view.LastValue(), + } + SizeView = &view.View{ + Name: "mpool-size", + Measure: MpoolSize, + Aggregation: view.LastValue(), + } + InboundRate = &view.View{ + Name: "msg-inbound", + Measure: MpoolInboundRate, + Aggregation: view.Count(), + } +) + type msgInfo struct { msg *types.SignedMessage seen time.Time @@ -24,6 +58,25 @@ var mpoolStatsCmd = &cli.Command{ Action: func(cctx *cli.Context) error { logging.SetLogLevel("rpc", "ERROR") + if err := view.Register(AgeView); err != nil { + return err + } + + expo, err := prometheus.NewExporter(prometheus.Options{ + Namespace: "lotusmpool", + }) + if err != nil { + return err + } + + http.Handle("/debug/metrics", expo) + + go func() { + if err := http.ListenAndServe(":10555", nil); err != nil { + panic(err) + } + }() + api, closer, err := lcli.GetFullNodeAPI(cctx) if err != nil { return err @@ -48,6 +101,7 @@ var mpoolStatsCmd = &cli.Command{ msg: u.Message, seen: time.Now(), } + stats.Record(ctx, MpoolInboundRate.M(1)) case lapi.MpoolRemove: mi, ok := tracker[u.Message.Cid()] if !ok { @@ -69,6 +123,15 @@ var mpoolStatsCmd = &cli.Command{ } st := ageStats(ages) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40")}, MpoolAge.M(st.Perc40.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50")}, MpoolAge.M(st.Perc50.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60")}, MpoolAge.M(st.Perc60.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70")}, MpoolAge.M(st.Perc70.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80")}, MpoolAge.M(st.Perc80.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90")}, MpoolAge.M(st.Perc90.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95")}, MpoolAge.M(st.Perc95.Seconds())) + + stats.Record(ctx, MpoolSize.M(int64(len(tracker)))) fmt.Printf("%d messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) } } From 8414aa6e4b053d21f32e8028a1dbb3fcb940103a Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 1 Sep 2020 15:11:02 -0700 Subject: [PATCH 4/8] more metrics! --- cmd/lotus-shed/mempool-stats.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index d7408b9cb..fc7159d2a 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -20,9 +20,11 @@ import ( ) var ( - MpoolAge = stats.Float64("mpoolage", "Age of messages in the mempool", stats.UnitSeconds) - MpoolSize = stats.Int64("mpoolsize", "Number of messages in mempool", stats.UnitDimensionless) - MpoolInboundRate = stats.Int64("inbound", "Counter for inbound messages", stats.UnitDimensionless) + MpoolAge = stats.Float64("mpoolage", "Age of messages in the mempool", stats.UnitSeconds) + MpoolSize = stats.Int64("mpoolsize", "Number of messages in mempool", stats.UnitDimensionless) + MpoolInboundRate = stats.Int64("inbound", "Counter for inbound messages", stats.UnitDimensionless) + BlockInclusionRate = stats.Int64("inclusion", "Counter for message included in blocks", stats.UnitDimensionless) + MsgWaitTime = stats.Float64("msg-wait-time", "Wait time of messages to make it into a block", stats.UnitSeconds) ) var ( @@ -46,6 +48,16 @@ var ( Measure: MpoolInboundRate, Aggregation: view.Count(), } + InclusionRate = &view.View{ + Name: "msg-inclusion", + Measure: BlockInclusionRate, + Aggregation: view.Count(), + } + MsgWait = &view.View{ + Name: "msg-wait", + Measure: MsgWaitTime, + Aggregation: view.Distribution(10, 30, 60, 120, 240, 600, 1800, 3600), + } ) type msgInfo struct { @@ -58,7 +70,7 @@ var mpoolStatsCmd = &cli.Command{ Action: func(cctx *cli.Context) error { logging.SetLogLevel("rpc", "ERROR") - if err := view.Register(AgeView); err != nil { + if err := view.Register(AgeView, SizeView, InboundRate, InclusionRate, MsgWait); err != nil { return err } @@ -108,6 +120,8 @@ var mpoolStatsCmd = &cli.Command{ continue } fmt.Printf("%s was in the mempool for %s (feecap=%s, prem=%s)\n", u.Message.Cid(), time.Since(mi.seen), u.Message.Message.GasFeeCap, u.Message.Message.GasPremium) + stats.Record(ctx, BlockInclusionRate.M(1)) + stats.Record(ctx, MsgWaitTime.M(time.Since(mi.seen).Seconds())) delete(tracker, u.Message.Cid()) default: return fmt.Errorf("unrecognized mpool update state: %d", u.Type) From e58327d4ed6ec61743522ba2fd12769af9fe55c1 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 1 Sep 2020 15:46:55 -0700 Subject: [PATCH 5/8] rename LE tag to quantile --- cmd/lotus-shed/mempool-stats.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index fc7159d2a..b21948065 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -28,7 +28,7 @@ var ( ) var ( - LeTag, _ = tag.NewKey("le") + LeTag, _ = tag.NewKey("quantile") ) var ( From 09194aa6133c4a7344dad81d343b9c15c4d30238 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 2 Sep 2020 15:57:42 -0700 Subject: [PATCH 6/8] print better error when losing connection --- cmd/lotus-shed/mempool-stats.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index b21948065..4c87b5b5a 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -106,7 +106,10 @@ var mpoolStatsCmd = &cli.Command{ tick := time.Tick(time.Second) for { select { - case u := <-updates: + case u, ok := <-updates: + if !ok { + return fmt.Errorf("connection with lotus node broke") + } switch u.Type { case lapi.MpoolAdd: tracker[u.Message.Cid()] = &msgInfo{ From 0361ca1c396d756a044dcdbf56534e5bebbcd054 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 9 Sep 2020 17:18:55 -0700 Subject: [PATCH 7/8] add some bits about windowed post --- cmd/lotus-shed/mempool-stats.go | 116 +++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 24 deletions(-) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index 4c87b5b5a..f38dc6a38 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -14,9 +14,11 @@ import ( "go.opencensus.io/stats/view" "go.opencensus.io/tag" + "github.com/filecoin-project/go-address" lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/specs-actors/actors/builtin" ) var ( @@ -29,33 +31,38 @@ var ( var ( LeTag, _ = tag.NewKey("quantile") + MTTag, _ = tag.NewKey("msg_type") ) var ( AgeView = &view.View{ Name: "mpool-age", Measure: MpoolAge, - TagKeys: []tag.Key{LeTag}, + TagKeys: []tag.Key{LeTag, MTTag}, Aggregation: view.LastValue(), } SizeView = &view.View{ Name: "mpool-size", Measure: MpoolSize, + TagKeys: []tag.Key{MTTag}, Aggregation: view.LastValue(), } InboundRate = &view.View{ Name: "msg-inbound", Measure: MpoolInboundRate, + TagKeys: []tag.Key{MTTag}, Aggregation: view.Count(), } InclusionRate = &view.View{ Name: "msg-inclusion", Measure: BlockInclusionRate, + TagKeys: []tag.Key{MTTag}, Aggregation: view.Count(), } MsgWait = &view.View{ Name: "msg-wait", Measure: MsgWaitTime, + TagKeys: []tag.Key{MTTag}, Aggregation: view.Distribution(10, 30, 60, 120, 240, 600, 1800, 3600), } ) @@ -102,6 +109,24 @@ var mpoolStatsCmd = &cli.Command{ return err } + mcache := make(map[address.Address]bool) + isMiner := func(addr address.Address) (bool, error) { + cache, ok := mcache[addr] + if ok { + return cache, nil + } + + act, err := api.StateGetActor(ctx, addr, types.EmptyTSK) + if err != nil { + return false, err + } + + ism := act.Code == builtin.StorageMinerActorCodeID + mcache[addr] = ism + return ism, nil + } + + wpostTracker := make(map[cid.Cid]*msgInfo) tracker := make(map[cid.Cid]*msgInfo) tick := time.Tick(time.Second) for { @@ -112,44 +137,87 @@ var mpoolStatsCmd = &cli.Command{ } switch u.Type { case lapi.MpoolAdd: + stats.Record(ctx, MpoolInboundRate.M(1)) tracker[u.Message.Cid()] = &msgInfo{ msg: u.Message, seen: time.Now(), } - stats.Record(ctx, MpoolInboundRate.M(1)) + + if u.Message.Message.Method == builtin.MethodsMiner.SubmitWindowedPoSt { + + miner, err := isMiner(u.Message.Message.To) + if err != nil { + log.Warnf("failed to determine if message target was to a miner: %s", err) + continue + } + + if miner { + wpostTracker[u.Message.Cid()] = &msgInfo{ + msg: u.Message, + seen: time.Now(), + } + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MpoolInboundRate.M(1)) + } + } + case lapi.MpoolRemove: mi, ok := tracker[u.Message.Cid()] - if !ok { - continue + if ok { + fmt.Printf("%s was in the mempool for %s (feecap=%s, prem=%s)\n", u.Message.Cid(), time.Since(mi.seen), u.Message.Message.GasFeeCap, u.Message.Message.GasPremium) + stats.Record(ctx, BlockInclusionRate.M(1)) + stats.Record(ctx, MsgWaitTime.M(time.Since(mi.seen).Seconds())) + delete(tracker, u.Message.Cid()) + } + + wm, ok := wpostTracker[u.Message.Cid()] + if ok { + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, BlockInclusionRate.M(1)) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MsgWaitTime.M(time.Since(wm.seen).Seconds())) + delete(wpostTracker, u.Message.Cid()) } - fmt.Printf("%s was in the mempool for %s (feecap=%s, prem=%s)\n", u.Message.Cid(), time.Since(mi.seen), u.Message.Message.GasFeeCap, u.Message.Message.GasPremium) - stats.Record(ctx, BlockInclusionRate.M(1)) - stats.Record(ctx, MsgWaitTime.M(time.Since(mi.seen).Seconds())) - delete(tracker, u.Message.Cid()) default: return fmt.Errorf("unrecognized mpool update state: %d", u.Type) } case <-tick: var ages []time.Duration - if len(tracker) == 0 { - continue - } - for _, v := range tracker { - age := time.Since(v.seen) - ages = append(ages, age) + if len(tracker) > 0 { + for _, v := range tracker { + age := time.Since(v.seen) + ages = append(ages, age) + } + + st := ageStats(ages) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40")}, MpoolAge.M(st.Perc40.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50")}, MpoolAge.M(st.Perc50.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60")}, MpoolAge.M(st.Perc60.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70")}, MpoolAge.M(st.Perc70.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80")}, MpoolAge.M(st.Perc80.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90")}, MpoolAge.M(st.Perc90.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95")}, MpoolAge.M(st.Perc95.Seconds())) + + stats.Record(ctx, MpoolSize.M(int64(len(tracker)))) + fmt.Printf("%d messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) } - st := ageStats(ages) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40")}, MpoolAge.M(st.Perc40.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50")}, MpoolAge.M(st.Perc50.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60")}, MpoolAge.M(st.Perc60.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70")}, MpoolAge.M(st.Perc70.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80")}, MpoolAge.M(st.Perc80.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90")}, MpoolAge.M(st.Perc90.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95")}, MpoolAge.M(st.Perc95.Seconds())) + var wpages []time.Duration + if len(wpostTracker) > 0 { + for _, v := range wpostTracker { + age := time.Since(v.seen) + wpages = append(wpages, age) + } - stats.Record(ctx, MpoolSize.M(int64(len(tracker)))) - fmt.Printf("%d messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) + st := ageStats(wpages) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc40.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc50.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc60.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc70.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc80.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc90.Seconds())) + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc95.Seconds())) + + stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MpoolSize.M(int64(len(wpostTracker)))) + fmt.Printf("%d wpost messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) + } } } return nil From c73916b4e7e49d2aa6d112beaeeffb1a61c13a20 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 9 Sep 2020 17:37:49 -0700 Subject: [PATCH 8/8] fix the linter --- cmd/lotus-shed/mempool-stats.go | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index f38dc6a38..b81cf2704 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -156,7 +156,7 @@ var mpoolStatsCmd = &cli.Command{ msg: u.Message, seen: time.Now(), } - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MpoolInboundRate.M(1)) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MpoolInboundRate.M(1)) } } @@ -171,8 +171,8 @@ var mpoolStatsCmd = &cli.Command{ wm, ok := wpostTracker[u.Message.Cid()] if ok { - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, BlockInclusionRate.M(1)) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MsgWaitTime.M(time.Since(wm.seen).Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, BlockInclusionRate.M(1)) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MsgWaitTime.M(time.Since(wm.seen).Seconds())) delete(wpostTracker, u.Message.Cid()) } default: @@ -187,13 +187,13 @@ var mpoolStatsCmd = &cli.Command{ } st := ageStats(ages) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40")}, MpoolAge.M(st.Perc40.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50")}, MpoolAge.M(st.Perc50.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60")}, MpoolAge.M(st.Perc60.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70")}, MpoolAge.M(st.Perc70.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80")}, MpoolAge.M(st.Perc80.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90")}, MpoolAge.M(st.Perc90.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95")}, MpoolAge.M(st.Perc95.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40")}, MpoolAge.M(st.Perc40.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50")}, MpoolAge.M(st.Perc50.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60")}, MpoolAge.M(st.Perc60.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70")}, MpoolAge.M(st.Perc70.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80")}, MpoolAge.M(st.Perc80.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90")}, MpoolAge.M(st.Perc90.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95")}, MpoolAge.M(st.Perc95.Seconds())) stats.Record(ctx, MpoolSize.M(int64(len(tracker)))) fmt.Printf("%d messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) @@ -207,20 +207,19 @@ var mpoolStatsCmd = &cli.Command{ } st := ageStats(wpages) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc40.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc50.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc60.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc70.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc80.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc90.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc95.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "40"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc40.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "50"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc50.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "60"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc60.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "70"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc70.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "80"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc80.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "90"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc90.Seconds())) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(LeTag, "95"), tag.Upsert(MTTag, "wpost")}, MpoolAge.M(st.Perc95.Seconds())) - stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MpoolSize.M(int64(len(wpostTracker)))) + _ = stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(MTTag, "wpost")}, MpoolSize.M(int64(len(wpostTracker)))) fmt.Printf("%d wpost messages in mempool for average of %s, (%s / %s / %s)\n", st.Count, st.Average, st.Perc50, st.Perc80, st.Perc95) } } } - return nil }, }