Add metrics for VM flush duration and obj count
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
c40c513508
commit
336aa95ab5
@ -9,6 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
"github.com/filecoin-project/lotus/metrics"
|
||||||
|
|
||||||
block "github.com/ipfs/go-block-format"
|
block "github.com/ipfs/go-block-format"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
@ -16,6 +17,7 @@ import (
|
|||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
mh "github.com/multiformats/go-multihash"
|
mh "github.com/multiformats/go-multihash"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
"go.opencensus.io/stats"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@ -618,7 +620,7 @@ func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) {
|
|||||||
return cid.Undef, xerrors.Errorf("flushing vm: %w", err)
|
return cid.Undef, xerrors.Errorf("flushing vm: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := Copy(ctx, from, to, root); err != nil {
|
if err := Copy(context.WithValue(ctx, "vm-flush", true), from, to, root); err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("copying tree: %w", err)
|
return cid.Undef, xerrors.Errorf("copying tree: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,6 +677,7 @@ func linksForObj(blk block.Block, cb func(cid.Cid)) error {
|
|||||||
func Copy(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid) error {
|
func Copy(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid) error {
|
||||||
ctx, span := trace.StartSpan(ctx, "vm.Copy") // nolint
|
ctx, span := trace.StartSpan(ctx, "vm.Copy") // nolint
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
var numBlocks int
|
var numBlocks int
|
||||||
var totalCopySize int
|
var totalCopySize int
|
||||||
@ -708,6 +711,10 @@ func Copy(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid) err
|
|||||||
trace.Int64Attribute("numBlocks", int64(numBlocks)),
|
trace.Int64Attribute("numBlocks", int64(numBlocks)),
|
||||||
trace.Int64Attribute("copySize", int64(totalCopySize)),
|
trace.Int64Attribute("copySize", int64(totalCopySize)),
|
||||||
)
|
)
|
||||||
|
if yes, ok := ctx.Value("vm-flush").(bool); yes && ok {
|
||||||
|
took := metrics.SinceInMilliseconds(start)
|
||||||
|
stats.Record(ctx, metrics.VMFlushCopyCount.M(int64(numBlocks)), metrics.VMFlushCopyDuration.M(took))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,8 @@ var (
|
|||||||
PubsubSendRPC = stats.Int64("pubsub/send_rpc", "Counter for total sent RPCs", stats.UnitDimensionless)
|
PubsubSendRPC = stats.Int64("pubsub/send_rpc", "Counter for total sent RPCs", stats.UnitDimensionless)
|
||||||
PubsubDropRPC = stats.Int64("pubsub/drop_rpc", "Counter for total dropped RPCs", stats.UnitDimensionless)
|
PubsubDropRPC = stats.Int64("pubsub/drop_rpc", "Counter for total dropped RPCs", stats.UnitDimensionless)
|
||||||
APIRequestDuration = stats.Float64("api/request_duration_ms", "Duration of API requests", stats.UnitMilliseconds)
|
APIRequestDuration = stats.Float64("api/request_duration_ms", "Duration of API requests", stats.UnitMilliseconds)
|
||||||
|
VMFlushCopyDuration = stats.Float64("vm/flush_copy_ms", "Time spent in VM Flush Copy", stats.UnitMilliseconds)
|
||||||
|
VMFlushCopyCount = stats.Int64("vm/flush_copy_count", "Number of copied objects", stats.UnitDimensionless)
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -146,6 +148,14 @@ var (
|
|||||||
Aggregation: defaultMillisecondsDistribution,
|
Aggregation: defaultMillisecondsDistribution,
|
||||||
TagKeys: []tag.Key{APIInterface, Endpoint},
|
TagKeys: []tag.Key{APIInterface, Endpoint},
|
||||||
}
|
}
|
||||||
|
VMFlushCopyDurationView = &view.View{
|
||||||
|
Measure: VMFlushCopyDuration,
|
||||||
|
Aggregation: view.Sum(),
|
||||||
|
}
|
||||||
|
VMFlushCopyCountView = &view.View{
|
||||||
|
Measure: VMFlushCopyCount,
|
||||||
|
Aggregation: view.Sum(),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultViews is an array of OpenCensus views for metric gathering purposes
|
// DefaultViews is an array of OpenCensus views for metric gathering purposes
|
||||||
@ -171,6 +181,8 @@ var DefaultViews = append([]*view.View{
|
|||||||
PubsubSendRPCView,
|
PubsubSendRPCView,
|
||||||
PubsubDropRPCView,
|
PubsubDropRPCView,
|
||||||
APIRequestDurationView,
|
APIRequestDurationView,
|
||||||
|
VMFlushCopyCountView,
|
||||||
|
VMFlushCopyDurationView,
|
||||||
},
|
},
|
||||||
rpcmetrics.DefaultViews...)
|
rpcmetrics.DefaultViews...)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user