aboutsummaryrefslogtreecommitdiff
path: root/src/sync.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-08-18 19:53:42 +0200
committerJon Atack <jon@atack.com>2021-09-01 15:25:38 +0200
commit9b08006bc502e67956d6ab518388fad6397cac8d (patch)
treec91ff6a05c64c14fe7b6085ec9a5008c37061871 /src/sync.cpp
parent3f4c6b87f1098436693c4990f2082515ec0ece26 (diff)
log, sync: improve lock contention logging and add time duration
in microseconds. Change the function name in order to print "LockContention" instead of "PrintLockContention" to the log. Add Doxygen documentation. With this change, the lock contention log prints: 2021-09-01T11:29:03Z LockContention: pnode->cs_vSend, net.cpp:1373 started 2021-09-01T11:29:03Z LockContention: pnode->cs_vSend, net.cpp:1373 completed (31μs) 2021-09-01T11:29:03Z LockContention: cs_vNodes, net.cpp:2277 started 2021-09-01T11:29:03Z LockContention: cs_vNodes, net.cpp:2277 completed (6μs) 2021-09-01T11:29:04Z LockContention: cs_vNodes, net.cpp:2242 started 2021-09-01T11:29:04Z LockContention: cs_vNodes, net.cpp:2242 completed (3μs) Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
Diffstat (limited to 'src/sync.cpp')
-rw-r--r--src/sync.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sync.cpp b/src/sync.cpp
index 9351417d43..ef46bbb22f 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -9,6 +9,7 @@
#include <sync.h>
#include <logging.h>
+#include <logging/timer.h>
#include <tinyformat.h>
#include <util/strencodings.h>
#include <util/threadnames.h>
@@ -27,10 +28,9 @@
#if !defined(HAVE_THREAD_LOCAL)
static_assert(false, "thread_local is not supported");
#endif
-void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
+void LockContention(const char* pszName, const char* pszFile, int nLine)
{
- LogPrint(BCLog::LOCK, "LOCKCONTENTION: %s\n", pszName);
- LogPrint(BCLog::LOCK, "Locker: %s:%d\n", pszFile, nLine);
+ LOG_TIME_MICROS_WITH_CATEGORY(strprintf("%s, %s:%d", pszName, pszFile, nLine), BCLog::LOCK);
}
#endif /* DEBUG_LOCKCONTENTION */