Created
May 7, 2018 14:07
-
-
Save jamesob/2aebc372f6421e6888ff2e5c29ac71b0 to your computer and use it in GitHub Desktop.
diff -uw <(git diff master..threadnames2.3) <(git diff master..threadnames2.4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /proc/self/fd/15 2018-05-07 10:05:27.307982805 -0400 | |
+++ /proc/self/fd/16 2018-05-07 10:05:27.307982805 -0400 | |
@@ -142,7 +142,7 @@ | |
// Start the lightweight task scheduler thread | |
diff --git a/src/logging.cpp b/src/logging.cpp | |
-index 60d418f..e9d63a7 100644 | |
+index 60d418f..ec9244a 100644 | |
--- a/src/logging.cpp | |
+++ b/src/logging.cpp | |
@@ -5,6 +5,12 @@ | |
@@ -158,80 +158,19 @@ | |
const char * const DEFAULT_DEBUGLOGFILE = "debug.log"; | |
-@@ -198,10 +204,17 @@ std::string BCLog::Logger::LogTimestampStr(const std::string &str) | |
- return strStamped; | |
- } | |
- | |
--void BCLog::Logger::LogPrintStr(const std::string &str) | |
-+void BCLog::Logger::LogPrintStr(const std::string &str, bool include_threadname) | |
- { | |
- std::string strTimestamped = LogTimestampStr(str); | |
+@@ -177,7 +183,11 @@ std::string BCLog::Logger::LogTimestampStr(const std::string &str) | |
-+ if (include_threadname) { | |
-+ std::string thread_name(thread_util::GetInternalName()); | |
+ if (m_started_new_line) { | |
+ int64_t nTimeMicros = GetTimeMicros(); | |
+- strStamped = FormatISO8601DateTime(nTimeMicros/1000000); | |
++ std::string thread_name = thread_util::GetInternalName(); | |
+ // The longest thread name (with numeric suffix) we have at the moment is 13 characters. | |
+ thread_name.resize(13, ' '); | |
-+ strTimestamped = "[" + std::move(thread_name) + "] " + strTimestamped; | |
-+ } | |
++ strStamped = "[" + std::move(thread_name) + "] " + FormatISO8601DateTime(nTimeMicros/1000000); | |
+ | |
- if (m_print_to_console) { | |
- // print to console | |
- fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout); | |
-diff --git a/src/logging.h b/src/logging.h | |
-index 6400b13..71b8019 100644 | |
---- a/src/logging.h | |
-+++ b/src/logging.h | |
-@@ -85,8 +85,14 @@ namespace BCLog { | |
- fs::path m_file_path; | |
- std::atomic<bool> m_reopen_file{false}; | |
- | |
-- /** Send a string to the log output */ | |
-- void LogPrintStr(const std::string &str); | |
-+ /** | |
-+ * Send a string to the log output | |
-+ * | |
-+ * @argument include_threadname If true, prefix the message with the name of | |
-+ * the originating thread. Should be false when | |
-+ * working with "Continued" log lines. | |
-+ */ | |
-+ void LogPrintStr(const std::string &str, bool include_threadname = true); | |
- | |
- /** Returns whether logs will be written to any output */ | |
- bool Enabled() const { return m_print_to_console || m_print_to_file; } | |
-@@ -143,7 +149,12 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c | |
- #define LogPrintf(...) do { MarkUsed(__VA_ARGS__); } while(0) | |
- #define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0) | |
- #else | |
--#define LogPrintf(...) do { \ | |
-+#define LogPrintf(...) do { _LogPrintf(false, __VA_ARGS__); } while(0) | |
-+#define LogPrint(category, ...) do { _LogPrint(false, category, __VA_ARGS__); } while(0) | |
-+#define LogPrintfContinued(...) do { _LogPrintf(true, __VA_ARGS__); } while(0) | |
-+#define LogPrintContinued(category, ...) do { _LogPrint(true, category, __VA_ARGS__); } while(0) | |
-+ | |
-+#define _LogPrintf(is_continued_logline, ...) do { \ | |
- if (g_logger->Enabled()) { \ | |
- std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \ | |
- try { \ | |
-@@ -152,15 +163,16 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c | |
- /* Original format string will have newline so don't add one here */ \ | |
- _log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \ | |
- } \ | |
-- g_logger->LogPrintStr(_log_msg_); \ | |
-+ g_logger->LogPrintStr(_log_msg_, /*include_threadname*/ !(is_continued_logline)); \ | |
- } \ | |
- } while(0) | |
- | |
--#define LogPrint(category, ...) do { \ | |
-+#define _LogPrint(is_continued_logline, category, ...) do { \ | |
- if (LogAcceptCategory((category))) { \ | |
-- LogPrintf(__VA_ARGS__); \ | |
-+ _LogPrintf((is_continued_logline), __VA_ARGS__); \ | |
- } \ | |
- } while(0) | |
-+ | |
- #endif | |
- | |
- #endif // BITCOIN_LOGGING_H | |
+ if (m_log_time_micros) { | |
+ strStamped.pop_back(); | |
+ strStamped += strprintf(".%06dZ", nTimeMicros%1000000); | |
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp | |
index 57fe455..b2a1249 100644 | |
--- a/src/qt/bitcoin.cpp | |
@@ -253,7 +192,7 @@ | |
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(); | |
diff --git a/src/sync.cpp b/src/sync.cpp | |
-index 6f21d49..137afc6 100644 | |
+index 6f21d49..c6ac11c 100644 | |
--- a/src/sync.cpp | |
+++ b/src/sync.cpp | |
@@ -3,9 +3,13 @@ | |
@@ -281,7 +220,7 @@ | |
sourceFile = pszFile; | |
sourceLine = nLine; | |
fTry = fTryIn; | |
-+ thread_name = thread_name_; | |
++ thread_name = std::move(thread_name_); | |
} | |
std::string ToString() const | |
@@ -300,24 +239,6 @@ | |
int sourceLine; | |
}; | |
-@@ -86,7 +94,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch, | |
- if (i.first == mismatch.second) { | |
- LogPrintf(" (2)"); /* Continued */ | |
- } | |
-- LogPrintf(" %s\n", i.second.ToString()); | |
-+ LogPrintfContinued(" %s\n", i.second.ToString()); | |
- } | |
- LogPrintf("Current lock order is:\n"); | |
- for (const std::pair<void*, CLockLocation> & i : s1) { | |
-@@ -96,7 +104,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch, | |
- if (i.first == mismatch.second) { | |
- LogPrintf(" (2)"); /* Continued */ | |
- } | |
-- LogPrintf(" %s\n", i.second.ToString()); | |
-+ LogPrintfContinued(" %s\n", i.second.ToString()); | |
- } | |
- assert(false); | |
- } | |
@@ -133,7 +141,7 @@ static void pop_lock() | |
void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry) | |
@@ -440,7 +361,7 @@ | |
+BOOST_AUTO_TEST_SUITE_END() | |
diff --git a/src/threadutil.cpp b/src/threadutil.cpp | |
new file mode 100644 | |
-index 0000000..7f0af65 | |
+index 0000000..721d177 | |
--- /dev/null | |
+++ b/src/threadutil.cpp | |
@@ -0,0 +1,213 @@ | |
@@ -531,7 +452,7 @@ | |
+void thread_util::Rename(std::string name) | |
+{ | |
+ SetProcessName(name.c_str()); | |
-+ SetInternalName(name); | |
++ SetInternalName(std::move(name)); | |
+} | |
+ | |
+/* | |
@@ -578,7 +499,7 @@ | |
+static bool EnsureKeyCreated() | |
+{ | |
+ static pthread_once_t key_once = PTHREAD_ONCE_INIT; | |
-+ return pthread_once(&key_once, make_key) ? false : true; | |
++ return !pthread_once(&key_once, make_key); | |
+} | |
+ | |
+std::string thread_util::GetInternalName() | |
@@ -720,47 +641,6 @@ | |
+} // namespace thread_util | |
+ | |
+#endif // BITCOIN_THREADUTIL_H | |
-diff --git a/src/timedata.cpp b/src/timedata.cpp | |
-index 27d0817..85aab8c 100644 | |
---- a/src/timedata.cpp | |
-+++ b/src/timedata.cpp | |
-@@ -110,11 +110,11 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) | |
- | |
- if (LogAcceptCategory(BCLog::NET)) { | |
- for (int64_t n : vSorted) { | |
-- LogPrint(BCLog::NET, "%+d ", n); /* Continued */ | |
-+ LogPrintContinued(BCLog::NET, "%+d ", n); /* Continued */ | |
- } | |
-- LogPrint(BCLog::NET, "| "); /* Continued */ | |
-+ LogPrintContinued(BCLog::NET, "| "); /* Continued */ | |
- | |
-- LogPrint(BCLog::NET, "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); | |
-+ LogPrintContinued(BCLog::NET, "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); | |
- } | |
- } | |
- } | |
-diff --git a/src/txdb.cpp b/src/txdb.cpp | |
-index 333d359..5cc4199 100644 | |
---- a/src/txdb.cpp | |
-+++ b/src/txdb.cpp | |
-@@ -55,7 +55,7 @@ struct CoinEntry { | |
- | |
- } | |
- | |
--CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) | |
-+CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) | |
- { | |
- } | |
- | |
-@@ -390,7 +390,7 @@ bool CCoinsViewDB::Upgrade() { | |
- uiInterface.ShowProgress(_("Upgrading UTXO database"), percentageDone, true); | |
- if (reportDone < percentageDone/10) { | |
- // report max. every 10% step | |
-- LogPrintf("[%d%%]...", percentageDone); /* Continued */ | |
-+ LogPrintfContinued("[%d%%]...", percentageDone); /* Continued */ | |
- reportDone = percentageDone/10; | |
- } | |
- } | |
diff --git a/src/util.cpp b/src/util.cpp | |
index 9a30672..2087443 100644 | |
--- a/src/util.cpp | |
@@ -837,7 +717,7 @@ | |
{ | |
LogPrintf("%s thread start\n", name); | |
diff --git a/src/validation.cpp b/src/validation.cpp | |
-index fc1f647..0e52126 100644 | |
+index fc1f647..382baa1 100644 | |
--- a/src/validation.cpp | |
+++ b/src/validation.cpp | |
@@ -43,6 +43,7 @@ | |
@@ -859,35 +739,6 @@ | |
scriptcheckqueue.Thread(); | |
} | |
-@@ -2243,8 +2244,8 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar | |
- FormatISO8601DateTime(pindexNew->GetBlockTime()), | |
- GuessVerificationProgress(chainParams.TxData(), pindexNew), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); | |
- if (!warningMessages.empty()) | |
-- LogPrintf(" warning='%s'", boost::algorithm::join(warningMessages, ", ")); /* Continued */ | |
-- LogPrintf("\n"); | |
-+ LogPrintfContinued(" warning='%s'", boost::algorithm::join(warningMessages, ", ")); /* Continued */ | |
-+ LogPrintfContinued("\n"); | |
- | |
- } | |
- | |
-@@ -3926,7 +3927,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, | |
- int percentageDone = std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100)))); | |
- if (reportDone < percentageDone/10) { | |
- // report every 10% step | |
-- LogPrintf("[%d%%]...", percentageDone); /* Continued */ | |
-+ LogPrintfContinued("[%d%%]...", percentageDone); /* Continued */ | |
- reportDone = percentageDone/10; | |
- } | |
- uiInterface.ShowProgress(_("Verifying blocks..."), percentageDone, false); | |
-@@ -3990,7 +3991,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, | |
- } | |
- } | |
- | |
-- LogPrintf("[DONE].\n"); | |
-+ LogPrintfContinued("[DONE].\n"); | |
- LogPrintf("No coin database inconsistencies in last %i blocks (%i transactions)\n", chainActive.Height() - pindexState->nHeight, nGoodTransactions); | |
- | |
- return true; | |
diff --git a/src/validation.h b/src/validation.h | |
index 9b40100..5c298a1 100644 | |
--- a/src/validation.h | |
@@ -928,20 +779,3 @@ | |
*/ | |
class CScriptCheck | |
{ | |
-diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp | |
-index a403411..bda6397 100644 | |
---- a/src/wallet/coinselection.cpp | |
-+++ b/src/wallet/coinselection.cpp | |
-@@ -289,10 +289,10 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<CInputCoin>& vCoins | |
- LogPrint(BCLog::SELECTCOINS, "SelectCoins() best subset: "); /* Continued */ | |
- for (unsigned int i = 0; i < vValue.size(); i++) { | |
- if (vfBest[i]) { | |
-- LogPrint(BCLog::SELECTCOINS, "%s ", FormatMoney(vValue[i].txout.nValue)); /* Continued */ | |
-+ LogPrintContinued(BCLog::SELECTCOINS, "%s ", FormatMoney(vValue[i].txout.nValue)); /* Continued */ | |
- } | |
- } | |
-- LogPrint(BCLog::SELECTCOINS, "total %s\n", FormatMoney(nBest)); | |
-+ LogPrintContinued(BCLog::SELECTCOINS, "total %s\n", FormatMoney(nBest)); | |
- } | |
- } | |
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment