aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go')
-rw-r--r--vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
index 0c1b9a5..6b70eb2 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
@@ -8,6 +8,7 @@ package leveldb
import (
"sync"
+ "sync/atomic"
"time"
"github.com/syndtr/goleveldb/leveldb/errors"
@@ -260,7 +261,7 @@ func (db *DB) compactionCommit(name string, rec *sessionRecord) {
db.compCommitLk.Lock()
defer db.compCommitLk.Unlock() // Defer is necessary.
db.compactionTransactFunc(name+"@commit", func(cnt *compactionTransactCounter) error {
- return db.s.commit(rec)
+ return db.s.commit(rec, true)
}, nil)
}
@@ -324,10 +325,12 @@ func (db *DB) memCompaction() {
db.logf("memdb@flush committed F·%d T·%v", len(rec.addedTables), stats.duration)
+ // Save compaction stats
for _, r := range rec.addedTables {
stats.write += r.size
}
db.compStats.addStat(flushLevel, stats)
+ atomic.AddUint32(&db.memComp, 1)
// Drop frozen memdb.
db.dropFrozenMem()
@@ -588,6 +591,14 @@ func (db *DB) tableCompaction(c *compaction, noTrivial bool) {
for i := range stats {
db.compStats.addStat(c.sourceLevel+1, &stats[i])
}
+ switch c.typ {
+ case level0Compaction:
+ atomic.AddUint32(&db.level0Comp, 1)
+ case nonLevel0Compaction:
+ atomic.AddUint32(&db.nonLevel0Comp, 1)
+ case seekCompaction:
+ atomic.AddUint32(&db.seekComp, 1)
+ }
}
func (db *DB) tableRangeCompaction(level int, umin, umax []byte) error {