<table><tr><td style="">rjvbb added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D7742" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>Some fresh timing results on Mac for importing an existing project for gcc 7.2.0 (full project parse off)</p>

<p>Dirwatchers off:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">kdevplatform.shell: All projects imported in 8.324 seconds
kdevplatform.shell:     creating dir watchers and/or starting parse jobs took an additional 0 seconds</pre></div>

<p>deferred dirwatcher creation:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">kdevplatform.shell: All projects imported in 7.846 seconds
kdevplatform.filemanager: Project dir monitoring is enabled for project "gcc-7.2.0-MP"
kdevplatform.shell:     creating dir watchers and/or starting parse jobs took an additional 85.419 seconds

kdevplatform.shell: All projects imported in 8.207 seconds
kdevplatform.filemanager: Project dir monitoring is enabled for project "gcc-7.2.0-MP"
kdevplatform.shell:     creating dir watchers and/or starting parse jobs took an additional 85.039 seconds</pre></div>

<p>Those 85 seconds are spent "beachballing" because KDirWatch::addDir() blocks the event loop (a true busy wait with the CPU running at 100%).</p>

<p>Overall process timing for that last run, when calling Quit (Command-Q) as soon as the dirwatcher creation started (= processed just after that completes):<br />
<tt style="background: #ebebeb; font-size: 13px;">246.719 user_cpu 13.199 kernel_cpu 4:25.29 total_time 97.9%CPU</tt></p>

<p>In other words: destruction of the KDirWatch instance is probably even more expensive than the addDir() call. More precisely:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">kdevplatform.filemanager: Deleting dir watcher took 162.723  for project "gcc-7.2.0-MP"

kdevplatform.shell: All projects imported in 7.937 seconds
kdevplatform.filemanager: Project dir monitoring is enabled for project "gcc-7.2.0-MP"
kdevplatform.shell:     creating dir watchers and/or starting parse jobs took an additional 84.48 seconds
kdevplatform.filemanager: Deleting dir watcher took 160.892  for project "gcc-7.2.0-MP"
245.998 user_cpu 13.800 kernel_cpu 4:23.85 total_time 98.4%CPU</pre></div>

<p>Those almost 3 minutes to close the gcc project are also spent outside of the event loop, and with the CPU running at 100%. There's a built-in way to defer KDirWatch destruction: using deleteLater() but even then it will still take place on (and thus blocking) the eventloop.</p>

<p>Note to self: this NSLog message may be related to KDirWatch/QFSW not working properly on Mac:<br />
2017-09-19 14:55 kdevelop.bin[72054] (CarbonCore.framework) implementation_callback_rpc: ERROR: CFDictionaryGetValue(FSEvents_streamDict, cfPortNumber) => NULL</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D7742" rel="noreferrer">https://phabricator.kde.org/D7742</a></div></div><br /><div><strong>To: </strong>rjvbb, KDevelop, mwolff, brauch<br /><strong>Cc: </strong>mwolff, kossebau, arrowdodger, brauch, zhigalin, kdevelop-devel, geetamc, Pilzschaf, akshaydeo, surgenight<br /></div>