From 7c61e890c5504018cebfdad522f5a639624eb311 Mon Sep 17 00:00:00 2001 From: Phi Date: Thu, 7 Sep 2023 11:19:10 +0200 Subject: [PATCH 1/2] Add timing in miner-select-messages Add timing in `lotus-shed mpool miner-select-messages` cmd. And printing amount of message in the mpool --- cmd/lotus-shed/mpool.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/lotus-shed/mpool.go b/cmd/lotus-shed/mpool.go index cfbff2abd7d..bb05c46b5a0 100644 --- a/cmd/lotus-shed/mpool.go +++ b/cmd/lotus-shed/mpool.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "time" "github.com/urfave/cli/v2" @@ -43,10 +44,20 @@ var minerSelectMsgsCmd = &cli.Command{ return err } + // Get the size of the mempool + pendingMsgs, err := api.MpoolPending(ctx, types.EmptyTSK) + if err != nil { + return err + } + mpoolSize := len(pendingMsgs) + + // Measure the time taken by MpoolSelect + startTime := time.Now() msgs, err := api.MpoolSelect(ctx, head.Key(), cctx.Float64("ticket-quality")) if err != nil { return err } + duration := time.Since(startTime) var totalGas int64 for i, f := range msgs { @@ -64,6 +75,9 @@ var minerSelectMsgsCmd = &cli.Command{ totalGas += f.Message.GasLimit } + // Log the duration, size of the mempool, and number of selected messages + fmt.Printf("Message selection took %s\n", duration) + fmt.Printf("Size of the mempool: %d\n", mpoolSize) fmt.Println("selected messages: ", len(msgs)) fmt.Printf("total gas limit of selected messages: %d / %d (%0.2f%%)\n", totalGas, build.BlockGasLimit, 100*float64(totalGas)/float64(build.BlockGasLimit)) return nil From d771aa353e97ec6e77aedfd7df15cb705bc0b935 Mon Sep 17 00:00:00 2001 From: Phi Date: Thu, 7 Sep 2023 11:27:28 +0200 Subject: [PATCH 2/2] Update comment Update comment --- cmd/lotus-shed/mpool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/lotus-shed/mpool.go b/cmd/lotus-shed/mpool.go index bb05c46b5a0..6b210bbc10e 100644 --- a/cmd/lotus-shed/mpool.go +++ b/cmd/lotus-shed/mpool.go @@ -75,7 +75,7 @@ var minerSelectMsgsCmd = &cli.Command{ totalGas += f.Message.GasLimit } - // Log the duration, size of the mempool, and number of selected messages + // Log the duration, size of the mempool, selected messages and total gas limit of selected messages fmt.Printf("Message selection took %s\n", duration) fmt.Printf("Size of the mempool: %d\n", mpoolSize) fmt.Println("selected messages: ", len(msgs))