<table><tr><td style="">mwolff created this revision.<br />mwolff added a reviewer: dfaure.<br />Restricted Application added a project: Frameworks.<br />Restricted Application added a subscriber: Frameworks.<br />mwolff requested review of this revision.
</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/D9824" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This greatly reduces the on-CPU time of the benchNotifyWatcher.<br />
The issue was that for every inotify event, the list of all<br />
entries would be walked which has abysmal performance when<br />
the map is large. By introducing a direct mapping we greatly<br />
speed things up.</p>

<p>I actually spotted this issue while profiling KDevelop, which<br />
sometimes exhibits similar performance issues.</p>

<p>Running the benchmarks with <tt style="background: #ebebeb; font-size: 13px;">-perf</tt> we can measure the cycles<br />
which trasnaltes to on-CPU time, ignoring the off-CPU time<br />
induced by sleeping and waiting in the tests.</p>

<p>Before:<br />
RESULT : KDirWatch_UnitTest::benchNotifyWatcher():</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);">306,496,490.1 CPU cycles per iteration (total: 3,064,964,902, iterations: 10)</pre></div>

<p>After:<br />
RESULT : KDirWatch_UnitTest::benchNotifyWatcher():</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);">219,120,818.3 CPU cycles per iteration (total: 2,191,208,183, iterations: 10)</pre></div>

<p>Note that the other backends could leverage a similar trick to<br />
speed them up.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R244 KCoreAddons</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D9824" rel="noreferrer">https://phabricator.kde.org/D9824</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/lib/io/kdirwatch.cpp<br />
src/lib/io/kdirwatch_p.h</div></div></div><br /><div><strong>To: </strong>mwolff, dfaure<br /><strong>Cc: </strong>Frameworks<br /></div>