Skip to content

Commit

Permalink
Allow to configure/disable the datastore's ARC cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMure committed Sep 6, 2019
1 parent 22532e2 commit 979f456
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config) fx.Option {
func Storage(bcfg *BuildCfg, cfg *config.Config) fx.Option {
cacheOpts := blockstore.DefaultCacheOpts()
cacheOpts.HasBloomFilterSize = cfg.Datastore.BloomFilterSize
cacheOpts.HasARCCacheSize = cfg.Datastore.ARCCacheSize
if !bcfg.Permanent {
cacheOpts.HasBloomFilterSize = 0
}
Expand Down
2 changes: 1 addition & 1 deletion core/node/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, nilRepo bool, hashOnRead
bs = blockstore.NewBlockstore(rds)
bs = &verifbs.VerifBS{Blockstore: bs}

if !nilRepo {
if !nilRepo && (cacheOpts.HasBloomFilterSize > 0 || cacheOpts.HasARCCacheSize > 0) {
bs, err = blockstore.CachedBlockstore(helpers.LifecycleCtx(mctx, lc), bs, cacheOpts)
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ As of writing, [7 hash functions](https://github.com/ipfs/go-ipfs-blockstore/blo

Default: `0`

- `ARCCacheSize`
A number representing the number of entries of the blockstore's [ARC cache](https://en.wikipedia.org/wiki/Adaptive_replacement_cache). A value of zero represents the feature being disabled.

Default: `65536`

- `Spec`
Spec defines the structure of the ipfs datastore. It is a composable structure, where each datastore is represented by a json object. Datastores can wrap other datastores to provide extra functionality (eg metrics, logging, or caching).

Expand Down

0 comments on commit 979f456

Please sign in to comment.