clamtk icon indicating copy to clipboard operation
clamtk copied to clipboard

High CPU usage

Open szekelyisz opened this issue 7 years ago • 4 comments

I'm scanning my Windows system disk with ClamTK from Ubuntu 16.10. Initially the scanning window is empty (I guess it's determining the list of files to scan), and CPU usage is low. As soon as the actual scan starts, ClamTK itself eats up almost 50% of one core of a 2.67 GHz i5. It's not just ClamTK, but also Xorg starts burning the CPU. This CPU usage is from ClamTK itself, clamscan's usage is a separate thing and not included. Maybe it's because the frequent update of the name of the file being scanned in the scan window. If that's the case, an option to disable displaying the filename should be implemented, because this is a price too high to pay for displaying something that's changing so fast that it's basically impossible to read anyway.

szekelyisz avatar Oct 23 '16 18:10 szekelyisz

Hi,

Thanks for passing along. First, I recommend you do not scan Windows with ClamTk. ClamTk is made for LInux - I'm afraid I don't have time to test out things on a Windows system. If you're still interested in using the ClamAV backend on Windows, I recommend you check out something like "clamwin".

Second, mostly all ClamTk is doing is echo-ing back what the backend is telling it. There is some CPU usage at the beginning for the progressbar, which was requested by a lot of users. I'm trying to make that not as bad, but I haven't made it very far yet. :( I'd like to use a "renice" or "nice" command in there, which would take longer but wouldn't crush all the CPU power.

So, in summary - please, for the sake of your Windows sytem - don't use ClamTk for that. Also, if you really want to scan an entire hard drive (on Linux), I recommend you use a rootkit scanner instead - and use ClamTk for scanning downloads and your home drive and the like.

I have the feeling I probably haven't been able to help you much here, but I'll keep working on making it better. Thanks again for reporting the issue.

respectfully Dave M

dave-theunsub avatar Oct 23 '16 18:10 dave-theunsub

Hi Dave,

thanks for the rapid reply. I think you misunderstood me. I'm not using the ClamAV on Windows. I'm running both the ClamAV backend and ClamTK on Ubuntu with my Windows disk mounted, and pointing ClamTK to the mount point to scan. I don't see why this should be a problem, for ClamAV files are just files, no matter which filesystem they're coming from.

I understand that the progress bar is very useful. In fact, this is the feature why I was looking for a graphical frontend to ClamAV: to get an estimate of how long the scan will take, because clamscan gives no clues about that. Of course this needs some preparations like counting the number of files to scan. There's no problem there.

I'm talking about the too frequent update of the scan window. Just to try, I've commented out the respective function calls (set_infobar_text() and $files_scanned_label->set_text()) in scan() in Scan.pm, and viola, CPU usage dropped dramatically and comes almost entirely from clamscan. Of course this way the window doesn't display the file bing scanned and the number of files scanned, but the progress bar still works. You could set up a recurring timer for 100ms for example to update these fields. This way you can still present useful information to your users without burning their CPUs.

szekelyisz avatar Oct 23 '16 19:10 szekelyisz

Hi,

No, I understand what you're saying, but please be careful. Like I said, I have not tested scanning Windows systems. Someday I'll tell the story of how ClamTk had the capability to (and did, a few times) delete entire mailboxes... Lessons learned early on... :)

Anyway, I'll take a look at your suggestions in paragraph 3 and see what I come up with. I'm trying to also release a new program, and that's what's taking up most of my time. :) I'll jump back onto ClamTk soon. I appreciate your feedback.

respectfully Dave M

dave-theunsub avatar Oct 24 '16 09:10 dave-theunsub

Thanks Dave! Keep up the good work!

szekelyisz avatar Oct 24 '16 14:10 szekelyisz