Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: shed: additional metrics in mpool miner-select-messages #11253

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/lotus-shed/mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"time"

"github.com/urfave/cli/v2"

Expand Down Expand Up @@ -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 {
Expand All @@ -64,6 +75,9 @@ var minerSelectMsgsCmd = &cli.Command{
totalGas += f.Message.GasLimit
}

// 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))
fmt.Printf("total gas limit of selected messages: %d / %d (%0.2f%%)\n", totalGas, build.BlockGasLimit, 100*float64(totalGas)/float64(build.BlockGasLimit))
return nil
Expand Down