Fix bug in memory usage calculation (unintended integer division) #12784

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:calc-error changing 1 files +2 −2
  1. practicalswift commented at 8:13 AM on March 26, 2018: contributor

    Fix bug in memory usage calculation (unintended integer division).

  2. practicalswift renamed this:
    Fix error in memory usage calculation (unintended integer division)
    Fix bug in memory usage calculation (unintended integer division)
    on Mar 26, 2018
  3. fanquake requested review from eklitzke on Mar 26, 2018
  4. promag commented at 1:29 PM on March 27, 2018: member

    ACK 490e8be.

  5. Fix error in memory usage calculation (unintended integer division) a16c6d23ca
  6. in src/dbwrapper.cpp:162 in 490e8be193 outdated
     158 | @@ -159,12 +159,12 @@ bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync)
     159 |      const bool log_memory = LogAcceptCategory(BCLog::LEVELDB);
     160 |      double mem_before = 0;
     161 |      if (log_memory) {
     162 | -        mem_before = DynamicMemoryUsage() / 1024 / 1024;
     163 | +        mem_before = (double)DynamicMemoryUsage() / 1024 / 1024;
    


    laanwj commented at 6:58 PM on March 27, 2018:

    Wouldn't replacing 1024 with 1024.0 here (and in the other case) have the same effect, but avoid the cast?


    practicalswift commented at 8:40 PM on March 27, 2018:

    @laanwj Absolutely! Now updated. Please re-review :-)

  7. practicalswift force-pushed on Mar 27, 2018
  8. eklitzke commented at 11:16 PM on March 27, 2018: contributor

    ACK a16c6d23cadb517f1e728c719a316768ae7b7fe8

    I'm really tempted to add formatters for MiB and whatnot as a new format specifier in tinyformat.h, as we have this logic all over the place.

  9. MarcoFalke commented at 11:38 PM on March 27, 2018: member

    utACK a16c6d23cadb517f1e728c719a316768ae7b7fe8

  10. eklitzke approved
  11. practicalswift commented at 2:38 AM on March 28, 2018: contributor

    @eklitzke Formatters for MiB, etc sounds nice!

  12. fanquake commented at 1:04 PM on March 29, 2018: member
  13. laanwj commented at 1:11 PM on March 29, 2018: member

    I'm really tempted to add formatters for MiB and whatnot as a new format specifier in tinyformat.h, as we have this logic all over the place.

    I'd prefer not to make such changes to tinyformat.h locally. Unless you manage to upstream it (https://github.com/c42f/tinyformat), an utility function would be preferable. Although this is arguably so simple I'm not sure how much is gained by that.

  14. laanwj merged this on Mar 29, 2018
  15. laanwj closed this on Mar 29, 2018

  16. laanwj referenced this in commit e80716d3b3 on Mar 29, 2018
  17. Fabcien referenced this in commit 8b217943d2 on Aug 30, 2019
  18. jonspock referenced this in commit 967ae8b763 on Dec 8, 2019
  19. jonspock referenced this in commit 63aeab11db on Dec 8, 2019
  20. jonspock referenced this in commit fc8fc19747 on Dec 8, 2019
  21. proteanx referenced this in commit fa4fd9798e on Dec 12, 2019
  22. PastaPastaPasta referenced this in commit 5de809e0f8 on Sep 27, 2020
  23. PastaPastaPasta referenced this in commit c82688bc90 on Sep 27, 2020
  24. PastaPastaPasta referenced this in commit d1e98dca54 on Oct 14, 2020
  25. practicalswift deleted the branch on Apr 10, 2021
  26. gades referenced this in commit 9bbe35317c on Jun 24, 2021
  27. gades referenced this in commit b0bd57c39e on Jan 29, 2022
  28. DrahtBot locked this on Aug 16, 2022

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-16 15:15 UTC

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