Skip to content

Conversation

ryanofsky
Copy link
Contributor

The new benchmarks exercise script validation, CCoinsDBView caching,
mempool eviction, and wallet coin selection code.

All of the benchmarks added here are extremely simple and don't
necessarily mirror common real world conditions or interesting
performance edge cases. Details about how specific benchmarks can be
improved are noted in comments.

Github-Issue: #7883

@ryanofsky ryanofsky force-pushed the issue-7883-benchmarks branch from be1bd69 to 4568486 Compare October 3, 2016 20:04
@fanquake fanquake added the Tests label Oct 3, 2016
@fanquake
Copy link
Member

fanquake commented Oct 4, 2016

Trying to compile this on OS X:

Making all in src
  CXXLD    bench/bench_bitcoin
ld: unknown option: --start-group
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bench/bench_bitcoin] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

@fanquake
Copy link
Member

fanquake commented Oct 4, 2016

After removing --start-group I see these numbers for the new benchmarks:

CCoinsCaching,14336,0.000036257319152,0.000077610835433,0.000076690073391
CCoinsCaching,14336,0.000038111116737,0.000081880833022,0.000077795902533

MempoolEviction,3072,0.000186952762306,0.000422742217779,0.000384807276229
MempoolEviction,3072,0.000204847194254,0.000402882695198,0.000387265269334

VerifyScriptBench,3584,0.000147988088429,0.000305769499391,0.000297257809767
VerifyScriptBench,3584,0.000145800411701,0.000301757827401,0.000298310802983

bench_bench_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
endif

bench_bench_bitcoin_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
bench_bench_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
bench_bench_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -Wl,--start-group
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use some circular dependencies? Or why adding linker --start-group?

Copy link
Member

@laanwj laanwj Oct 4, 2016

Choose a reason for hiding this comment

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

He probably added it because of a weird crypter link issue:

