logging: bypass timestamp formatting when not logging #12970

pull theuni wants to merge 1 commits into bitcoin:master from theuni:slow-tests changing 1 files +9 −7
  1. theuni commented at 9:26 PM on April 12, 2018: member

    As suggested by @laanwj on IRC:

    <cfields> whoa
    <cfields> Leaving test case "knapsack_solver_test"; testing time: 358694ms
    <cfields> i386 + old wine ^^
    <cfields> Leaving test case "knapsack_solver_test"; testing time: 6781ms
    <cfields> ^^ same, but with the LogPrint commented out
    ...
    <wumpus> if both log-to-file and log-to-console is disabled, it should probably bypass all logging
    

    Edit: The painful line commented out being the LogPrintf in CWallet::AddToWallet.

  2. theuni cross-referenced this on Apr 12, 2018 from issue Use winehq debs for win32 tests by ajtowns
  3. MarcoFalke added the label Refactoring on Apr 12, 2018
  4. laanwj commented at 9:35 PM on April 12, 2018: member

    utACK 8ca1f6ecba5efc278927fd34eb04f6a4254dfe03

  5. theuni commented at 9:41 PM on April 12, 2018: member

    Wine i686 build down to 11 min :)

  6. MarcoFalke commented at 9:41 PM on April 12, 2018: member

    utACK 8ca1f6e (Run time seems to be about the same or slightly faster than with the wine-hq)

  7. theuni commented at 10:14 PM on April 12, 2018: member

    While this is an easy win for tests, we should still track down why LogTimestampStr() is so painful.

  8. laanwj commented at 10:23 PM on April 12, 2018: member

    While this is an easy win for tests, we should still track down why LogTimestampStr() is so painful.

    It looks inefficient too:

    std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
    {
        static std::locale classic(std::locale::classic());
        // std::locale takes ownership of the pointer
        std::locale loc(classic, new boost::posix_time::time_facet(pszFormat));
        std::stringstream ss;
        ss.imbue(loc);
        ss << boost::posix_time::from_time_t(nTime);
        return ss.str();
    }
    
  9. in src/util.cpp:342 in 8ca1f6ecba outdated
     338 | @@ -339,6 +339,10 @@ int LogPrintStr(const std::string &str)
     339 |      int ret = 0; // Returns total number of characters written
     340 |      static std::atomic_bool fStartedNewLine(true);
     341 |  
     342 | +    if (!fPrintToConsole && !fPrintToDebugLog) {
    


    laanwj commented at 10:25 PM on April 12, 2018:

    nit: might be even more efficient to do this check in util.h already, before calling tfm::format.


    theuni commented at 10:34 PM on April 12, 2018:

    Good point, done.

  10. theuni force-pushed on Apr 12, 2018
  11. logging: bypass timestamp formatting when not logging
    This leads to massive speedups under Wine.
    339730a6d8
  12. theuni force-pushed on Apr 12, 2018
  13. jimpo commented at 1:18 AM on April 13, 2018: contributor

    utACK 339730a

  14. sipa commented at 1:27 AM on April 13, 2018: member

    utACK 339730a6d84a3a90ae23d732fbfc1c81af88d435

  15. fanquake commented at 1:30 AM on April 13, 2018: member

    utACK 339730a

  16. sipa merged this on Apr 13, 2018
  17. sipa closed this on Apr 13, 2018

  18. sipa referenced this in commit 5df84de583 on Apr 13, 2018
  19. practicalswift commented at 5:18 AM on April 13, 2018: contributor

    utACK 339730a6d84a3a90ae23d732fbfc1c81af88d435

    Impressive! Very nice find!

  20. sipa cross-referenced this on Apr 13, 2018 from issue Avoid std::locale/imbue madness in DateTimeStrFormat by sipa
  21. laanwj referenced this in commit dec61152d6 on Apr 14, 2018
  22. MarcoFalke referenced this in commit 7b18489ce0 on Apr 20, 2018
  23. theuni cross-referenced this on May 3, 2018 from issue Use thread names in logs and deadlock diagnostics by jamesob
  24. MarcoFalke cross-referenced this on May 21, 2018 from issue Travis: Build tests on Ubuntu 18.04 with docker by ken2812221
  25. MarcoFalke referenced this in commit ae3970655e on May 24, 2018
  26. MarcoFalke referenced this in commit 2d27e63426 on May 24, 2018
  27. MarcoFalke referenced this in commit b3cf3ad30a on May 29, 2018
  28. HashUnlimited cross-referenced this on Sep 5, 2018 from issue Avoid std::locale/imbue in DateTimeStrFormat by HashUnlimited
  29. PastaPastaPasta referenced this in commit c399d41af4 on Jun 17, 2020
  30. PastaPastaPasta referenced this in commit 09f21b73f6 on Jun 17, 2020
  31. PastaPastaPasta referenced this in commit 0524dfb93d on Jun 27, 2020
  32. PastaPastaPasta referenced this in commit e1967e42c4 on Apr 13, 2021
  33. PastaPastaPasta referenced this in commit 9b11b3d8ef on Apr 17, 2021
  34. PastaPastaPasta referenced this in commit bb1ae8452c on Apr 18, 2021
  35. kwvg referenced this in commit 318281c506 on Apr 23, 2021
  36. gades referenced this in commit 809cfd0267 on Jun 30, 2021
  37. 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:54 UTC