Commit b9f5b406 authored by Jakub Sztandera's avatar Jakub Sztandera

blockstore: change unit of bloom filter to byte from bits

License: MIT
Signed-off-by: default avatarJakub Sztandera <kubuxu@protonmail.ch>
parent 680c54e9
...@@ -8,16 +8,16 @@ import ( ...@@ -8,16 +8,16 @@ import (
// Next to each option is it aproximate memory usage per unit // Next to each option is it aproximate memory usage per unit
type CacheOpts struct { type CacheOpts struct {
HasBloomFilterSize int // 1 bit HasBloomFilterSize int // 1 byte
HasBloomFilterHashes int // No size, 7 is usually best, consult bloom papers HasBloomFilterHashes int // No size, 7 is usually best, consult bloom papers
HasARCCacheSize int // 32 bytes HasARCCacheSize int // 32 bytes
} }
func DefaultCacheOpts() CacheOpts { func DefaultCacheOpts() CacheOpts {
return CacheOpts{ return CacheOpts{
HasBloomFilterSize: 512 * 8 * 1024, HasBloomFilterSize: 512 << 10,
HasBloomFilterHashes: 7, HasBloomFilterHashes: 7,
HasARCCacheSize: 64 * 1024, HasARCCacheSize: 64 << 10,
} }
} }
...@@ -34,7 +34,8 @@ func CachedBlockstore(bs GCBlockstore, ...@@ -34,7 +34,8 @@ func CachedBlockstore(bs GCBlockstore,
return nil, errors.New("bloom filter hash count can't be 0 when there is size set") return nil, errors.New("bloom filter hash count can't be 0 when there is size set")
} }
if opts.HasBloomFilterSize != 0 { if opts.HasBloomFilterSize != 0 {
cbs, err = bloomCached(cbs, ctx, opts.HasBloomFilterSize, opts.HasBloomFilterHashes) // *8 because of bytes to bits conversion
cbs, err = bloomCached(cbs, ctx, opts.HasBloomFilterSize*8, opts.HasBloomFilterHashes)
} }
if opts.HasARCCacheSize > 0 { if opts.HasARCCacheSize > 0 {
cbs, err = arcCached(cbs, opts.HasARCCacheSize) cbs, err = arcCached(cbs, opts.HasARCCacheSize)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment