-
Notifications
You must be signed in to change notification settings - Fork 37.7k
p2p: Avoid allocating memory for addrKnown where we don't need it #17164
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only relevant for nodes that accept incoming connections? And those nodes are assumed to have a ton of resources. Though, it can't hurt to same some bits, if it can be done conveniently.
Not really. To all the nodes with block-relay-only peers. |
e65af6e
to
90407e6
Compare
Concept ACK. |
@@ -115,9 +115,6 @@ class CBloomFilter | |||
class CRollingBloomFilter | |||
{ | |||
public: | |||
// A random bloom filter calls GetRand() at creation time. | |||
// Don't create global CRollingBloomFilter objects, as they may be | |||
// constructed before the randomizer is properly initialized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to other reviewers: The comment no longer applies after 05fde14
I did some testing with massif, and this saves about 263.3 KiB for 10 peers that connect, but don't have address relay enabled. Note that the tx relay rolling bloom filter takes up 5.1 MB, which sort of dwarfs the gains here. ACK 90407e6 Show signature and timestampSignature:
Timestamp of file with hash |
@MarcoFalke so, the result is actually ... an extra ~4.8 MB RAM usage? |
@GChuf no, Marco's just saying that this update probably saves only 5% of the overall memory we dedicate per peer (or maybe even a bit less due to other stuff). My code does not introduce any extra overhead. |
26802de
to
090b75c
Compare
@naumenkogs thanks for clarifying. Just had to ask because I wasn't sure I understand. |
re-ACK 090b75c Show signature and timestampSignature:
Timestamp of file with hash |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
I think there should be NULL pointer checks or assertions at the locations that now use |
ACK a552e84 |
re-ACK a552e84 Show signature and timestampSignature:
Timestamp of file with hash |
ACK a552e84 Potential Followups
Review NotesLooked through to see that the new asserts won't crash the daemon where previously it might have been a silent failure... The assert in bitcoin/src/net_processing.cpp Lines 3560 to 3564 in a552e84
The assert in bitcoin/src/net_processing.cpp Lines 2101 to 2128 in a552e84
For the assert in 1 of them in bitcoin/src/net_processing.cpp Lines 1326 to 1345 in a552e84
3 of them in bitcoin/src/net_processing.cpp Lines 1985 to 1999 in a552e84
bitcoin/src/net_processing.cpp Lines 2964 to 2982 in a552e84
The last one in bitcoin/src/net_processing.cpp Lines 3552 to 3553 in a552e84
|
I agree. At least right now |
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
ccf5aa7
to
b6d2183
Compare
What? No. All nodes ideally should accept incoming connections, it doesn't imply "a ton of resources"! |
…'t need it b6d2183 Minor refactoring to remove implied m_addr_relay_peer. (User) a552e84 added asserts to check m_addr_known when it's used (User) 090b75c p2p: Avoid allocating memory for addrKnown where we don't need it (User) Pull request description: We should allocate memory for addrKnown filter only for those peers which are expected to participate in address relay. Currently, we do it for all peers (including SPV and block-relay-only), which results in extra RAM where it's not needed. Upd: In future, we would still allow SPVs to ask for addrs, so allocation still will be done by default. However, they will be able to opt-out via [this proposal](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-October/017428.html) and then we could save some more memory. This PR still saves memory for block-relay-only peers immediately after merging. Top commit has no ACKs. Tree-SHA512: e84d93b2615556d466f5ca0e543580fde763911a3bfea3127c493ddfaba8f05c8605cb94ff795d165af542b594400995a2c51338185c298581408687e7812463
… we don't need it b6d2183 Minor refactoring to remove implied m_addr_relay_peer. (User) a552e84 added asserts to check m_addr_known when it's used (User) 090b75c p2p: Avoid allocating memory for addrKnown where we don't need it (User) Pull request description: We should allocate memory for addrKnown filter only for those peers which are expected to participate in address relay. Currently, we do it for all peers (including SPV and block-relay-only), which results in extra RAM where it's not needed. Upd: In future, we would still allow SPVs to ask for addrs, so allocation still will be done by default. However, they will be able to opt-out via [this proposal](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-October/017428.html) and then we could save some more memory. This PR still saves memory for block-relay-only peers immediately after merging. Top commit has no ACKs. Tree-SHA512: e84d93b2615556d466f5ca0e543580fde763911a3bfea3127c493ddfaba8f05c8605cb94ff795d165af542b594400995a2c51338185c298581408687e7812463
@naumenkogs Please set a different name than
|
Summary: > We should allocate memory for addrKnown filter only for those peers which are expected to participate in address relay. > > Currently, we do it for all peers (including SPV and block-relay-only), which results in extra RAM where it's not needed. > > Upd: > In future, we would still allow SPVs to ask for addrs, so allocation still will be done by default. > However, they will be able to opt-out via this proposal and then we could save some more memory. > This PR still saves memory for block-relay-only peers immediately after merging. We use `std::make_unique` instead of `MakeUnique` (see D2463) This is a backport of Core [[bitcoin/bitcoin#17164 | PR17164]] [1/3] bitcoin/bitcoin@090b75c Test Plan: `ninja all check-all` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D8238
Summary: This is a backport of Core [[bitcoin/bitcoin#17164 | PR17164]] [2/3] bitcoin/bitcoin@a552e84 Depends on D8238 Test Plan: `ninja all check-all` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D8239
Summary: Co-authored-by: MarcoFalke <falke.marco@gmail.com> This is a backport of Core [[bitcoin/bitcoin#17164 | PR17164]] [3/3] bitcoin/bitcoin@b6d2183 Depends on D8239 Test Plan: `ninja all check-all` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8240
… we don't need it b6d2183 Minor refactoring to remove implied m_addr_relay_peer. (User) a552e84 added asserts to check m_addr_known when it's used (User) 090b75c p2p: Avoid allocating memory for addrKnown where we don't need it (User) Pull request description: We should allocate memory for addrKnown filter only for those peers which are expected to participate in address relay. Currently, we do it for all peers (including SPV and block-relay-only), which results in extra RAM where it's not needed. Upd: In future, we would still allow SPVs to ask for addrs, so allocation still will be done by default. However, they will be able to opt-out via [this proposal](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-October/017428.html) and then we could save some more memory. This PR still saves memory for block-relay-only peers immediately after merging. Top commit has no ACKs. Tree-SHA512: e84d93b2615556d466f5ca0e543580fde763911a3bfea3127c493ddfaba8f05c8605cb94ff795d165af542b594400995a2c51338185c298581408687e7812463
We should allocate memory for addrKnown filter only for those peers which are expected to participate in address relay.
Currently, we do it for all peers (including SPV and block-relay-only), which results in extra RAM where it's not needed.
Upd:
In future, we would still allow SPVs to ask for addrs, so allocation still will be done by default.
However, they will be able to opt-out via this proposal and then we could save some more memory.
This PR still saves memory for block-relay-only peers immediately after merging.