mdbx more metrics (#613)

This commit is contained in:
Alex Sharov 2022-08-31 10:04:53 +07:00 committed by GitHub
parent 393fcf6856
commit 22beae4579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 54 deletions

2
go.mod
View File

@ -19,7 +19,7 @@ require (
github.com/quasilyte/go-ruleguard/dsl v0.3.21
github.com/spaolacci/murmur3 v1.1.0
github.com/stretchr/testify v1.8.0
github.com/torquem-ch/mdbx-go v0.25.2
github.com/torquem-ch/mdbx-go v0.25.3
go.uber.org/atomic v1.10.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e

4
go.sum
View File

@ -110,8 +110,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/torquem-ch/mdbx-go v0.25.2 h1:Ub5M0krJRv4SJCh1GjNmQGTaDjWKH0YaSTH+S3DmYV4=
github.com/torquem-ch/mdbx-go v0.25.2/go.mod h1:T2fsoJDVppxfAPTLd1svUgH1kpPmeXdPESmroSHcL1E=
github.com/torquem-ch/mdbx-go v0.25.3 h1:Moz3A/KERndd2aeLGygeD6zC6ZedyuFdw1pdBQRf6N8=
github.com/torquem-ch/mdbx-go v0.25.3/go.mod h1:T2fsoJDVppxfAPTLd1svUgH1kpPmeXdPESmroSHcL1E=
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ=

View File

@ -43,14 +43,15 @@ var (
DbCommitEnding = metrics.GetOrCreateSummary(`db_commit_seconds{phase="ending"}`) //nolint
DbCommitTotal = metrics.GetOrCreateSummary(`db_commit_seconds{phase="total"}`) //nolint
DbPgopsNewly = metrics.NewCounter(`db_pgops_newly`) //nolint
DbPgopsCow = metrics.NewCounter(`db_pgops_cow`) //nolint
DbPgopsClone = metrics.NewCounter(`db_pgops_clone`) //nolint
DbPgopsSplit = metrics.NewCounter(`db_pgops_split`) //nolint
DbPgopsMerge = metrics.NewCounter(`db_pgops_merge`) //nolint
DbPgopsSpill = metrics.NewCounter(`db_pgops_spill`) //nolint
DbPgopsUnspill = metrics.NewCounter(`db_pgops_unspill`) //nolint
DbPgopsWops = metrics.NewCounter(`db_pgops_wops`) //nolint
DbPgopsNewly = metrics.NewCounter(`db_pgops_newly`) //nolint
DbPgopsCow = metrics.NewCounter(`db_pgops_cow`) //nolint
DbPgopsClone = metrics.NewCounter(`db_pgops_clone`) //nolint
DbPgopsSplit = metrics.NewCounter(`db_pgops_split`) //nolint
DbPgopsMerge = metrics.NewCounter(`db_pgops_merge`) //nolint
DbPgopsSpill = metrics.NewCounter(`db_pgops_spill`) //nolint
DbPgopsUnspill = metrics.NewCounter(`db_pgops_unspill`) //nolint
DbPgopsWops = metrics.NewCounter(`db_pgops_wops`) //nolint
DbPgopsGcrtime = metrics.GetOrCreateSummary(`db_pgops_gcrtime`) //nolint
GcLeafMetric = metrics.NewCounter(`db_gc_leaf`) //nolint
GcOverflowMetric = metrics.NewCounter(`db_gc_overflow`) //nolint

View File

@ -593,6 +593,7 @@ func (tx *MdbxTx) CollectMetrics() {
kv.DbPgopsSpill.Set(info.PageOps.Spill)
kv.DbPgopsUnspill.Set(info.PageOps.Unspill)
kv.DbPgopsWops.Set(info.PageOps.Wops)
kv.DbPgopsGcrtime.Update(info.PageOps.Gcrtime.Seconds())
txInfo, err := tx.tx.Info(true)
if err != nil {
@ -611,49 +612,6 @@ func (tx *MdbxTx) CollectMetrics() {
kv.GcLeafMetric.Set(gc.LeafPages)
kv.GcOverflowMetric.Set(gc.OverflowPages)
kv.GcPagesMetric.Set((gc.LeafPages + gc.OverflowPages) * tx.db.opts.pageSize / 8)
{
st, err := tx.BucketStat(kv.PlainState)
if err != nil {
return
}
kv.TableStateLeaf.Set(st.LeafPages)
kv.TableStateBranch.Set(st.BranchPages)
kv.TableStateEntries.Set(st.Entries)
kv.TableStateSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * tx.db.opts.pageSize)
}
{
st, err := tx.BucketStat(kv.StorageChangeSet)
if err != nil {
return
}
kv.TableScsLeaf.Set(st.LeafPages)
kv.TableScsBranch.Set(st.BranchPages)
kv.TableScsEntries.Set(st.Entries)
kv.TableScsSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * tx.db.opts.pageSize)
}
{
st, err := tx.BucketStat(kv.EthTx)
if err != nil {
return
}
kv.TableTxLeaf.Set(st.LeafPages)
kv.TableTxBranch.Set(st.BranchPages)
kv.TableTxOverflow.Set(st.OverflowPages)
kv.TableTxEntries.Set(st.Entries)
kv.TableTxSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * tx.db.opts.pageSize)
}
{
st, err := tx.BucketStat(kv.Log)
if err != nil {
return
}
kv.TableLogLeaf.Set(st.LeafPages)
kv.TableLogBranch.Set(st.BranchPages)
kv.TableLogOverflow.Set(st.OverflowPages)
kv.TableLogEntries.Set(st.Entries)
kv.TableLogSize.Set((st.LeafPages + st.BranchPages + st.OverflowPages) * tx.db.opts.pageSize)
}
}
// ListBuckets - all buckets stored as keys of un-named bucket