blockstore: change unit of bloom filter to byte from bits
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Sep 6, 2016 at 19:25 UTC
27279cdefe55b60d55db6eefbf759b4077a123ba
2 files changed
+6
-5
blocks/blockstore/caching.go
+5
-4
@@ -8,16 +8,16 @@ import (
8
9
// Next to each option is it aproximate memory usage per unit
10
type CacheOpts struct {
11
- HasBloomFilterSize int // 1 bit
11
+ HasBloomFilterSize int // 1 byte
12
HasBloomFilterHashes int // No size, 7 is usually best, consult bloom papers
13
HasARCCacheSize int // 32 bytes
14
}
15
16
func DefaultCacheOpts() CacheOpts {
17
return CacheOpts{
18
- HasBloomFilterSize: 512 * 8 * 1024,
18
+ HasBloomFilterSize: 512 << 10,
19
HasBloomFilterHashes: 7,
20
- HasARCCacheSize: 64 * 1024,
20
+ HasARCCacheSize: 64 << 10,
21
}
22
}
23
@@ -34,7 +34,8 @@ func CachedBlockstore(bs GCBlockstore,
34
return nil, errors.New("bloom filter hash count can't be 0 when there is size set")
35
}
36
if opts.HasBloomFilterSize != 0 {
37
- cbs, err = bloomCached(cbs, ctx, opts.HasBloomFilterSize, opts.HasBloomFilterHashes)
37
+ // *8 because of bytes to bits conversion
38
+ cbs, err = bloomCached(cbs, ctx, opts.HasBloomFilterSize*8, opts.HasBloomFilterHashes)
39
}
40
if opts.HasARCCacheSize > 0 {
41
cbs, err = arcCached(cbs, opts.HasARCCacheSize)
docs/config.md
+1
-1
@@ -100,7 +100,7 @@ Default: `false`
100
A boolean value. If set to true, all block reads from disk will be hashed and verified. This will cause increased CPU utilization.
101
102
- `BloomFilterSize`
103
-A number representing the size in bits of the blockstore's bloom filter. A value of zero represents the feature being disabled.
103
+A number representing the size in bytes of the blockstore's bloom filter. A value of zero represents the feature being disabled.
104
105
Default: `0`
106