When moving dozens of files to trash, and while having lots of files already sitting in the .Trash directories, gvfsd-trash uses 100% of CPU, and Thunar also uses a lot of CPU for minutes while being unresponsive.
I just tried to empty my trash ( 15000 item; about 1GB)
and it raised the CPU to 100% on i5 quad(?) core. I canceled the process after about 1.5 minutes.
Thunar also start to hang.
Maybe as a hint:
using trash-empty ( package: trash-cli ) did the job in a very smooth and fast way.
On Arch Linux I use "gio trash --empty" which is very fast, unless Thunar is running, in which case it will hang and use a lot of CPU as it's probably monitoring the trash directories. So using that or using Thunar's empty trash shortcut gives the same problem.
On Arch Linux I use "gio trash --empty" which is very fast, unless Thunar is
running, in which case it will hang and use a lot of CPU as it's probably
monitoring the trash directories. So using that or using Thunar's empty
trash shortcut gives the same problem.
That was an excellent hint, thanks !
I tried to diable different thunar file monitors, and found out that the "bookmark_monitor" makes a big difference for me when executing "gio trash --empty".
I am not sure why two different files create a "bookmark monitor" ... possibly that is the problem.
Before checking details, could you please try if the attached patch fixes the bug for you ?
(No bookmark monitor at all)
Note: Restoring the files is also extremely slow. About 5 sec per file (i.e. 3.5hours for restoring 2600 files). But that also happens here with only 5 to 10 files. Maybe a VM problem?
While building a testenvironment I figured thunar also takes *a lot of time for moving and renaming many files.
Regarding moving with about 2600 files a 400kb:
mv file* ./target took about 1 second(?) (I couldn't even start counting. It finished right after pressing enter)
Thunar: about 16 seconds ("detailed" view)
Why am I saying this? Because there might be a general problem with the moving process (I guess trashing is also just a "move to trash"-move operation (?)
Regarding "move" in general: To be checked if that's only a thunar problem, or if the slowness comes from g_file_move .. same for nautilus/nemo, which probably as well rely on g_file_move .. is it faster there ?
I changed the code to make deletions run in linear (no creation of the copy window) (Code changes below).
...
Hanging: yes
So I guess more investigation is needed.
My assumption why your modified thunar_application_trash as well hangs is, that it is done in the main-thread, which is blocked for the time it takes. In any case, you should execute that code in a separate thread (ThunarJob/ExoJob).
Currently code is already executed in a separate thread, so that is already fine, check _thunar_io_jobs_trash, which in the end is called via trash_stub ... possibly that extra-thread either blocks some resources of the main-thread or possibly updates on the trash-folder are triggered.
I would suggest to simplify _thunar_io_jobs_trash to see if that helps, and to check which part of the code actually causes the hang.
My assumption why your modified thunar_application_trash as well hangs is, that it is done in the main-thread, which is blocked for the time it takes.
Sorry, "Hanging: yes" was was unclear! Of course it "hangs" while in operation. I meant: after the operation (meaning after g_print("finished delete operation---\n");) Thunar still hang.
All in all, probably it would make sense to dig more into the direction the reported suggests (rate limit for file/folder updates). FOr that, best read the linked issue and the related merge request for nautilus.
We dont have s specific trash-monitor in thunar, but we have different file and folder monitors. Best search for g_file_monitor in the thunar codebase and put some printf into the related callback to see if one of them is called with high rate when trashing files.