diff options
| author | Martin Kobetic <mkobetic@gmail.com> | 2014-06-17 19:30:10 +0000 |
|---|---|---|
| committer | Martin Kobetic <mkobetic@gmail.com> | 2014-06-17 19:30:10 +0000 |
| commit | 4918ce83018aef9d80e3c9ed2035b22dd5cddac9 (patch) | |
| tree | 9a7368d7811e4f68343636542e13e1e4da6c1f90 /db.go | |
| parent | add freelist stats to db stats (diff) | |
| download | dedo-4918ce83018aef9d80e3c9ed2035b22dd5cddac9.tar.gz dedo-4918ce83018aef9d80e3c9ed2035b22dd5cddac9.tar.xz | |
drop mergeStats and move freelist stats update to Tx
Diffstat (limited to 'db.go')
| -rw-r--r-- | db.go | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -427,12 +427,16 @@ func (db *DB) removeTx(tx *Tx) { break } } + n := len(db.txs) // Unlock the meta pages. db.metalock.Unlock() // Merge statistics. - db.mergeStats(&tx.stats) + db.statlock.Lock() + db.stats.OpenTxN = n + db.stats.TxStats.add(&tx.stats) + db.statlock.Unlock() } // Update executes a function within the context of a read-write managed transaction. @@ -550,16 +554,6 @@ func (db *DB) allocate(count int) (*page, error) { return p, nil } -// mergeStats updates db stats in thread-safe manner. -func (db *DB) mergeStats(txStats *TxStats) { - db.statlock.Lock() - db.stats.FreelistN = db.freelist.count() - db.stats.FreelistAlloc = db.freelist.size() - db.stats.OpenTxN = len(db.txs) - db.stats.TxStats.add(txStats) - db.statlock.Unlock() -} - // Stats represents statistics about the database. type Stats struct { // Freelist stats |
