Skip to content

Conversation

fanquake
Copy link
Member

This is #18985 rebased, with the most recent comments addressed.

We can avoid many unnecessary std::vector allocations by changing
CBloomFilter to take Spans instead of std::vector's for the insert
and contains operations.

CBloomFilter currently converts types such as CDataStream and uint256
to std::vector on insert and contains. This is unnecessary because
CDataStreams and uint256 are already std::vectors internally. We just
need a way to point to the right data within those types. Span gives
us this ability.

@maflcko maflcko changed the title bloom: use Span instead of std::vector for insert and contains (#18985) bloom: use Span instead of std::vector for insert and contains Sep 28, 2021
@jonatack
Copy link
Member

Concept ACK

@laanwj
Copy link
Member

laanwj commented Sep 28, 2021

Thanks for picking this up. Concept ACK.

jb55 and others added 3 commits September 29, 2021 09:40
We can avoid many unnecessary std::vector allocations by changing
CBloomFilter to take Spans instead of std::vector's for the `insert`
and `contains` operations.

CBloomFilter currently converts types such as CDataStream and uint256
to std::vector on `insert` and `contains`. This is unnecessary because
CDataStreams and uint256 are already std::vectors internally. We just
need a way to point to the right data within those types. Span gives
us this ability.

Signed-off-by: William Casarin <jb55@jb55.com>
@fanquake
Copy link
Member Author

Fixed up the change that I should have already made, and added minor bloom cleanup commits.

@sipa
Copy link
Member

sipa commented Sep 29, 2021

Code review ACK a11da75

1 similar comment
@laanwj
Copy link
Member

laanwj commented Sep 29, 2021

Code review ACK a11da75

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Sep 29, 2021
…or `insert` and `contains`

a11da75 bloom: cleanup includes (fanquake)
f1ed1d3 bloom: use constexpr where appropriate (fanquake)
2ba4ddf bloom: use Span instead of std::vector for `insert` and `contains` (William Casarin)

Pull request description:

  This is #18985 rebased, with the most recent comments addressed.

  > We can avoid many unnecessary std::vector allocations by changing
  CBloomFilter to take Spans instead of std::vector's for the `insert`
  and `contains` operations.

  > CBloomFilter currently converts types such as CDataStream and uint256
  to std::vector on `insert` and `contains`. This is unnecessary because
  CDataStreams and uint256 are already std::vectors internally. We just
  need a way to point to the right data within those types. Span gives
  us this ability.

ACKs for top commit:
  sipa:
    Code review ACK a11da75
  laanwj:
    Code review ACK a11da75

Tree-SHA512: ee9ba02c9588daa1ff51782d1953fd060839dd15aa85861b2633b6ff2398320188ddd00f01d0c99442224485364ede9f8322366de4239fc7831ebfa06bd34659
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 29, 2021
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@maflcko maflcko closed this Sep 29, 2021
@fanquake fanquake deleted the 18985_rebased branch September 29, 2021 23:34
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants