Add total to db.GetMemoryStats
This commit is contained in:
parent
ad886d1f9b
commit
7d28b710e3
@ -10,6 +10,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bsm/go-vlq"
|
"github.com/bsm/go-vlq"
|
||||||
@ -138,7 +139,17 @@ func (d *RocksDB) Reopen() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func atoi(s string) int {
|
||||||
|
i, err := strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMemoryStats returns memory usage statistics as reported by RocksDB
|
||||||
func (d *RocksDB) GetMemoryStats() string {
|
func (d *RocksDB) GetMemoryStats() string {
|
||||||
|
var total, indexAndFilter, memtable int
|
||||||
type columnStats struct {
|
type columnStats struct {
|
||||||
name string
|
name string
|
||||||
indexAndFilter string
|
indexAndFilter string
|
||||||
@ -149,21 +160,20 @@ func (d *RocksDB) GetMemoryStats() string {
|
|||||||
cs[i].name = cfNames[i]
|
cs[i].name = cfNames[i]
|
||||||
cs[i].indexAndFilter = d.db.GetPropertyCF("rocksdb.estimate-table-readers-mem", d.cfh[i])
|
cs[i].indexAndFilter = d.db.GetPropertyCF("rocksdb.estimate-table-readers-mem", d.cfh[i])
|
||||||
cs[i].memtable = d.db.GetPropertyCF("rocksdb.cur-size-all-mem-tables", d.cfh[i])
|
cs[i].memtable = d.db.GetPropertyCF("rocksdb.cur-size-all-mem-tables", d.cfh[i])
|
||||||
|
indexAndFilter += atoi(cs[i].indexAndFilter)
|
||||||
|
memtable += atoi(cs[i].memtable)
|
||||||
}
|
}
|
||||||
m := struct {
|
m := struct {
|
||||||
cacheUsage int
|
cacheUsage int
|
||||||
pinnedCacheUsage int
|
pinnedCacheUsage int
|
||||||
indexAndFilter string
|
|
||||||
memtable string
|
|
||||||
columns []columnStats
|
columns []columnStats
|
||||||
}{
|
}{
|
||||||
cacheUsage: d.cache.GetUsage(),
|
cacheUsage: d.cache.GetUsage(),
|
||||||
pinnedCacheUsage: d.cache.GetPinnedUsage(),
|
pinnedCacheUsage: d.cache.GetPinnedUsage(),
|
||||||
indexAndFilter: d.db.GetProperty("rocksdb.estimate-table-readers-mem"),
|
|
||||||
memtable: d.db.GetProperty("rocksdb.cur-size-all-mem-tables"),
|
|
||||||
columns: cs,
|
columns: cs,
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%+v", m)
|
total = m.cacheUsage + indexAndFilter + memtable
|
||||||
|
return fmt.Sprintf("Total %d, indexAndFilter %d, memtable %d, %+v", total, indexAndFilter, memtable, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StopIteration is returned by callback function to signal stop of iteration
|
// StopIteration is returned by callback function to signal stop of iteration
|
||||||
@ -358,6 +368,7 @@ func (d *RocksDB) resetValueSatToZero(valueSat *big.Int, addrDesc bchain.Address
|
|||||||
valueSat.SetInt64(0)
|
valueSat.SetInt64(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAndResetConnectBlockStats gets statistics about cache usage in connect blocks and resets the counters
|
||||||
func (d *RocksDB) GetAndResetConnectBlockStats() string {
|
func (d *RocksDB) GetAndResetConnectBlockStats() string {
|
||||||
s := fmt.Sprintf("%+v", d.cbs)
|
s := fmt.Sprintf("%+v", d.cbs)
|
||||||
d.cbs = connectBlockStats{}
|
d.cbs = connectBlockStats{}
|
||||||
@ -649,6 +660,7 @@ func (d *RocksDB) getBlockTxs(height uint32) ([]blockTxs, error) {
|
|||||||
return bt, nil
|
return bt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAddrDescBalance returns AddrBalance for given addrDesc
|
||||||
func (d *RocksDB) GetAddrDescBalance(addrDesc bchain.AddressDescriptor) (*AddrBalance, error) {
|
func (d *RocksDB) GetAddrDescBalance(addrDesc bchain.AddressDescriptor) (*AddrBalance, error) {
|
||||||
val, err := d.db.GetCF(d.ro, d.cfh[cfAddressBalance], addrDesc)
|
val, err := d.db.GetCF(d.ro, d.cfh[cfAddressBalance], addrDesc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1388,6 +1400,8 @@ func (d *RocksDB) LoadInternalState(rpcCoin string) (*common.InternalState, erro
|
|||||||
return is, nil
|
return is, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetInconsistentState sets the internal state to DbStateInconsistent or DbStateOpen based on inconsistent parameter
|
||||||
|
// db in left in DbStateInconsistent state cannot be used and must be recreated
|
||||||
func (d *RocksDB) SetInconsistentState(inconsistent bool) error {
|
func (d *RocksDB) SetInconsistentState(inconsistent bool) error {
|
||||||
if d.is == nil {
|
if d.is == nil {
|
||||||
return errors.New("Internal state not created")
|
return errors.New("Internal state not created")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user