High CPU usage when deleting files (Vista/W7)

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
khagaroth
Junior Member
Junior Member
Posts: 13
Joined: 2009-06-14, 07:30 UTC

High CPU usage when deleting files (Vista/W7)

Post by *khagaroth »

When deleting files in Vista or Window 7 CPU usage goes through the roof and deleting is very slow.
This is not caused by antivirus or any similar program, I tested it on freshly installed OS, where TC was the only program installed. Indexing was turned off and the drive that I deleted from is not monitored by system restore. Also, thumbnails and logging in TC are turned off.
It does not happen if I set TC to use Explorers delete method.
When looking at totalcmd.exe threads in Process Explorer while deleting, all the CPU cycles are consumed by several threads of ntdll.dll!RtlGetCurrentPeb+0x155 with some insane numbers of cycles delta and TOTALCMD.exe+0x35f0. All other running processes have CPU usage under 1%.
Ah, and another weird thing, setting TCs process to lower priority actually speeds deleting up.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Author of Total Commander
https://www.ghisler.com
khagaroth
Junior Member
Junior Member
Posts: 13
Joined: 2009-06-14, 07:30 UTC

Post by *khagaroth »

Wouldn't it be better then to use IFileOperation, that replaces SHFileOperation on Vista and newer? It would be fine to ignore it if the slowdown was small, but right now it is 30times slower than it should be.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, after a quick look at MSDN it doesn't seem to support deleting to the recycle bin - at least there doesn't seem to be an option to delete to recycle bin or not:
http://msdn.microsoft.com/en-us/library/bb775765(VS.85).aspx

Otherwise it looks very promising, allowing to get confirmation about the deletion of each item...
Author of Total Commander
https://www.ghisler.com
User avatar
tbeu
Power Member
Power Member
Posts: 1336
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

It should delete to recycle bin by default as said in http://msdn.microsoft.com/en-us/library/bb775799(VS.85).aspx
If this method is not called, the default value used by the operation is FOF_ALLOWUNDO | FOF_NOCONFIRMMKDIR
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks, that looks indeed very promising. I will make some tests with it.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I have just tested these interfaces today, and they are almost perfect when sending them the list of selected files with DeleteItem() and then calling PerformOperations(). Unfortunately they do have some problems too:
1. The do not warn about read only or hidden/system files! :shock:
That seems to be the case in XP Explorer too! :shock:
2. There seems to be no way to find out before calling these functions whether the drive supports the recycle bin or not
3. It's not possible to skip files in PreDeleteItem(), only accept the deleting or abort the entire process. Therefore I cannot let the user choose whether he wants to skip read only files or not...
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I'm using IFileOperation now by default in beta 6, but each file individually. This still causes high CPU, but it's much faster then SHFileOperation.

To delete all selected files/folders together, you need to add
VistaDelete=1

to wincmd.ini under [Configuration]. Note that the progress bar sometimes behaves strangely, but that's because TC is getting strange values for number of files deleted/total files from the file progress interface.
Author of Total Commander
https://www.ghisler.com
Valery_Kondakoff
Junior Member
Junior Member
Posts: 92
Joined: 2004-06-27, 15:24 UTC

Post by *Valery_Kondakoff »

Is it possible to supress the Windows 'Delete Folder' warning when using VistaDelete=1?

Here is a screenshot: http://www.rugby-forum.ru/temp/delete.jpg (Win7 RC1, TC 7.5b6).
CU
VK
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I was asked that also in the private beta forum, but unfortunately there seems to be no way to do that. It's possible to turn off all dialogs, but not just the initial dialog before the deletion starts. :(
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

It's possible to turn off all dialogs
Well as long as TC is informed about ALL events during the process there should be no problem to your own UI handlers.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately it isn't - there is an option "reply yes to all dialogs", but not "notify me about all problems". :(

Maybe Microsoft will add this to Windows 8...
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Since you can now use VistaDelete=1, I'm moving this to "fixed bugs".
Author of Total Commander
https://www.ghisler.com
Post Reply