-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: do not run bloom in case of ephemeral node #2953
Changes from all commits
3035aa8
016d3d9
61a3d12
e85a39c
af77782
58526b2
d9bafb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package blockstore | ||
|
||
import ( | ||
"errors" | ||
|
||
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" | ||
) | ||
|
||
// Next to each option is it aproximate memory usage per unit | ||
type CacheOpts struct { | ||
HasBloomFilterSize int // 1 bit | ||
HasBloomFilterHashes int // No size, 7 is usually best, consult bloom papers | ||
HasARCCacheSize int // 32 bytes | ||
} | ||
|
||
func DefaultCacheOpts() CacheOpts { | ||
return CacheOpts{ | ||
HasBloomFilterSize: 512 * 8 * 1024, | ||
HasBloomFilterHashes: 7, | ||
HasARCCacheSize: 64 * 1024, | ||
} | ||
} | ||
|
||
func CachedBlockstore(bs GCBlockstore, | ||
ctx context.Context, opts CacheOpts) (cbs GCBlockstore, err error) { | ||
cbs = bs | ||
|
||
if opts.HasBloomFilterSize < 0 || opts.HasBloomFilterHashes < 0 || | ||
opts.HasARCCacheSize < 0 { | ||
return nil, errors.New("all options for cache need to be greater than zero") | ||
} | ||
|
||
if opts.HasBloomFilterSize != 0 && opts.HasBloomFilterHashes == 0 { | ||
return nil, errors.New("bloom filter hash count can't be 0 when there is size set") | ||
} | ||
if opts.HasBloomFilterSize != 0 { | ||
cbs, err = bloomCached(cbs, ctx, opts.HasBloomFilterSize, opts.HasBloomFilterHashes, | ||
opts.HasARCCacheSize) | ||
} | ||
|
||
return cbs, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ type BuildCfg struct { | |
// If online is set, the node will have networking enabled | ||
Online bool | ||
|
||
// If permament then node should run more expensive processes | ||
// that will improve performance in long run | ||
Permament bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not a good name. the node wont ever be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't use This part is on my list to refactor for the split to: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
those aren't good distinctions. an ephemeral node may be online and may be offline. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we don't have Online Ephemeral, but very good point. |
||
|
||
// If NilRepo is set, a repo backed by a nil datastore will be constructed | ||
NilRepo bool | ||
|
||
|
@@ -131,7 +135,12 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error { | |
|
||
var err error | ||
bs := bstore.NewBlockstore(n.Repo.Datastore()) | ||
n.Blockstore, err = bstore.BloomCached(bs, 256*1024, kSizeBlockstoreWriteCache) | ||
opts := bstore.DefaultCacheOpts() | ||
if !cfg.Permament { | ||
opts.HasBloomFilterSize = 0 | ||
} | ||
|
||
n.Blockstore, err = bstore.CachedBlockstore(bs, ctx, opts) | ||
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 0
-- reduces the failure cases (negative numbers)