Skip to content

Commit

Permalink
Merge pull request #6 from zuoyebang/dev
Browse files Browse the repository at this point in the history
add cache debug info
  • Loading branch information
xingfu89 authored Apr 1, 2024
2 parents d7ca85d + c2ef30a commit 88b3d7f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
3 changes: 3 additions & 0 deletions bitpage/bitpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ func (b *Bitpage) SetPage(pn PageNum, p *page) {
}

func (b *Bitpage) GetCacheMetrics() string {
if b.cache == nil {
return ""
}
return b.cache.MetricsInfo()
}

Expand Down
4 changes: 4 additions & 0 deletions bitree/bitree.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ func (t *Bitree) BitreeDebugInfo(dataType string) string {
)
}

if t.opts.UseBlockCompress {
fmt.Fprintf(buf, "%s-bitpage%d-blockCache: %s\n", dataType, t.index, t.bpage.GetCacheMetrics())
}

return buf.String()
}

Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (d *DB) Close() error {
err = utils.FirstError(err, d.walDir.Close())
}

d.readState.val.unrefLocked()
d.readState.val.unref()

for _, mem := range d.mu.mem.queue {
mem.readerUnref()
Expand Down
11 changes: 1 addition & 10 deletions read_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ func (s *readState) unref() {
}
}

func (s *readState) unrefLocked() {
if atomic.AddInt32(&s.refcnt, -1) != 0 {
return
}
for _, mem := range s.memtables {
mem.readerUnref()
}
}

func (d *DB) loadReadState() *readState {
d.readState.RLock()
state := d.readState.val
Expand All @@ -69,6 +60,6 @@ func (d *DB) updateReadStateLocked() {
d.readState.Unlock()

if old != nil {
old.unrefLocked()
old.unref()
}
}

0 comments on commit 88b3d7f

Please sign in to comment.