aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-06-18 12:35:13 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-06-18 12:35:13 -0600
commit56de9902a82bee5ba4743cef87125e9288de9fdd (patch)
treec71ca330eea56da7de76044b1f110bc808e81805
parentMerge pull request #199 from kardianos/patch-1 (diff)
parentfix up freelist stats naming and add FreeAlloc (diff)
downloaddedo-56de9902a82bee5ba4743cef87125e9288de9fdd.tar.gz
dedo-56de9902a82bee5ba4743cef87125e9288de9fdd.tar.xz
Merge pull request #201 from Shopify/freelist_stats_cleanup
Fix up freelist stats naming and add FreeAlloc
-rw-r--r--db.go5
-rw-r--r--db_test.go2
-rw-r--r--tx.go5
3 files changed, 7 insertions, 5 deletions
diff --git a/db.go b/db.go
index 13bfb16..e88e499 100644
--- a/db.go
+++ b/db.go
@@ -557,8 +557,9 @@ func (db *DB) allocate(count int) (*page, error) {
// Stats represents statistics about the database.
type Stats struct {
// Freelist stats
- FreelistN int // total number of pages on the freelist
- FreelistAlloc int // total bytes used by the freelist and the pages on it
+ FreePageN int // total number of free pages
+ FreeAlloc int // total bytes allocated in free pages
+ FreelistInuse int // total bytes used by the freelist
// Transaction stats
TxN int // total number of started read transactions
diff --git a/db_test.go b/db_test.go
index 8e9f399..55535a0 100644
--- a/db_test.go
+++ b/db_test.go
@@ -254,7 +254,7 @@ func TestDB_Stats(t *testing.T) {
})
stats := db.Stats()
assert.Equal(t, 2, stats.TxStats.PageCount, "PageCount")
- assert.Equal(t, 2, stats.FreelistN, "FreelistN %d", db.freelist.count())
+ assert.Equal(t, 2, stats.FreePageN, "FreelistN")
})
}
diff --git a/tx.go b/tx.go
index bcbcd5f..ac034ec 100644
--- a/tx.go
+++ b/tx.go
@@ -241,8 +241,9 @@ func (tx *Tx) close() {
// Merge statistics.
tx.db.statlock.Lock()
- tx.db.stats.FreelistN = freelistN
- tx.db.stats.FreelistAlloc = freelistAlloc
+ tx.db.stats.FreePageN = freelistN
+ tx.db.stats.FreeAlloc = freelistN * tx.db.pageSize
+ tx.db.stats.FreelistInuse = freelistAlloc
tx.db.stats.TxStats.add(&tx.stats)
tx.db.statlock.Unlock()
} else {