-
Notifications
You must be signed in to change notification settings - Fork 37.7k
addrman: improve performance of GetAddr
when specifying network
#29578
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
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. |
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.
57db2e7
to
e1e1078
Compare
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.
ACK e1e1078
> 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. |
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.
ACK 32a44d7
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. |
GetAddr
returns 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 invRandom
from that network usingm_network_counts
since 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
GetAddr
by checkingm_network_counts
when specifying a network.AddrManGetAddrByNetwork
bench:master:
this PR: