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

Switch to a more efficient rolling Bloom filter #7113

Merged
merged 1 commit into from Dec 3, 2015

Conversation

sipa
Copy link
Member

@sipa sipa commented Nov 27, 2015

For each 'bit' in the filter we really maintain 2 bits, which store either:

  • 0: not set
  • 1-3: set in generation N

After (nElements / 2) insertions, we switch to a new generation, and wipe entries which already had the new generation number, effectively switching from the last 1.5 * nElements set to the last 1.0 * nElements set.

This is 25% more space efficient than the previous implementation, and can (at peak) store 1.5 times the requested amount of history (though only 1.0 times the requested history is guaranteed).

The existing unit tests should be sufficient.

@laanwj
Copy link
Member

laanwj commented Nov 27, 2015

Nice!
(discussion was in Replace setInventoryKnown with a rolling bloom filter. #7100 )

For each 'bit' in the filter we really maintain 2 bits, which store either:
0: not set
1-3: set in generation N

After (nElements / 2) insertions, we switch to a new generation, and wipe
entries which already had the new generation number, effectively switching
from the last 1.5 * nElements set to the last 1.0 * nElements set.

This is 25% more space efficient than the previous implementation, and can
(at peak) store 1.5 times the requested amount of history (though only
1.0 times the requested history is guaranteed).

The existing unit tests should be sufficient.
@pstratem
Copy link
Contributor

ACK

@ghost
Copy link

ghost commented Nov 30, 2015

Yes

@laanwj
Copy link
Member

laanwj commented Dec 3, 2015

utACK

@laanwj laanwj merged commit 086ee67 into bitcoin:master Dec 3, 2015
laanwj added a commit that referenced this pull request Dec 3, 2015
086ee67 Switch to a more efficient rolling Bloom filter (Pieter Wuille)
codablock pushed a commit to codablock/dash that referenced this pull request Dec 9, 2017
086ee67 Switch to a more efficient rolling Bloom filter (Pieter Wuille)
furszy added a commit to PIVX-Project/PIVX that referenced this pull request Feb 14, 2021
1378196 Removes unsed `CBloomFilter` constructor. (251)
c4c4c9c Switch to a more efficient rolling Bloom filter (Pieter Wuille)

Pull request description:

  From bitcoin#7113

  > For each 'bit' in the filter we really maintain 2 bits, which store either:
  >
  >0: not set
  >1-3: set in generation N
  >After (nElements / 2) insertions, we switch to a new generation, and wipe entries which already had the new generation number, effectively switching from the last 1.5 * nElements set to the last 1.0 * nElements set.
  >
  >This is 25% more space efficient than the previous implementation, and can (at peak) store 1.5 times the requested amount of history (though only 1.0 times the requested history is guaranteed).
  >
  >The existing unit tests should be sufficient.

  Also included bitcoin#13948

ACKs for top commit:
  furszy:
    good, ACK 1378196
  Fuzzbawls:
    utACK 1378196

Tree-SHA512: c73e34086b2a8a1fd1df5acff9a72c034ac94608871e90a06e9f0edddb4f652b274a1f961b1d26ca46737c1e25f90a43e57099aa5b869876d10fe258cd0f0741
zkbot added a commit to zcash/zcash that referenced this pull request Mar 5, 2021
Backport bloom filter improvements

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7113
- bitcoin/bitcoin#7818
  - Only the second commit (to resolve conflicts).
- bitcoin/bitcoin#7934
- bitcoin/bitcoin#8655
  - Partial backport to help resolve conflicts.
- bitcoin/bitcoin#9060
- bitcoin/bitcoin#9223
- bitcoin/bitcoin#9644
  - Partial backport to help resolve conflicts.
- bitcoin/bitcoin#9916
- bitcoin/bitcoin#9750
- bitcoin/bitcoin#13176
- bitcoin/bitcoin#13948
- bitcoin/bitcoin#16073
- bitcoin/bitcoin#18670
- bitcoin/bitcoin#18806
  - Reveals upstream's covert fix for CVE-2013-5700.
- bitcoin/bitcoin#19968
zkbot added a commit to zcash/zcash that referenced this pull request Apr 15, 2021
Backport bloom filter improvements

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7113
- bitcoin/bitcoin#7818
  - Only the second commit (to resolve conflicts).
- bitcoin/bitcoin#7934
- bitcoin/bitcoin#8655
  - Partial backport to help resolve conflicts.
- bitcoin/bitcoin#9060
- bitcoin/bitcoin#9223
- bitcoin/bitcoin#9644
  - Partial backport to help resolve conflicts.
- bitcoin/bitcoin#9916
- bitcoin/bitcoin#9750
- bitcoin/bitcoin#13176
- bitcoin/bitcoin#13948
- bitcoin/bitcoin#16073
- bitcoin/bitcoin#18670
- bitcoin/bitcoin#18806
  - Reveals upstream's covert fix for CVE-2013-5700.
- bitcoin/bitcoin#19968
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants