topcontexts

René J.V. Bertin rjvbertin at gmail.com
Wed Apr 11 08:25:56 UTC 2018


Hi,

Apologies for making this thread yet a bit more endless. I am going to return that suggestion to profile right back at you, Milian.

I don't know if the idea to use mmap is yours, but you brought up its existence and have already profiled KDevelop before (and are clearly used to doing that).

I think we should see some concise, quantitative justification of using thousands of mmap resources if the implementation states it could be problematic and the fallback code does basically the same thing.
(The fallback reads the file remainder into a buffer, and then delete the QFile*; given the average size of those files that content could well already have been buffered anyway.)

There are over 5000 topcontext files in my session that has the KDevelop project, and on Mac mmaps will show up among the open files in the process inspector. I've added a simple QElapsedTimer to the background parser's updateProgress method (see below) and can confirm that I don't see systematic differences there. If more precise data obtained through profiling can show that there is indeed a (real-world) performance benefit to the mmap approach then fine (and maybe next time I'll try to profile something myself). If not, how is that not a waste of resources that could be used better elsewhere?

--- background parser timer (a priori meant to time a full project reparse but maybe I should keep track of all timings and print some stats on exit)

diff --git a/kdevplatform/language/backgroundparser/backgroundparser.cpp b/kdevplatform/language/backgroundparser/backgroundparser.cpp
index f76cb612e2f4505e97c3371a36b0c36e26592cb5..19a4eeb3fe41e5e22d8b0bce893b041890091bdf 100644
--- a/kdevplatform/language/backgroundparser/backgroundparser.cpp
+++ b/kdevplatform/language/backgroundparser/backgroundparser.cpp
@@ -30,6 +30,7 @@
 #include <QMutexLocker>
 #include <QPointer>
 #include <QTimer>
+#include <QElapsedTimer>
 #include <QThread>
 
 #include <KConfigGroup>
@@ -195,6 +196,7 @@ public:
         m_timer.setSingleShot(true);
         m_progressTimer.setSingleShot(true);
         m_progressTimer.setInterval(500);
+        m_totalTimer.invalidate();
 
         ThreadWeaver::setDebugLevel(true, 1);
 
@@ -507,6 +513,7 @@ config.readEntry(entry, oldConfig.readEntry(entry, default))
     int m_progressMax = 0;
     int m_progressDone = 0;
     QTimer m_progressTimer;
+    QElapsedTimer m_totalTimer;
 };
 
 BackgroundParser::BackgroundParser(ILanguageController *languageController)
@@ -763,6 +770,9 @@ void BackgroundParser::updateProgressData()
         if (!d->m_progressTimer.isActive()) {
             d->m_progressTimer.start();
         }
+        if (!d->m_totalTimer.isValid()) {
+            d->m_totalTimer.start();
+        }
     }
 
     // Cancel progress updating and hide progress-bar when parsing is done.
@@ -772,6 +782,13 @@ void BackgroundParser::updateProgressData()
         if (d->m_progressTimer.isActive()) {
             d->m_progressTimer.stop();
         }
+        if (d->m_totalTimer.isValid()) {
+            qreal elapsed = d->m_totalTimer.elapsed() / 1000.0;
+            d->m_totalTimer.invalidate();
+            if (qEnvironmentVariableIsSet("KDEV_BACKGROUNDPARSER_TIMINGS")) {
+                qCInfo(LANGUAGE) << "Finished background parse job(s) in" << elapsed << "seconds";
+            }
+        }
         emit d->m_parser->hideProgress(d->m_parser);
     }
 }



More information about the KDevelop-devel mailing list