Skip to content
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

Add ARC caching and bloom filter for blockstorage #2885

Merged
merged 4 commits into from
Jul 4, 2016

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Jun 21, 2016

Resolves #2850
License: MIT
Signed-off-by: Jakub Sztandera kubuxu@protonmail.ch

@Kubuxu Kubuxu added the status/in-progress In progress label Jun 21, 2016
@Kubuxu Kubuxu force-pushed the feature/bloom-cache branch 6 times, most recently from 4765754 to 91e0251 Compare June 22, 2016 19:49
@Kubuxu Kubuxu changed the title [WIP] Add bloom filter [WIP] Add ARC caching and bloom filter for blocks Jun 22, 2016
@Kubuxu Kubuxu changed the title [WIP] Add ARC caching and bloom filter for blocks [WIP] Add ARC caching and bloom filter for blockstorage Jun 22, 2016
@Kubuxu Kubuxu force-pushed the feature/bloom-cache branch 2 times, most recently from db06568 to 17876d9 Compare June 22, 2016 21:49
@whyrusleeping
Copy link
Member

blocked on #2601

@whyrusleeping whyrusleeping added this to the Ipfs 0.4.3 milestone Jun 23, 2016
@Kubuxu
Copy link
Member Author

Kubuxu commented Jun 23, 2016

@kevina In other issues you said that AllKeysChan my be hard on performance, what is the alternative?

@kevina
Copy link
Contributor

kevina commented Jun 23, 2016

@Kubuxu, unfortunately if you use the datastore there are not any. I decided that for the filestore it would make more sense to just use the LevelDB directly.

If I where you I try hacking go-datastore and increase the channel buffer size here, https://github.com/ipfs/go-datastore/blob/master/query/query.go#L185 and see if that speeds things up (try a buffer size of say 16, than maybe something huge like 1024 or larger).

To see how much overhead is really involved you could hack go-datastore to be able to get the underlying LevelDB involved and query it directly.

@Kubuxu Kubuxu changed the title [WIP] Add ARC caching and bloom filter for blockstorage Add ARC caching and bloom filter for blockstorage Jun 24, 2016
@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 2, 2016

Rebased on to master, tests are running.

Should I implement block cache in this PR or in a different one?

@whyrusleeping
Copy link
Member

@Kubuxu do it separately if its not too much trouble.

@Kubuxu Kubuxu added need/review Needs a review and removed status/in-progress In progress labels Jul 2, 2016
@Kubuxu Kubuxu force-pushed the feature/bloom-cache branch 2 times, most recently from 7b982fe to 7060a27 Compare July 2, 2016 06:41
@whyrusleeping
Copy link
Member

rebase on master so we dont get the docker failures?

@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 3, 2016

I should also squash everything as first commits are failing.

Replace write_cache with bloom_cache
Improve ARC caching
Fix small issue in case of AllKeysChan fails
deps: Update go-datastore
blocks/blockstore: Invalidate ARC cache before deletin block
deps: Update go-datastore

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 3, 2016

Squashed.

@@ -131,7 +131,7 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {

var err error
bs := bstore.NewBlockstore(n.Repo.Datastore())
n.Blockstore, err = bstore.WriteCached(bs, kSizeBlockstoreWriteCache)
n.Blockstore, err = bstore.BloomCached(bs, 256*1024, kSizeBlockstoreWriteCache)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this a constant

Copy link
Member Author

@Kubuxu Kubuxu Jul 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am introducing CacheOpts in the ARC caching of whole blocks I am working on right now. Would it be ok if I added it in that PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 4, 2016

@whyrusleeping I will add the context passing in the next PR too. I will have to rework all places where ctor is used either way.

@whyrusleeping
Copy link
Member

@Kubuxu i'm still not sure this is ready. How does it fare on long running nodes? What happens when the filter gets full, or there are lots of deletes, etc

@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 4, 2016

Main problem would be if there is a lot of deletes, then the false positive ratio would rise proportionally with ratio of blocks deleted, In worst case scenario (all block deleted) the performance would be where it was before the bloom filter (+1ms of latency).

Other case would be if the repo was much bigger in comparison with the bloom filter preselected size. Our current settings should provide optimal operation (<1% of false positives) up to 30k blocks in storage, at about 100k blocks it will rise to about 15% of false positives (but still it reduces number of Has requests by roughly 73%, 2% of real positives and 15% false positives).

I plan to add auto rebuild (and expand) but I would need concrete metrics for that of real operation. That is why I plan working this week on the metrics interface I mentioned on sprint.

@whyrusleeping
Copy link
Member

@Kubuxu alright, that sounds good to me. Lets get this in and get some mileage on it

@whyrusleeping whyrusleeping merged commit ad5730d into master Jul 4, 2016
@whyrusleeping whyrusleeping deleted the feature/bloom-cache branch July 4, 2016 18:57
@jbenet
Copy link
Member

jbenet commented Aug 27, 2016

it would be great to see benchmark graphs on a large typical workload with and without this PR.

We need to get into the habit of benchmarking and graphing with large batteries of tests.

@jbenet jbenet mentioned this pull request Aug 28, 2016
58 tasks
@Kubuxu
Copy link
Member Author

Kubuxu commented Aug 29, 2016

In this case the aim of introducing Bloom filtering and ARC caching on Has requests wasn't purely about performance but reducing load on the underlying file system, and thus hard drives.

We are not caching blocks (we are trying that in #2942, the performance benefits isn't clear), but only if block is available in the datastore or not.

Best metric for this change set will be reduction of disk hits when caching is available, on which I was supposed to work quite a time ago by improving metric collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants