Merge pull request #313 from prometheus/feature/memory-profile/more-reasonable

Adjust LevelDB Defaults
This commit is contained in:
Matt T. Proud 2013-06-24 03:55:22 -07:00
commit 676c0a0f20
3 changed files with 19 additions and 19 deletions

View file

@ -40,7 +40,7 @@ GOENV = TMPDIR=$(TMPDIR) GOROOT=$(GOROOT) GOPATH=$(GOPATH)
GO = $(GOENV) $(GOCC) GO = $(GOENV) $(GOCC)
GOFMT = $(GOROOT)/bin/gofmt GOFMT = $(GOROOT)/bin/gofmt
LEVELDB_VERSION := 1.9.0 LEVELDB_VERSION := 1.12.0
PROTOCOL_BUFFERS_VERSION := 2.5.0 PROTOCOL_BUFFERS_VERSION := 2.5.0
SNAPPY_VERSION := 1.1.0 SNAPPY_VERSION := 1.1.0

View file

@ -49,13 +49,13 @@ var (
// These flag values are back of the envelope, though they seem sensible. // These flag values are back of the envelope, though they seem sensible.
// Please re-evaluate based on your own needs. // Please re-evaluate based on your own needs.
curationRemarksCacheSize = flag.Int("curationRemarksCacheSize", 50*1024*1024, "The size for the curation remarks cache (bytes).") curationRemarksCacheSize = flag.Int("curationRemarksCacheSize", 5*1024*1024, "The size for the curation remarks cache (bytes).")
fingerprintsToLabelPairCacheSize = flag.Int("fingerprintsToLabelPairCacheSizeBytes", 100*1024*1024, "The size for the fingerprint to label pair index (bytes).") fingerprintsToLabelPairCacheSize = flag.Int("fingerprintsToLabelPairCacheSizeBytes", 25*1024*1024, "The size for the fingerprint to label pair index (bytes).")
highWatermarkCacheSize = flag.Int("highWatermarksByFingerprintSizeBytes", 50*1024*1024, "The size for the metric high watermarks (bytes).") highWatermarkCacheSize = flag.Int("highWatermarksByFingerprintSizeBytes", 5*1024*1024, "The size for the metric high watermarks (bytes).")
labelNameToFingerprintsCacheSize = flag.Int("labelNameToFingerprintsCacheSizeBytes", 100*1024*1024, "The size for the label name to metric fingerprint index (bytes).") labelNameToFingerprintsCacheSize = flag.Int("labelNameToFingerprintsCacheSizeBytes", 25*1024*1024, "The size for the label name to metric fingerprint index (bytes).")
labelPairToFingerprintsCacheSize = flag.Int("labelPairToFingerprintsCacheSizeBytes", 100*1024*1024, "The size for the label pair to metric fingerprint index (bytes).") labelPairToFingerprintsCacheSize = flag.Int("labelPairToFingerprintsCacheSizeBytes", 25*1024*1024, "The size for the label pair to metric fingerprint index (bytes).")
metricMembershipIndexCacheSize = flag.Int("metricMembershipCacheSizeBytes", 50*1024*1024, "The size for the metric membership index (bytes).") metricMembershipIndexCacheSize = flag.Int("metricMembershipCacheSizeBytes", 5*1024*1024, "The size for the metric membership index (bytes).")
samplesByFingerprintCacheSize = flag.Int("samplesByFingerprintCacheSizeBytes", 500*1024*1024, "The size for the samples database (bytes).") samplesByFingerprintCacheSize = flag.Int("samplesByFingerprintCacheSizeBytes", 50*1024*1024, "The size for the samples database (bytes).")
) )
type leveldbOpener func() type leveldbOpener func()

View file

@ -29,7 +29,8 @@ import (
var ( var (
leveldbFlushOnMutate = flag.Bool("leveldbFlushOnMutate", false, "Whether LevelDB should flush every operation to disk upon mutation before returning (bool).") leveldbFlushOnMutate = flag.Bool("leveldbFlushOnMutate", false, "Whether LevelDB should flush every operation to disk upon mutation before returning (bool).")
leveldbUseSnappy = flag.Bool("leveldbUseSnappy", true, "Whether LevelDB attempts to use Snappy for compressing elements (bool).") leveldbUseSnappy = flag.Bool("leveldbUseSnappy", true, "Whether LevelDB attempts to use Snappy for compressing elements (bool).")
leveldbUseParanoidChecks = flag.Bool("leveldbUseParanoidChecks", true, "Whether LevelDB uses expensive checks (bool).") leveldbUseParanoidChecks = flag.Bool("leveldbUseParanoidChecks", false, "Whether LevelDB uses expensive checks (bool).")
maximumOpenFiles = flag.Int("leveldb.maximumOpenFiles", 128, "The maximum number of files each LevelDB may maintain.")
) )
// LevelDBPersistence is a disk-backed sorted key-value store. // LevelDBPersistence is a disk-backed sorted key-value store.
@ -168,7 +169,7 @@ func (i levigoIterator) GetError() (err error) {
return i.iterator.GetError() return i.iterator.GetError()
} }
func NewLevelDBPersistence(storageRoot string, cacheCapacity, bitsPerBloomFilterEncoded int) (p *LevelDBPersistence, err error) { func NewLevelDBPersistence(storageRoot string, cacheCapacity, bitsPerBloomFilterEncoded int) (*LevelDBPersistence, error) {
options := levigo.NewOptions() options := levigo.NewOptions()
options.SetCreateIfMissing(true) options.SetCreateIfMissing(true)
options.SetParanoidChecks(*leveldbUseParanoidChecks) options.SetParanoidChecks(*leveldbUseParanoidChecks)
@ -184,18 +185,19 @@ func NewLevelDBPersistence(storageRoot string, cacheCapacity, bitsPerBloomFilter
filterPolicy := levigo.NewBloomFilter(bitsPerBloomFilterEncoded) filterPolicy := levigo.NewBloomFilter(bitsPerBloomFilterEncoded)
options.SetFilterPolicy(filterPolicy) options.SetFilterPolicy(filterPolicy)
options.SetMaxOpenFiles(*maximumOpenFiles)
storage, err := levigo.Open(storageRoot, options) storage, err := levigo.Open(storageRoot, options)
if err != nil { if err != nil {
return return nil, err
} }
var ( readOptions := levigo.NewReadOptions()
readOptions = levigo.NewReadOptions()
writeOptions = levigo.NewWriteOptions()
)
writeOptions := levigo.NewWriteOptions()
writeOptions.SetSync(*leveldbFlushOnMutate) writeOptions.SetSync(*leveldbFlushOnMutate)
p = &LevelDBPersistence{
return &LevelDBPersistence{
path: storageRoot, path: storageRoot,
cache: cache, cache: cache,
@ -206,9 +208,7 @@ func NewLevelDBPersistence(storageRoot string, cacheCapacity, bitsPerBloomFilter
writeOptions: writeOptions, writeOptions: writeOptions,
storage: storage, storage: storage,
} }, nil
return
} }
func (l *LevelDBPersistence) Close() { func (l *LevelDBPersistence) Close() {