More efficient bitsliced rolling Bloom filter

This patch changes the implementation from one that stores 16 2-bit integers
in one uint32_t's, to one that stores the first bit of 64 2-bit integers in
one uint64_t and the second bit in another. This allows for 450x faster
refreshing and 2.2x faster average speed.
This commit is contained in:
Pieter Wuille
2016-04-24 18:37:29 +02:00
parent aa62b68745
commit 1953c40aa9
3 changed files with 32 additions and 26 deletions

View File

@@ -135,20 +135,9 @@ private:
int nEntriesPerGeneration;
int nEntriesThisGeneration;
int nGeneration;
std::vector<uint32_t> data;
std::vector<uint64_t> data;
unsigned int nTweak;
int nHashFuncs;
unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
inline int get(uint32_t position) const {
return (data[(position >> 4) % data.size()] >> (2 * (position & 0xF))) & 0x3;
}
inline void put(uint32_t position, uint32_t val) {
uint32_t& cell = data[(position >> 4) % data.size()];
cell = (cell & ~(((uint32_t)3) << (2 * (position & 0xF)))) | (val << (2 * (position & 0xF)));
}
};
#endif // BITCOIN_BLOOM_H