Skip to content

Commit

Permalink
Merge pull request #2 from DeBankDeFi/withmetrics
Browse files Browse the repository at this point in the history
support for getting cache statistics
  • Loading branch information
windycrypto authored Oct 18, 2022
2 parents e25a061 + 408d4b9 commit 55b04b4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
28 changes: 28 additions & 0 deletions immutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,31 @@ func (t *ImmutableTree) nodeSize() int {
})
return size
}

func (t *ImmutableTree) GetIAVLNodeCacheHitCnt() uint64 {
if t.ndb.opts.Stat == nil {
return 0
}
return t.ndb.opts.Stat.GetCacheHitCnt()
}

func (t *ImmutableTree) GetIAVLNodeCacheMissCnt() uint64 {
if t.ndb.opts.Stat == nil {
return 0
}
return t.ndb.opts.Stat.GetCacheMissCnt()
}

func (t *ImmutableTree) GetIAVLNodeFastCacheHitCnt() uint64 {
if t.ndb.opts.Stat == nil {
return 0
}
return t.ndb.opts.Stat.GetFastCacheHitCnt()
}

func (t *ImmutableTree) GetIAVLNodeFastCacheMissCnt() uint64 {
if t.ndb.opts.Stat == nil {
return 0
}
return t.ndb.opts.Stat.GetFastCacheMissCnt()
}
28 changes: 28 additions & 0 deletions mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,3 +1236,31 @@ func (tree *MutableTree) addOrphans(orphans []*Node) error {
}
return nil
}

func (tree *MutableTree) GetIAVLNodeCacheHitCnt() uint64 {
if tree.ndb.opts.Stat == nil {
return 0
}
return tree.ndb.opts.Stat.GetCacheHitCnt()
}

func (tree *MutableTree) GetIAVLNodeCacheMissCnt() uint64 {
if tree.ndb.opts.Stat == nil {
return 0
}
return tree.ndb.opts.Stat.GetCacheMissCnt()
}

func (tree *MutableTree) GetIAVLNodeFastCacheHitCnt() uint64 {
if tree.ndb.opts.Stat == nil {
return 0
}
return tree.ndb.opts.Stat.GetFastCacheHitCnt()
}

func (tree *MutableTree) GetIAVLNodeFastCacheMissCnt() uint64 {
if tree.ndb.opts.Stat == nil {
return 0
}
return tree.ndb.opts.Stat.GetFastCacheMissCnt()
}

0 comments on commit 55b04b4

Please sign in to comment.