Our man file copy function has some glaring issues that I'd like to tackle in a few steps:
- Split the sendfile and read/write code path to function, to make evolution easier
- Then Make those function io calls (read, write, sendfile) O_NONBLOCK and use select/poll freeing user space CPU time to for instance notify the user of progressand and reducing chances of blocking in both ways (file io blocking or socket/ksmserver blocking)
- Then make the sendFile/write operation O_DIRECT and O_SYNC (https://linux.die.net/man/2/open), perhaps by default, or option or depending on the fs destination. Fixing https://bugs.kde.org/show_bug.cgi?id=281270 Inconsistent notifications during/after file operations (copying, moving, deleting, compressing, extracting) depending on amount of data/items involved (another to fix this is to mount usb sticks with the sync mount option)
Then if needed :
- D28555
Tune the parameters of the sendFile code path to copy data by chunks bigger than 32kB, I am thinking 128/512 to keep granular progress reporting, Tune the read/write (it reads and write by chunks of 32kB at the moment
Bonus steps
- Add a io_uring (https://lwn.net/Articles/778411/) code path for recent linux kernels
All of those steps should make the code more async, maintainable and performant, and fix a few longstanding bugs.
It should help on
*Ridiculously slow file copy (multiple small files) https://bugs.kde.org/show_bug.cgi?id=342056