Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Jan 12, 2017

This uses the fast reduction from http://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/ instead of a modulus operator to quickly compute (nearly) uniformly distributed values within range.

@JeremyRubin
Copy link
Contributor

Concept ACK. Great find!

@fanquake
Copy link
Member

Travis failure is in keypool.py, so seemingly unrelated.

(uint32_t)((hash_function.template operator()<4>(e) * (uint64_t)size) >> 32),
(uint32_t)((hash_function.template operator()<5>(e) * (uint64_t)size) >> 32),
(uint32_t)((hash_function.template operator()<6>(e) * (uint64_t)size) >> 32),
(uint32_t)((hash_function.template operator()<7>(e) * (uint64_t)size) >> 32)}};
Copy link
Contributor

@dcousens dcousens Jan 13, 2017

Choose a reason for hiding this comment

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

maybe a small inline function/macro would be easier to read than this?

@gmaxwell
Copy link
Contributor

utACK.

@gmaxwell
Copy link
Contributor

someone should make sure to benchmark this change.

@JeremyRubin
Copy link
Contributor

Just dropping a note here to assist other reviewers that you should also verify that InitSignatureCache makes no power-of-2 assumptions. I wrote it not to make such assumptions, and it doesn't, but it is aware that the cache may end up not using it's whole memory budget.

@sipa
Copy link
Member Author

sipa commented Mar 29, 2017

Anything needed here?

@JeremyRubin
Copy link
Contributor

Maybe a benchmark?

I'd previously done a simulation on division v.s. masking and didn't see a difference, so I'm sure that this is fine...

@sdaftuar
Copy link
Member

utACK

@laanwj laanwj merged commit 7482781 into bitcoin:master Apr 3, 2017
laanwj added a commit that referenced this pull request Apr 3, 2017
7482781 Allow non-power-of-2 signature cache sizes (Pieter Wuille)

Tree-SHA512: 5731c22b46c5ae81cf6d52000c28e39b243a47d96d91079942a5b5a10db214449217f71aa2195e18f8a3917cb206b04c75dc13e4522eb700a1dbf1819013ba22
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 20, 2019
7482781 Allow non-power-of-2 signature cache sizes (Pieter Wuille)

Tree-SHA512: 5731c22b46c5ae81cf6d52000c28e39b243a47d96d91079942a5b5a10db214449217f71aa2195e18f8a3917cb206b04c75dc13e4522eb700a1dbf1819013ba22
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants