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: member

    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:

    0Making all in src
    1  CXXLD    bench/bench_bitcoin
    2ld: unknown option: --start-group
    3clang: error: linker command failed with exit code 1 (use -v to see invocation)
    4make[2]: *** [bench/bench_bitcoin] Error 1
    5make[1]: *** [all-recursive] Error 1
    6make: *** [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:

    0CCoinsCaching,14336,0.000036257319152,0.000077610835433,0.000076690073391
    1CCoinsCaching,14336,0.000038111116737,0.000081880833022,0.000077795902533
    2
    3MempoolEviction,3072,0.000186952762306,0.000422742217779,0.000384807276229
    4MempoolEviction,3072,0.000204847194254,0.000402882695198,0.000387265269334
    5
    6VerifyScriptBench,3584,0.000147988088429,0.000305769499391,0.000297257809767
    7VerifyScriptBench,3584,0.000145800411701,0.000301757827401,0.000298310802983
    
  6. in src/Makefile.bench.include: 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:

    0libbitcoin_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':
    1/.../bitcoin/src/wallet/crypter.cpp:85: undefined reference to `AES256CBCEncrypt::AES256CBCEncrypt(unsigned char const*, unsigned char const*, bool)'
    2/.../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:

    0./src/libbitcoin_server.a:libbitcoin_server_a-main.o:000000000000c6c0 T CheckFinalTx(CTransaction const&, int)
    1./src/libbitcoin_wallet.a:libbitcoin_wallet_a-wallet.o:                 U CheckFinalTx(CTransaction const&, int)
    2
    3./src/libbitcoin_server.a:libbitcoin_server_a-init.o:                 U RegisterWalletRPCCommands(CRPCTable&)
    4./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.

     0CCoinsCaching,10240,0.000053781084716,0.000108781736344,0.000108645693399
     1CCoinsCaching,10240,0.000053551048040,0.000109656713903,0.000109049887396
     2CCoinsCaching,10240,0.000053836032748,0.000108591280878,0.000108507415280
     3
     4MempoolEviction,1536,0.000360749661922,0.000733753666282,0.000728020289292
     5MempoolEviction,1536,0.000362284481525,0.000727366656065,0.000728628287713
     6MempoolEviction,1536,0.000364426523447,0.000764504075050,0.000734255183488
     7
     8VerifyScriptBench,1536,0.000325001776218,0.000652246177197,0.000652723324796
     9VerifyScriptBench,1536,0.000325386412442,0.000652894377708,0.000653158252438
    10VerifyScriptBench,1536,0.000325437635183,0.000652890652418,0.000653182932486
    
  12. in src/bench/ccoins_caching.cpp: 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. codablock referenced this in commit 2f8677391a on Jan 12, 2018
  21. MarcoFalke referenced this in commit b5e4b9b510 on Jan 22, 2018
  22. virtload referenced this in commit 3a13bc24bc on Apr 4, 2018
  23. andvgal referenced this in commit 9e8dfe7759 on Jan 6, 2019
  24. PastaPastaPasta referenced this in commit 69cc5d3e4d on Jul 18, 2019
  25. PastaPastaPasta referenced this in commit e264f0e8b2 on Apr 4, 2020
  26. PastaPastaPasta referenced this in commit a09e1c9b7e on Apr 5, 2020
  27. jasonbcox referenced this in commit 01da54bc97 on Oct 31, 2020
  28. ckti referenced this in commit a7e4127fb3 on Mar 28, 2021
  29. MarcoFalke 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: 2024-12-18 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me