Add microbenchmarks to profile more code paths. #8873

pull ryanofsky wants to merge 1 commits into bitcoin:master from ryanofsky:issue-7883-benchmarks changing 5 files +372 −1
  1. ryanofsky commented at 7:22 PM on October 3, 2016: 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

  2. ryanofsky force-pushed on Oct 3, 2016
  3. fanquake added the label Tests on Oct 3, 2016
  4. fanquake commented at 3:20 AM on October 4, 2016: member

    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
    
  5. fanquake commented at 3:26 AM on October 4, 2016: member

    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
    
  6. in src/Makefile.bench.include:None in 456848695f outdated
      41 |  bench_bench_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
      42 |  endif
      43 |  
      44 |  bench_bench_bitcoin_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
      45 | -bench_bench_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
      46 | +bench_bench_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -Wl,--start-group
    


    paveljanik commented at 5:20 AM on October 4, 2016:

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


    laanwj commented at 11:57 AM on October 4, 2016:

    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.


    ryanofsky commented at 12:43 PM on October 4, 2016:

    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.


    ryanofsky commented at 8:22 PM on October 4, 2016:

    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.

  7. laanwj commented at 9:12 AM on October 4, 2016: member

    Awesome! Thanks for doing this. Concept ACK.

  8. sipa commented at 12:46 PM on October 4, 2016: member

    I can't easily look at the source code now. What exactly causes the circular dependency?

  9. laanwj commented at 2:59 PM on October 4, 2016: member

    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.

  10. ryanofsky force-pushed on Oct 4, 2016
  11. fanquake commented at 10:20 AM on October 9, 2016: member

    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
    
  12. in src/bench/ccoins_caching.cpp:None in c9086edc5c outdated
      54 | +// characteristics than e.g. reindex timings. But that's not a requirement of
      55 | +// every benchmark."
      56 | +// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
      57 | +static void CCoinsCaching(benchmark::State& state)
      58 | +{
      59 | +  CBasicKeyStore keystore;
    


    paveljanik commented at 10:28 AM on October 9, 2016:

    Please clang-format the new code.

  13. paveljanik commented at 10:30 AM on October 9, 2016: contributor

    Concept ACK

  14. Add microbenchmarks to profile more code paths.
    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
    18dacf9bd2
  15. laanwj force-pushed on Oct 18, 2016
  16. laanwj commented at 8:02 PM on October 18, 2016: member

    Applied clang-format to all the new files.

  17. laanwj merged this on Oct 18, 2016
  18. laanwj closed this on Oct 18, 2016

  19. laanwj referenced this in commit 74dc388ab5 on Oct 18, 2016
  20. laanwj cross-referenced this on Oct 18, 2016 from issue Add benchmarks to `bench_bitcoin` by laanwj
  21. laanwj cross-referenced this on Oct 19, 2016 from issue Locked memory manager by laanwj
  22. ryanofsky cross-referenced this on May 26, 2017 from issue [PoC] Add wallet inspection and modification tool "bitcoin-wallet-tool" by jonasschnelli
  23. codablock referenced this in commit 2f8677391a on Jan 12, 2018
  24. jeffrade cross-referenced this on Jan 15, 2018 from issue [Docs] Updating benchmarkmarking.md with an updated sample output by jeffrade
  25. MarcoFalke referenced this in commit b5e4b9b510 on Jan 22, 2018
  26. virtload referenced this in commit 3a13bc24bc on Apr 4, 2018
  27. dagurval cross-referenced this on Apr 30, 2018 from issue Benchmark cherries by dagurval
  28. andvgal referenced this in commit 9e8dfe7759 on Jan 6, 2019
  29. PastaPastaPasta cross-referenced this on Jul 18, 2019 from issue Backports 0.15 pr21 by PastaPastaPasta
  30. PastaPastaPasta referenced this in commit 69cc5d3e4d on Jul 18, 2019
  31. PastaPastaPasta referenced this in commit e264f0e8b2 on Apr 4, 2020
  32. PastaPastaPasta referenced this in commit a09e1c9b7e on Apr 5, 2020
  33. sickpig cross-referenced this on Apr 28, 2020 from issue Update benchmark suite by sickpig
  34. jasonbcox referenced this in commit 01da54bc97 on Oct 31, 2020
  35. ckti referenced this in commit a7e4127fb3 on Mar 28, 2021
  36. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:55 UTC