<table><tr><td style="">davidedmundson created this revision.<br />Herald added a project: Frameworks.<br />Herald added a subscriber: kde-frameworks-devel.<br />davidedmundson 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/D17195">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Connection is used in two places SlaveBase (file.so etc) and<br />
SlaveInterface (dolphin etc).</p>

<p>In SlaveInterface it operates in a normal event-driven Qt way with<br />
signals when data is ready. If data is ready and a client reads one<br />
line, it emitted dataReady again next event loop to tell the client to<br />
read the next line.</p>

<p>SlaveBase has a custom event loop. We're either polling the task queue<br />
or blocking for a more low level signal, we don't ever process the Qt<br />
event queue.<br />
The one exception is  QCoreApplication::sendPostedEvents(nullptr,<br />
QEvent::DeferredDelete); which we called manually after we've dispatched<br />
each task.</p>

<p>If we're copying a lot of files, SlaveBase reads the first command<br />
there's still many commands left so in the SlaveBase we post an event,<br />
which won't get used, into the queue.</p>

<p>This is a problem as now when we call sendPostedEvents(DefferedDelete)<br />
qApp itterates through the list of pending events in linear time,<br />
without clearing anything. After each command we're itterating through a<br />
bigger and bigger list until we're spending all our CPU time here.</p>

<p>This patch splits Connection to have distinct modes for use by SlaveBase<br />
and SlaveInterface as SlaveBase wasn't going to ever run those queued<br />
events anyway.</p>

<p>Copying 1 million 10 byte text files on my machine:<br />
Before: 14 hours<br />
After: 10 minutes</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D17195">https://phabricator.kde.org/D17195</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/core/connection.cpp<br />
src/core/connection_p.h<br />
src/core/slavebase.cpp</div></div></div><br /><div><strong>To: </strong>davidedmundson<br /><strong>Cc: </strong>kde-frameworks-devel, michaelh, ngraham, bruns<br /></div>