[POC] Rust based Cuckoo Filter for m_addr_known #21837
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This proof of concept PR (leveraging work done by Cory Fields & Jeremy Rubin, see #16834) replaces the rolling bloom filter used for
m_addr_known
with a Cuckoo Filter written in Rust. I've have made some minor build related adjustments to the Rust code, which can be seen here: https://github.com/fanquake/rust-cuckoofilter/tree/cabi_build_adjustments.See "Cuckoo Filter: Practically Better Than Bloom":
Using this is a matter of:
Note that sometimes compilation will finish (i.e due to
ccache
) beforecargo
has finished generating the header and Rust lib, which will result in a compile error:In this case you can just re-run
make
. Has been tested on macOS and Linux. Sometimesp2p_getaddr_caching.py
fails, because the number of records returned falls a few short ofMAX_ADDR_TO_SEND
. Need investigating.I'm not suggesting that this be merged as-is, or that this is the ideal way of integrating Rust code (i.e copying sources in tree, using
cbindgen
), into Bitcoin Core. What I am suggesting is that the Rust discussion should continue, particularly in regards to integrations that can be done in a very non-invasive / modular fashion.Doesn't crash, but may catch your machine on fire 🔥, use with caution. More Rust related discussion available in #17090.