Performance Regression Fix: Pre-Allocate txChanged vector #8681

pull JeremyRubin wants to merge 1 commits into bitcoin:master from JeremyRubin:fix-perf-regressed-txChanged changing 1 files +7 −4
  1. JeremyRubin commented at 10:54 PM on September 7, 2016: contributor

    There's a non-trivial performance regression in the Connect postprocess time. Part of the problem is that the vector is not preallocated & the elements are copy-constructed. This commit should fix those two concerns, and address the performance regression significantly.

    s/o to @morcos for noticing that this was a slowdown.

  2. in src/main.cpp:None in 8625f70500 outdated
    3018 | @@ -3019,14 +3019,17 @@ static void NotifyHeaderTip() {
    3019 |  bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, const CBlock *pblock) {
    3020 |      CBlockIndex *pindexMostWork = NULL;
    3021 |      CBlockIndex *pindexNewTip = NULL;
    3022 | +    std::vector<std::tuple<CTransaction,CBlockIndex*,int> > txChanged;
    


    sipa commented at 10:56 PM on September 7, 2016:

    In c++11 the ugly '> >' (with a space in between) is no longer needed. Might as well fix it when you're changing it.


    TheBlueMatt commented at 11:00 PM on September 7, 2016:

    I mean at this point thats just like...coding style, right?

  3. sipa commented at 11:02 PM on September 7, 2016: member

    Ok, maybe I incorrectly assume that I'm not alone with finding this ugly and distracting :)

  4. JeremyRubin commented at 11:08 PM on September 7, 2016: contributor

    I think we should just wait for the eventual clang-formattening; unless you really need that byte back.

  5. sipa commented at 11:14 PM on September 7, 2016: member

    I don't think a mass clang-format will happen. It's just too invasive everywhere at the same time. It couls be done piecewise like the -Woverwrite changes, but that's a simple thing and it takes a long time already too.

    My view is that whenever code is rewritten, we should try to bring it up to par with coding style. But if people disagree that '> >' is something to avoid, I will shut up about it :)

  6. JeremyRubin commented at 11:48 PM on September 7, 2016: contributor

    Benchmark

    Forgot to include with initial PR, it's something like 12% faster in connect postprocess.

  7. Performance Regression Fix: Pre-Allocate txChanged vector ec81881b86
  8. JeremyRubin force-pushed on Sep 8, 2016
  9. JeremyRubin force-pushed on Sep 8, 2016
  10. JeremyRubin commented at 12:14 AM on September 8, 2016: contributor

    push -f'ed a version where txData type template extra whitespace is removed as per @sipa's request.

    Travis might fail because I force pushed twice and there's a known race condition on that.

  11. dcousens commented at 1:16 AM on September 8, 2016: contributor

    utACK ec81881

  12. jonasschnelli added the label Refactoring on Sep 8, 2016
  13. laanwj added the label Resource usage on Sep 8, 2016
  14. sipa commented at 11:27 AM on September 9, 2016: member

    utACK ec81881b86b9680fcdcc42fd3ba31f04b8d09714

  15. sipa merged this on Sep 9, 2016
  16. sipa closed this on Sep 9, 2016

  17. sipa referenced this in commit 6898213409 on Sep 9, 2016
  18. codablock referenced this in commit 5a8d55ace7 on Sep 19, 2017
  19. codablock referenced this in commit 9f42dec2a9 on Jan 9, 2018
  20. codablock referenced this in commit 3baee7ba24 on Jan 9, 2018
  21. andvgal referenced this in commit 0bcc27b367 on Jan 6, 2019
  22. 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: 2026-04-15 21:16 UTC

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