libbitcoin_wallet.a(libbitcoin_wallet_a-crypter.o): In function `CCrypter::Encrypt(std::vector<unsigned char, secure_allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> >&) const':
/.../bitcoin/src/wallet/crypter.cpp:85: undefined reference to `AES256CBCEncrypt::AES256CBCEncrypt(unsigned char const*, unsigned char const*, bool)'
/.../bitcoin/src/wallet/crypter.cpp:86: undefined reference to `AES256CBCEncrypt::Encrypt(unsigned char const*, int, unsigned char*) const'

Rather we should structure the libraries sanely than resort to linker groups, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the issue I saw. I did try briefly to rearrange the link order and add dup library listings to work around the apparently circular dependencies, but for some reason nothing I tried worked so I resorted to --start-group. I can try again to figure find a working link order that doesn't require the flag, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least one circular dependency exists between the wallet and server libs:

./src/libbitcoin_server.a:libbitcoin_server_a-main.o:000000000000c6c0 T CheckFinalTx(CTransaction const&, int)
./src/libbitcoin_wallet.a:libbitcoin_wallet_a-wallet.o:                 U CheckFinalTx(CTransaction const&, int)

./src/libbitcoin_server.a:libbitcoin_server_a-init.o:                 U RegisterWalletRPCCommands(CRPCTable&)
./src/libbitcoin_wallet.a:libbitcoin_wallet_a-rpcwallet.o:0000000000000370 T RegisterWalletRPCCommands(CRPCTable&)

But this problem only manifests if you remove ccoins_caching.cpp, mempool_eviction.cpp, verify_script.cpp from the sources list (which is what I had done during development).

Otherwise, adding the crypo lib after the wallet lib as Wladimir suggested seems to be sufficient to build, so I updated the PR with this change and removed start-group.

@laanwj
Copy link
Member

laanwj commented Oct 4, 2016

Awesome! Thanks for doing this.
Concept ACK.

@sipa
Copy link
Member

sipa commented Oct 4, 2016 via email

@laanwj
Copy link
Member

laanwj commented Oct 4, 2016

I think the problem is not a circular dependency here, but that LIBBITCOIN_WALLET is added after LIBBITCOIN_CRYPTO, whereas wallet needs crypto so it should go before that.

@ryanofsky ryanofsky force-pushed the issue-7883-benchmarks branch from 4568486 to c9086ed Compare October 4, 2016 20:18
@fanquake
Copy link
Member

fanquake commented Oct 9, 2016

Compiling has been fixed on OS X.

CCoinsCaching,10240,0.000053781084716,0.000108781736344,0.000108645693399
CCoinsCaching,10240,0.000053551048040,0.000109656713903,0.000109049887396
CCoinsCaching,10240,0.000053836032748,0.000108591280878,0.000108507415280

MempoolEviction,1536,0.000360749661922,0.000733753666282,0.000728020289292
MempoolEviction,1536,0.000362284481525,0.000727366656065,0.000728628287713
MempoolEviction,1536,0.000364426523447,0.000764504075050,0.000734255183488

VerifyScriptBench,1536,0.000325001776218,0.000652246177197,0.000652723324796
VerifyScriptBench,1536,0.000325386412442,0.000652894377708,0.000653158252438
VerifyScriptBench,1536,0.000325437635183,0.000652890652418,0.000653182932486

// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
static void CCoinsCaching(benchmark::State& state)
{
CBasicKeyStore keystore;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please clang-format the new code.

@paveljanik
Copy link
Contributor

Concept ACK

The new benchmarks exercise script validation, CCoinsDBView caching,
mempool eviction, and wallet coin selection code.

All of the benchmarks added here are extremely simple and don't
necessarily mirror common real world conditions or interesting
performance edge cases. Details about how specific benchmarks can be
improved are noted in comments.

Github-Issue: bitcoin#7883
@laanwj laanwj force-pushed the issue-7883-benchmarks branch from c9086ed to 18dacf9 Compare October 18, 2016 20:00
@laanwj
Copy link
Member

laanwj commented Oct 18, 2016

Applied clang-format to all the new files.

@laanwj laanwj merged commit 18dacf9 into bitcoin:master Oct 18, 2016
laanwj added a commit that referenced this pull request Oct 18, 2016
18dacf9 Add microbenchmarks to profile more code paths. (Russell Yanofsky)
This was referenced Oct 18, 2016
codablock pushed a commit to codablock/dash that referenced this pull request Jan 12, 2018
18dacf9 Add microbenchmarks to profile more code paths. (Russell Yanofsky)
maflcko pushed a commit that referenced this pull request Jan 22, 2018
…ple output

b21244e Updating benchmarkmarking.md with an updated sample output and help options (Jeff Rade)

Pull request description:

  This PR is just a documentation update for someone (or myself) that looks into finishing up #7883 in the future.

  Looked through #7883 and appears [ryanofsky's PR](#8873) setup the benchmarks, but there are `FIXME` comments to pull in data from `test/` to get a larger data set (assuming reason why 7883 is still open).

Tree-SHA512: d758efc659c75f2b3ceb376f5a466c4234354077e4671ac3eb901c082c4e519ce5ff592cea4742711050b4ce56a1b65ef69433dd74e7db3eb11a8567d517d9e2
virtload pushed a commit to bitcoin-atom/bitcoin-atom that referenced this pull request Apr 4, 2018
…ple output

b21244e0be Updating benchmarkmarking.md with an updated sample output and help options (Jeff Rade)

Pull request description:

  This PR is just a documentation update for someone (or myself) that looks into finishing up #7883 in the future.

  Looked through #7883 and appears [ryanofsky's PR](bitcoin/bitcoin#8873) setup the benchmarks, but there are `FIXME` comments to pull in data from `test/` to get a larger data set (assuming reason why 7883 is still open).

Tree-SHA512: d758efc659c75f2b3ceb376f5a466c4234354077e4671ac3eb901c082c4e519ce5ff592cea4742711050b4ce56a1b65ef69433dd74e7db3eb11a8567d517d9e2
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
18dacf9 Add microbenchmarks to profile more code paths. (Russell Yanofsky)
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 18, 2019
18dacf9 Add microbenchmarks to profile more code paths. (Russell Yanofsky)
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 4, 2020
…ted sample output

b21244e Updating benchmarkmarking.md with an updated sample output and help options (Jeff Rade)

Pull request description:

  This PR is just a documentation update for someone (or myself) that looks into finishing up bitcoin#7883 in the future.

  Looked through bitcoin#7883 and appears [ryanofsky's PR](bitcoin#8873) setup the benchmarks, but there are `FIXME` comments to pull in data from `test/` to get a larger data set (assuming reason why 7883 is still open).

Tree-SHA512: d758efc659c75f2b3ceb376f5a466c4234354077e4671ac3eb901c082c4e519ce5ff592cea4742711050b4ce56a1b65ef69433dd74e7db3eb11a8567d517d9e2
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Apr 5, 2020
…ted sample output

b21244e Updating benchmarkmarking.md with an updated sample output and help options (Jeff Rade)

Pull request description:

  This PR is just a documentation update for someone (or myself) that looks into finishing up bitcoin#7883 in the future.

  Looked through bitcoin#7883 and appears [ryanofsky's PR](bitcoin#8873) setup the benchmarks, but there are `FIXME` comments to pull in data from `test/` to get a larger data set (assuming reason why 7883 is still open).

Tree-SHA512: d758efc659c75f2b3ceb376f5a466c4234354077e4671ac3eb901c082c4e519ce5ff592cea4742711050b4ce56a1b65ef69433dd74e7db3eb11a8567d517d9e2
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 31, 2020
…sample output

Summary:
b21244e Updating benchmarkmarking.md with an updated sample output and help options (Jeff Rade)

Pull request description:

  This PR is just a documentation update for someone (or myself) that looks into finishing up #7883 in the future.

  Looked through #7883 and appears [ryanofsky's PR](bitcoin/bitcoin#8873) setup the benchmarks, but there are `FIXME` comments to pull in data from `test/` to get a larger data set (assuming reason why 7883 is still open).

---

Backport of Core [[bitcoin/bitcoin#12187 | PR12187]]

Test Plan: read it

Reviewers: #bitcoin_abc, PiRK

Reviewed By: PiRK

Differential Revision: https://reviews.bitcoinabc.org/D8205
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
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.

5 participants