From abb64187311fd40ae0b41c9076e67aa6fab61e45 Mon Sep 17 00:00:00 2001 From: brion Date: Mon, 17 Oct 2022 17:15:21 +0800 Subject: [PATCH 1/3] add support for getting cache statistics --- immutable_tree.go | 28 ++++++++++++++++++++++++++++ mutable_tree.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/immutable_tree.go b/immutable_tree.go index 5a59b1afd..55dc54b61 100644 --- a/immutable_tree.go +++ b/immutable_tree.go @@ -320,3 +320,31 @@ func (t *ImmutableTree) nodeSize() int { }) return size } + +func (tree *ImmutableTree) GetIAVLNodeCacheHitCnt() uint64 { + if tree.ndb.opts.Stat == nil { + return 0 + } + return tree.ndb.opts.Stat.GetCacheHitCnt() +} + +func (tree *ImmutableTree) GetIAVLNodeCacheMissCnt() uint64 { + if tree.ndb.opts.Stat == nil { + return 0 + } + return tree.ndb.opts.Stat.GetCacheMissCnt() +} + +func (tree *ImmutableTree) GetIAVLNodeFastCacheHitCnt() uint64 { + if tree.ndb.opts.Stat == nil { + return 0 + } + return tree.ndb.opts.Stat.GetFastCacheHitCnt() +} + +func (tree *ImmutableTree) GetIAVLNodeFastCacheMissCnt() uint64 { + if tree.ndb.opts.Stat == nil { + return 0 + } + return tree.ndb.opts.Stat.GetFastCacheMissCnt() +} diff --git a/mutable_tree.go b/mutable_tree.go index 5579ef591..4221b835d 100644 --- a/mutable_tree.go +++ b/mutable_tree.go @@ -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() +} From b1c0e30cc5b0a22bfcb95d345e523e2819b04951 Mon Sep 17 00:00:00 2001 From: brion Date: Mon, 17 Oct 2022 17:15:53 +0800 Subject: [PATCH 2/3] add support for getting cache statistics --- immutable_tree.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/immutable_tree.go b/immutable_tree.go index 55dc54b61..5a59b1afd 100644 --- a/immutable_tree.go +++ b/immutable_tree.go @@ -320,31 +320,3 @@ func (t *ImmutableTree) nodeSize() int { }) return size } - -func (tree *ImmutableTree) GetIAVLNodeCacheHitCnt() uint64 { - if tree.ndb.opts.Stat == nil { - return 0 - } - return tree.ndb.opts.Stat.GetCacheHitCnt() -} - -func (tree *ImmutableTree) GetIAVLNodeCacheMissCnt() uint64 { - if tree.ndb.opts.Stat == nil { - return 0 - } - return tree.ndb.opts.Stat.GetCacheMissCnt() -} - -func (tree *ImmutableTree) GetIAVLNodeFastCacheHitCnt() uint64 { - if tree.ndb.opts.Stat == nil { - return 0 - } - return tree.ndb.opts.Stat.GetFastCacheHitCnt() -} - -func (tree *ImmutableTree) GetIAVLNodeFastCacheMissCnt() uint64 { - if tree.ndb.opts.Stat == nil { - return 0 - } - return tree.ndb.opts.Stat.GetFastCacheMissCnt() -} From 408d4b9dc0dc96199b956822893ed639c2f1dc4a Mon Sep 17 00:00:00 2001 From: brion Date: Tue, 18 Oct 2022 23:20:56 +0800 Subject: [PATCH 3/3] immutable tree implement cache stat interface --- immutable_tree.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/immutable_tree.go b/immutable_tree.go index 5a59b1afd..e2a135c77 100644 --- a/immutable_tree.go +++ b/immutable_tree.go @@ -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() +}