-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[fuzz] Use public methods in addrman fuzz tests #23053
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
[fuzz] Use public methods in addrman fuzz tests #23053
Conversation
@vasild - this addresses your review comment here: #22974 (review) |
00a2c72
to
a41f097
Compare
Rebased |
a41f097
to
19e2d94
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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 19e2d94
The public Good()
will do some extra locking and call Check()
in comparison to Good_()
. The locking should be insignificant wrt performance and the Check()
should be noop due to the used consistency_check_ratio=0
. Also, the public Good()
will do "test before evict" which could cause some slowdown.
I did measure the timings to fill an addrman with hardcoded n=3 (33% tried)
, num_sources=50
and num_addresses=500
on both master
and this PR. The addrman ends up with about 16k addresses.
master
:
13.493194 sec: fill
0.534130 sec: ser
5.664423 sec: deser
1.330460 sec: compare
13.488360 sec: fill
0.529679 sec: ser
5.632100 sec: deser
1.321111 sec: compare
This PR:
14.130295 sec: fill
0.553457 sec: ser
5.809201 sec: deser
1.392843 sec: compare
13.757125 sec: fill
0.556877 sec: ser
5.863635 sec: deser
1.371259 sec: compare
src/test/fuzz/addrman.cpp
Outdated
|
||
if (n > 0 && mapInfo.size() % n == 0) { | ||
Good_(addr, false, GetTime()); |
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.
The new code calls Good()
which calls Good_(/*test_before_evict=*/true)
whereas the old code passed false
. I think this is ok.
Concept ACK |
I'm moving this to draft for now. It conflicts with #22950, which I think should go in first. |
19e2d94
to
0a1eb04
Compare
Rebased on #22950. Leaving as a draft until that PR is merged. |
Don't reach inside the object-under-test to use its random context.
Use a (reference) parameter instead of a data member of CAddrManDeterministic. This will allow us to make Fill() a free function in a later commit. Also remove CAddrManDeterministic.m_fuzzed_data_provider since it's no longer used.
0a1eb04
to
c0555ec
Compare
It doesn't require access to CAddrManDeterministic
Also rename it to FillAddrman and pass an addrman reference as an argument. Change FillAddrman to only use addrman's public interface methods.
Suggested here: bitcoin#22974 (comment)
c0555ec
to
4445211
Compare
Rebased. Marking ready for review. |
|
concept ACK |
@MarcoFalke - I don't see how that can be related to this PR. The failure is in |
utACK 4445211. Agree the failure seems unrelated, looks like some startup race. Thanks very much @vasild for the benchmarks. Indeed it appears the only functional change here is hitting more locks and It appears to me that AddrManDeterministic would no longer be required if |
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 4445211
Correct, the tsan failure is unrelated (known bug with boost). Sorry for missing this. Re-run the task, but it can be ignored either way. |
ACK 4445211 Reviewed the code and did a few hours of fuzzing Not related to this PR, but the structure of |
@@ -307,7 +302,7 @@ FUZZ_TARGET_INIT(addrman_serdeser, initialize_addrman) | |||
|
|||
CDataStream data_stream(SER_NETWORK, PROTOCOL_VERSION); | |||
|
|||
addr_man1.Fill(); | |||
FillAddrman(addr_man1, fuzzed_data_provider); |
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.
Not related to the changes in this PR, but a general observation on the changed fuzz test:
I just noticed that addrman_serdeser
is currently the slowest (>60 minutes, slower almost by a factor of 2 compared to the second slowest one) of fuzz tests when run for the qa asset corpus (CI Link), so it seems to be the current bottleneck for a CI run to finish. I wonder if it this is still in the acceptable range, or whether it would make sense to ease the parameters a bit in a follow-up so that it would fill addrman with less addresses.
4445211 [fuzz] Update comment in FillAddrman() (John Newbery) 640476e [fuzz] Make Fill() a free function in fuzz/addrman.cpp (John Newbery) 90ad8ad [fuzz] Make RandAddr() a free function in fuzz/addrman.cpp (John Newbery) 491975c [fuzz] Pass FuzzedDataProvider& into Fill() in addrman fuzz tests (John Newbery) 56303e3 [fuzz] Create a FastRandomContext in addrman fuzz tests (John Newbery) Pull request description: bitcoin#22974 improved the performance of `CAddrMan::Good()` significantly so that it could be used directly in the fuzz tests, instead of those tests reaching directly into addrman's internal data structures. This PR continues the work of making the fuzz tests only use `CAddrMan`'s public methods and pulls the `Fill()` and `RandAddr()` methods from `CAddrManDeterministic` into free functions, since they no longer need access to `CAddrMan` internals. ACKs for top commit: theuni: utACK 4445211. Agree the failure seems unrelated, looks like some startup race. mzumsande: ACK 4445211 vasild: ACK 4445211 Tree-SHA512: fcf994e1dedd0012b77f632720b6423d51ceda4eb85c9efe572f2a1150117f9e511114a5206738dd94409137287577f3b01a9998f5237de845410d3d96e7cb7f
#22974 improved the performance of
CAddrMan::Good()
significantly so that it could be used directly in the fuzz tests, instead of those tests reaching directly into addrman's internal data structures.This PR continues the work of making the fuzz tests only use
CAddrMan
's public methods and pulls theFill()
andRandAddr()
methods fromCAddrManDeterministic
into free functions, since they no longer need access toCAddrMan
internals.