LevelDB vendor has now the same version as used in go-ethereum 1.8.5 (#883)

* LevelDB version is now same as in go-ethereum

* make dep-ensure untracked LevelDB storage.go
This commit is contained in:
Frank Mueller 2018-05-01 19:09:19 +02:00 committed by GitHub
parent 809c5a4db2
commit 123382cdf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 81 additions and 9 deletions

4
Gopkg.lock generated
View File

@ -345,7 +345,7 @@
"leveldb/table", "leveldb/table",
"leveldb/util" "leveldb/util"
] ]
revision = "34011bf325bce385408353a30b101fe5e923eb6e" revision = "169b1b37be738edb2813dab48c97a549bcf99bb5"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -483,6 +483,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "749bac1b2eea5afcdd2fdca30c2d1b68763378c463f7c409742de028c4fe8402" inputs-digest = "760ef0bfdecf48e51bf8a9e4409c04d46d1c74c8c42a8ca75447d5fd197f5095"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View File

@ -138,7 +138,7 @@ ignored = [ "github.com/ethereum/go-ethereum/ethapi" ]
[[override]] [[override]]
name = "github.com/syndtr/goleveldb" name = "github.com/syndtr/goleveldb"
revision = "34011bf325bce385408353a30b101fe5e923eb6e" revision = "169b1b37be738edb2813dab48c97a549bcf99bb5"
[[constraint]] [[constraint]]
branch = "master" branch = "master"

View File

@ -906,6 +906,8 @@ func (db *DB) GetSnapshot() (*Snapshot, error) {
// Returns the number of files at level 'n'. // Returns the number of files at level 'n'.
// leveldb.stats // leveldb.stats
// Returns statistics of the underlying DB. // Returns statistics of the underlying DB.
// leveldb.iostats
// Returns statistics of effective disk read and write.
// leveldb.writedelay // leveldb.writedelay
// Returns cumulative write delay caused by compaction. // Returns cumulative write delay caused by compaction.
// leveldb.sstables // leveldb.sstables
@ -959,6 +961,10 @@ func (db *DB) GetProperty(name string) (value string, err error) {
level, len(tables), float64(tables.size())/1048576.0, duration.Seconds(), level, len(tables), float64(tables.size())/1048576.0, duration.Seconds(),
float64(read)/1048576.0, float64(write)/1048576.0) float64(read)/1048576.0, float64(write)/1048576.0)
} }
case p == "iostats":
value = fmt.Sprintf("Read(MB):%.5f Write(MB):%.5f",
float64(db.s.stor.reads())/1048576.0,
float64(db.s.stor.writes())/1048576.0)
case p == "writedelay": case p == "writedelay":
writeDelayN, writeDelay := atomic.LoadInt32(&db.cWriteDelayN), time.Duration(atomic.LoadInt64(&db.cWriteDelay)) writeDelayN, writeDelay := atomic.LoadInt32(&db.cWriteDelayN), time.Duration(atomic.LoadInt64(&db.cWriteDelay))
value = fmt.Sprintf("DelayN:%d Delay:%s", writeDelayN, writeDelay) value = fmt.Sprintf("DelayN:%d Delay:%s", writeDelayN, writeDelay)

View File

@ -146,7 +146,7 @@ func (db *DB) unlockWrite(overflow bool, merged int, err error) {
} }
} }
// ourBatch if defined should equal with batch. // ourBatch is batch that we can modify.
func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error { func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error {
// Try to flush memdb. This method would also trying to throttle writes // Try to flush memdb. This method would also trying to throttle writes
// if it is too fast and compaction cannot catch-up. // if it is too fast and compaction cannot catch-up.
@ -215,6 +215,11 @@ func (db *DB) writeLocked(batch, ourBatch *Batch, merge, sync bool) error {
} }
} }
// Release ourBatch if any.
if ourBatch != nil {
defer db.batchPool.Put(ourBatch)
}
// Seq number. // Seq number.
seq := db.seq + 1 seq := db.seq + 1

View File

@ -42,7 +42,7 @@ type session struct {
stTempFileNum int64 stTempFileNum int64
stSeqNum uint64 // last mem compacted seq; need external synchronization stSeqNum uint64 // last mem compacted seq; need external synchronization
stor storage.Storage stor *iStorage
storLock storage.Locker storLock storage.Locker
o *cachedOptions o *cachedOptions
icmp *iComparer icmp *iComparer
@ -68,7 +68,7 @@ func newSession(stor storage.Storage, o *opt.Options) (s *session, err error) {
return return
} }
s = &session{ s = &session{
stor: stor, stor: newIStorage(stor),
storLock: storLock, storLock: storLock,
fileRef: make(map[int64]int), fileRef: make(map[int64]int),
} }

63
vendor/github.com/syndtr/goleveldb/leveldb/storage.go generated vendored Normal file
View File

@ -0,0 +1,63 @@
package leveldb
import (
"github.com/syndtr/goleveldb/leveldb/storage"
"sync/atomic"
)
type iStorage struct {
storage.Storage
read uint64
write uint64
}
func (c *iStorage) Open(fd storage.FileDesc) (storage.Reader, error) {
r, err := c.Storage.Open(fd)
return &iStorageReader{r, c}, err
}
func (c *iStorage) Create(fd storage.FileDesc) (storage.Writer, error) {
w, err := c.Storage.Create(fd)
return &iStorageWriter{w, c}, err
}
func (c *iStorage) reads() uint64 {
return atomic.LoadUint64(&c.read)
}
func (c *iStorage) writes() uint64 {
return atomic.LoadUint64(&c.write)
}
// newIStorage returns the given storage wrapped by iStorage.
func newIStorage(s storage.Storage) *iStorage {
return &iStorage{s, 0, 0}
}
type iStorageReader struct {
storage.Reader
c *iStorage
}
func (r *iStorageReader) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
atomic.AddUint64(&r.c.read, uint64(n))
return n, err
}
func (r *iStorageReader) ReadAt(p []byte, off int64) (n int, err error) {
n, err = r.Reader.ReadAt(p, off)
atomic.AddUint64(&r.c.read, uint64(n))
return n, err
}
type iStorageWriter struct {
storage.Writer
c *iStorage
}
func (w *iStorageWriter) Write(p []byte) (n int, err error) {
n, err = w.Writer.Write(p)
atomic.AddUint64(&w.c.write, uint64(n))
return n, err
}

View File

@ -8,7 +8,6 @@ package storage
import ( import (
"os" "os"
"path/filepath"
) )
type plan9FileLock struct { type plan9FileLock struct {
@ -48,8 +47,7 @@ func rename(oldpath, newpath string) error {
} }
} }
_, fname := filepath.Split(newpath) return os.Rename(oldpath, newpath)
return os.Rename(oldpath, fname)
} }
func syncDir(name string) error { func syncDir(name string) error {