From 4ba370b5cabf9a7e75bb45d107a3ed54871c80cb Mon Sep 17 00:00:00 2001 From: Joerg Date: Mon, 9 Oct 2023 21:11:26 +0200 Subject: [PATCH 1/6] Add a debug message, which appears when event in Mixxx application took longer than 20ms --- src/mixxxapplication.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index d3625f47b29..7aaea3d56eb 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -61,6 +61,8 @@ class QMouseEventEditable : public QMouseEvent { #endif }; +constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(20); + } // anonymous namespace #endif @@ -168,7 +170,23 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { default: break; } - return QApplication::notify(target, event); + + PerformanceTimer time; + time.start(); + + bool ret = QApplication::notify(target, event); + + if (time.elapsed() > kEventNotifyExecTimeWarningThreshold) { + qDebug() << "Processing event type" + << event->type() + << "for object" + << target->metaObject()->className() + << target->objectName() + << "took" + << time.elapsed().debugMillisWithUnit(); + } + + return ret; } bool MixxxApplication::touchIsRightButton() { From c716b1981c2f75bb8a7574f9d2d4d614b9e422bd Mon Sep 17 00:00:00 2001 From: Joerg Date: Thu, 19 Oct 2023 22:07:28 +0200 Subject: [PATCH 2/6] Added thread info --- src/mixxxapplication.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 7aaea3d56eb..80db9b4cbf5 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -61,7 +61,7 @@ class QMouseEventEditable : public QMouseEvent { #endif }; -constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(20); +constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(5); } // anonymous namespace #endif @@ -182,6 +182,8 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { << "for object" << target->metaObject()->className() << target->objectName() + << "running in thread:" + << target->thread()->objectName() << "took" << time.elapsed().debugMillisWithUnit(); } From 2e7901b688784004de3afce39e3394b8e6141f75 Mon Sep 17 00:00:00 2001 From: Joerg Date: Fri, 28 Jun 2024 09:23:56 +0200 Subject: [PATCH 3/6] Only start the event loop performance timer if we are in developer mode --- src/mixxxapplication.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 71d6114f1b7..5bb43f982c3 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -15,6 +15,7 @@ #include "track/track.h" #include "track/trackref.h" #include "util/cache.h" +#include "util/cmdlineargs.h" #include "util/color/rgbcolor.h" #include "util/fileinfo.h" #include "util/math.h" @@ -181,10 +182,15 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { #endif PerformanceTimer time; - time.start(); + bool isDeveloper = CmdlineArgs::Instance().getDeveloper(); + + if (isDeveloper) { + time.start(); + } + bool ret = QApplication::notify(target, event); - if (time.elapsed() > kEventNotifyExecTimeWarningThreshold) { + if (isDeveloper && time.elapsed() > kEventNotifyExecTimeWarningThreshold) { qDebug() << "Processing event type" << event->type() << "for object" From 58d99108a1a92f05a37f89c1f5194b69551a35cc Mon Sep 17 00:00:00 2001 From: Joerg Date: Fri, 28 Jun 2024 12:03:54 +0200 Subject: [PATCH 4/6] Adjusted the warning threshold to 5ms and added a comment, which explains this --- src/mixxxapplication.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 5bb43f982c3..d16cca86ebc 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -71,7 +71,16 @@ class QMouseEventEditable : public QMouseEvent { #endif }; #endif -constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(20); + +// kEventNotifyExecTimeWarningThreshold defines the threshold duration for event +// processing warnings. If the processing time of an event exceeds this duration +// in developer mode, a warning will be logged. This is used to identify +// potentially slow event processing in the application, which could impact +// performance. With a 60Hz waveform update rate, paint and swap events must be +// processed through the event queue every 16.6ms, to ensure smooth rendering. +// Exceeding this processing time can lead to visible delays, therefore 5ms is a +// reasonable threshold. +constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(5); } // anonymous namespace From f0a8db5ae136417ca988c8b2fcc9cec96a8e7321 Mon Sep 17 00:00:00 2001 From: Joerg Date: Sat, 7 Sep 2024 17:12:17 +0200 Subject: [PATCH 5/6] Introduce m_isDeveloper member variable in MixxxApplication to cache developer mode status, reducing redundant calls to CmdlineArgs::Instance().getDeveloper(). --- src/mixxxapplication.cpp | 8 ++++---- src/mixxxapplication.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index d16cca86ebc..8c5652b8dbe 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -87,7 +87,8 @@ constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration MixxxApplication::MixxxApplication(int& argc, char** argv) : QApplication(argc, argv), m_rightPressedButtons(0), - m_pTouchShift(nullptr) { + m_pTouchShift(nullptr), + m_isDeveloper(CmdlineArgs::Instance().getDeveloper()) { registerMetaTypes(); // Increase the size of the global thread pool to at least @@ -191,15 +192,14 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) { #endif PerformanceTimer time; - bool isDeveloper = CmdlineArgs::Instance().getDeveloper(); - if (isDeveloper) { + if (m_isDeveloper) { time.start(); } bool ret = QApplication::notify(target, event); - if (isDeveloper && time.elapsed() > kEventNotifyExecTimeWarningThreshold) { + if (m_isDeveloper && time.elapsed() > kEventNotifyExecTimeWarningThreshold) { qDebug() << "Processing event type" << event->type() << "for object" diff --git a/src/mixxxapplication.h b/src/mixxxapplication.h index cb1f2449441..f4ce522f8a2 100644 --- a/src/mixxxapplication.h +++ b/src/mixxxapplication.h @@ -18,5 +18,5 @@ class MixxxApplication : public QApplication { int m_rightPressedButtons; ControlProxy* m_pTouchShift; - + bool m_isDeveloper; }; From 5c49483ce411da6767c6114d3ccf710c04efb6fb Mon Sep 17 00:00:00 2001 From: Joerg Date: Sat, 2 Nov 2024 15:08:11 +0100 Subject: [PATCH 6/6] Adjusted warning threshold again to 10ms --- src/mixxxapplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mixxxapplication.cpp b/src/mixxxapplication.cpp index 8c5652b8dbe..3d45fe052b3 100644 --- a/src/mixxxapplication.cpp +++ b/src/mixxxapplication.cpp @@ -78,9 +78,9 @@ class QMouseEventEditable : public QMouseEvent { // potentially slow event processing in the application, which could impact // performance. With a 60Hz waveform update rate, paint and swap events must be // processed through the event queue every 16.6ms, to ensure smooth rendering. -// Exceeding this processing time can lead to visible delays, therefore 5ms is a +// Exceeding this processing time can lead to visible delays, therefore 10ms is a // reasonable threshold. -constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(5); +constexpr mixxx::Duration kEventNotifyExecTimeWarningThreshold = mixxx::Duration::fromMillis(10); } // anonymous namespace