<table><tr><td style="">meven added a comment.
</td></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/T11627#218943" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">T11627#218943</a>, <a href="https://phabricator.kde.org/p/meven/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@meven</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/T11627#206210" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">T11627#206210</a>, <a href="https://phabricator.kde.org/p/broulik/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@broulik</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><p>I'm pretty sure there's a tonne of blocking DBus calls being done all over the place during file copy (checking for slaves on hold, updating kuiserver job tracking info, etc) which can cause apps to hang or slow down if whatever they're trying to call into is busy. Best example: SIGSTOP plasmashell, try copying a file in Dolphin, won't work until plasmashell SIGCONTs.</p></div>
</blockquote>
<p>That's interesting, we need to fix that.</p>
<p>About <a href="https://bugs.kde.org/show_bug.cgi?id=281270" class="remarkup-link" target="_blank" rel="noreferrer">https://bugs.kde.org/show_bug.cgi?id=281270</a> <tt style="background: #ebebeb; font-size: 13px;">Inconsistent notifications during/after file operations (copying, moving, deleting, compressing, extracting) depending on amount of data/items involved</tt> :</p>
<p>A possible way to fix this would probably use sendfile with O_NONBLOCK + select.<br />
After a non-blocking sendfile we call select/pselect on the dest file descriptor. Then when it returns something other than EWOULDBLOCK, we can deduce the processed bytes from the size sent to copy to dest (i.e sendfile count parameter) or use pselect and its sigset_t parameter. We then can call sendfile again to write next bytes.<br />
On the plus side it would make the code async which would make progress reporting more reactive.</p></div>
</blockquote>
<p>This approach does not work unfortunately, select does not take into account filesystem sync.<br />
I tried also with <tt style="background: #ebebeb; font-size: 13px;">sync_file_range</tt> but it does not block when file is syncing.</p>
<p>That being said the select method allows to free some main thread cpu time while the kernel is running sendfile.<br />
Allowing for instance to notify ioslaves users of progress.</p>
<p>Regarding this bug I have the idea of adding a state "Closing file" or "Writing data to disk" to the CopyJob so users can surface to users that something is going on.</p>
<p>And I want to edit <a href="https://phabricator.kde.org/D25079" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D25079</a> where the chunk size for sendfile is probably too big.</p></div></div><br /><div><strong>TASK DETAIL</strong><div><a href="https://phabricator.kde.org/T11627">https://phabricator.kde.org/T11627</a></div></div><br /><div><strong>To: </strong>meven<br /><strong>Cc: </strong>broulik, ognarb, Dolphin, Frameworks, meven, dfaure, pberestov, iasensio, fprice, LeGast00n, MrPepe, fbampaloukas, alexde, GB_2, Codezela, feverfew, michaelh, spoorun, navarromorales, firef, ngraham, andrebarros, bruns, emmanuelp, mikesomov<br /></div>