Skip to content

Conversation

pstratem
Copy link
Contributor

@pstratem pstratem commented May 23, 2016

Lazy calculate vchKeyedNetGroup in CNode::GetKeyedNetGroup.

This is a (very small) performance improvement.

Fix mentioned by gmaxwell in #8086

@pstratem pstratem changed the title Avoid recalculating vchKeyedNetGroup in eviction logic. [WIP]Avoid recalculating vchKeyedNetGroup in eviction logic. May 23, 2016
@gmaxwell
Copy link
Contributor

bleh. There really is no reason to do this lazily. It should eagerly generate it at connection time, saving a hashing operation that it's going to perform anyways is not a good trade-off for having an extra heap allocation. Doubly so when the hash is changed to siphash.

Lazy calculate vchKeyedNetGroup in CNode::GetKeyedNetGroup.
@pstratem pstratem force-pushed the 2016-05-22-efficient-keyed-eviction branch from 66ed14d to ee57c20 Compare May 23, 2016 09:04
@pstratem pstratem changed the title [WIP]Avoid recalculating vchKeyedNetGroup in eviction logic. Avoid recalculating vchKeyedNetGroup in eviction logic. May 23, 2016
@pstratem
Copy link
Contributor Author

@gmaxwell i mean ok..

@@ -363,6 +365,8 @@ class CNode
CBloomFilter* pfilter;
int nRefCount;
NodeId id;

std::vector<unsigned char> vchKeyedNetGroup;
Copy link
Member

Choose a reason for hiding this comment

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

Use a uint256, or even a uint64_t.

Copy link
Contributor

Choose a reason for hiding this comment

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

uint64_t please. The probability that two distinct net-groups share a 64-bit hash is negligible, and if it ever happens its harmless (and would have no effect at all unless it's a collision with one of the four lowest ones that are in use).

@sipa
Copy link
Member

sipa commented May 24, 2016

Concept ACK. I think SHA256 is still overkill, but this is a clear improvement.

@sipa
Copy link
Member

sipa commented May 26, 2016

Included into #8086.

@gmaxwell
Copy link
Contributor

This should be closed, was merged via 8086->8173.

@pstratem pstratem closed this Jun 11, 2016
@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.

4 participants