addrman: improve performance of GetAddr when specifying network#29578
addrman: improve performance of GetAddr when specifying network#29578brunoerg wants to merge 3 commits intobitcoin:masterfrom
GetAddr when specifying network#29578Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
|
I was able to reproduce the diff, but please rebase the changes so that the benchmark is before the change so that we can easily check before/after. Running it locally:
Before: after: |
98cc6ac to
1319958
Compare
Nice idea, force-pushed changing the order of the commits. |
vasild
left a comment
There was a problem hiding this comment.
ACK 57db2e7e5ecaa6d23efd9e30ceac48fb6489d213
Changing the argument from std::optional<Network> to const std::optional<Network>& seems unnecessary because it is very cheap to copy that, it is 8 bytes. I would drop commit 1319958b45455a18800cb83d483448a3021b2aba addrman: net: use const ref for network in GetAddresses/GetAddr
57db2e7 to
e1e1078
Compare
vasild
left a comment
There was a problem hiding this comment.
ACK e1e107893594be1f1c79e4432fa345a0bbc1d8a4
> make && ./src/bench/bench_bitcoin --filter=AddrManGetAddr --min-time=1000 Before: ``` | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 76,852.79 | 13,011.89 | 0.4% | 1.07 | `AddrManGetAddr` | 76,598.21 | 13,055.14 | 0.2% | 1.07 | `AddrManGetAddr` | 76,296.32 | 13,106.79 | 0.1% | 1.07 | `AddrManGetAddr` ``` After: ``` | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 65,966.97 | 15,159.10 | 0.3% | 1.07 | `AddrManGetAddr` | 66,075.40 | 15,134.23 | 0.2% | 1.06 | `AddrManGetAddr` | 66,306.34 | 15,081.51 | 0.3% | 1.06 | `AddrManGetAddr` ```
e1e1078 to
32a44d7
Compare
|
Rebased to fix CI. |
I know I'm gonna make myself unpopular by saying this but these PRs require hours and hours from reviewers and authors that I'd rather see work on more impactful things. Given that this project has extremely limited resources, the cost to benefit ratio just doesn't make any sense to me here. Why does the performance of I'm open to being convinced but I'm very skeptical that there are no other more impactful performance improvements we could be spending our time on instead. |
I super respect your opinion and agree with your point about focusing on more impactful things. However, I do not think this PR requires hours and hours from reviewers/authors, the impactful change here is around 6 lines of code and it does not conflict with any other more important PR (better, any other PR). Also, |
This is how the new generation is recruited, newcomers cannot (and should not) start with "more impactful things". |
One of these PRs might be harmless, but PRs like this one keep happening and the cumulative review time piles up.
Yes
@paplorinc I see your point but I don't think that "more impactful" implies non-trivial. Easy and smaller yet still impactful changes are certainly possible but I think this project could do better in providing guidance to newcomers in that regard. |
|
@dergoegge I'll consider your point for further PRs (including reviews). Thanks. |
|
Closing for now. |
|
The development of Bitcoin Core is decentralized because every developer decides for themselves what is important and what not. Asserting one's opinion on others is more in line with centralized corporate management. |
Performance improvements should be measured in numbers by machines, which does not seem like an opinion. According to #29578 (comment) , the code can only be reached by RPC and P2P. For those places no end-to-end performance difference has been provided. I'd say if there is a measurable (reproducible) performance improvement for a users' use case, or another use case that hasn't been mentioned yet, the change can be considered based on that. Otherwise, the code change seems like a style change, which largely is opinion-based. |
GetAddrreturns all or many randomly selected addresses, it usesvRandom(randomly-ordered vector of allnIds) to get the addresses. However, if a network is specified, we could check the number of entries invRandomfrom that network usingm_network_countssince it contains the number of entries in addrman per network. This way we could avoid unnecessary searchs invRandom. So...This PR improve the performance of addrman's
GetAddrby checkingm_network_countswhen specifying a network.AddrManGetAddrByNetworkbench:master:
this PR: