Skip to content

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Oct 4, 2022

Moving the heavy (Boost) mempool code out of fuzz/util.h. Means that (for ex) a crypto_common fuzz unit doesn't need to care about seeing endless Boost headers. This results in a ~10% speedup (for me) when compiling the fuzz tests. Your results may vary.

@fanquake fanquake added the Tests label Oct 4, 2022
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -17,5 +17,6 @@ libtest_fuzz_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
libtest_fuzz_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libtest_fuzz_a_SOURCES = \
test/fuzz/fuzz.cpp \
test/fuzz/mempool_utils.cpp \
Copy link
Member

@maflcko maflcko Oct 4, 2022

Choose a reason for hiding this comment

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

I wonder if we can nest more folders. Maybe src/test/fuzz/util/mempool.cpp to differentiate utils from tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some nesting.

// policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'
//
// Reproduce using CFeeRate(348732081484775, 10).GetFeePerK()
const CAmount fee = std::min<CAmount>(ConsumeMoney(fuzzed_data_provider), std::numeric_limits<CAmount>::max() / static_cast<CAmount>(100000));
Copy link
Member

Choose a reason for hiding this comment

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

unrelated:

Suggested change
const CAmount fee = std::min<CAmount>(ConsumeMoney(fuzzed_data_provider), std::numeric_limits<CAmount>::max() / static_cast<CAmount>(100000));
const CAmount fee{ConsumeMoney(fuzzed_data_provider, /*max=*/std::numeric_limits<CAmount>::max() / CAmount{100'000})};

It should be possible to just pass the max. (Can do in a separate commit, if you want)

Copy link
Member Author

Choose a reason for hiding this comment

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

Added another commit for this.

@fanquake fanquake force-pushed the fuzz_add_mempool_utils_h branch from 53366df to 6703800 Compare October 4, 2022 16:53
Moving the mempool code (Boost) out of util.h, results in a ~10% speedup
(for me) when compiling the fuzz tests.
@fanquake fanquake force-pushed the fuzz_add_mempool_utils_h branch from 6703800 to 8a6b6df Compare October 4, 2022 20:12
@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 4, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17786 (refactor: Nuke policy/fees->mempool circular dependencies by hebasto)

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.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

review ACK 8a6b6df 🍮

Show signature

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

review ACK 8a6b6dfcd8d26b62c3a13beba72440635fcc5e19 🍮
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgJuAv+MyuzOk4R07Q6iwAbpfd78pnXvv/5J2YAj5mpWWifj9ZAJL72sYk/K1I8
5K4ukFrthMelgGVV7Hkz7KcSEQu/rRpjHRRILFuYsnxGwhVYi4RCH0w+s4jrotBc
onA2qBJaft8ULZtZg1wDS+Lkl8VLQ9bwkYmUkZgJf9vaUQwMYFlO70QkqidubjcR
+lslpo9UkFD4uH8q9YLClPvGWWxpjB/6x8/CKDEVt7Yfu1cQypX6kmgrG4T2Kmgi
6FrJDAM0ECts/di/V1TLhRsGdQrSMhDxx0UawygzgaLTBc38ezG7sE17ram+ems+
cpE+mDhWu56QWG6hCrpIyRH2pkDcjymAwIjfEug9EromErGocKKpY1nK5BVaqNbl
KKhrNnZ4x+DBhvgBxCiGzfGFP2oGgDAKPY4Ke22LjdpdC1szqBcLMdWVyPCKrJBc
VzypwHcwe8rGkqZaVmGzIGB7PSEfJCEhvscA31Z7vFBsuHqTiz/OROgV+J4+/qPr
fQ8WY0tK
=GxLp
-----END PGP SIGNATURE-----


#include <primitives/transaction.h>
#include <test/fuzz/FuzzedDataProvider.h>
Copy link
Member

Choose a reason for hiding this comment

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

those two includes could be fwd-decls, but it doesn't matter because everywhere where this header is included, the full includes already exist

@maflcko maflcko merged commit d3cdd37 into bitcoin:master Oct 5, 2022
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

post-merge concept ACK

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 5, 2022
@fanquake fanquake deleted the fuzz_add_mempool_utils_h branch October 10, 2022 12:14
@bitcoin bitcoin locked and limited conversation to collaborators Oct 10, 2023
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