Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I am using the zip utility in Linux to compress files, CPU utilization is going to 100%.

Can anybody help me why CPU utilization is so high?

I'm using the command:

zip file_name *.xml
share|improve this question

3 Answers 3

The more compressible a file is, the more CPU it will use while compressing since it will actually be performing compression (which is CPU-bound) rather than I/O. XML files are highly compressible due to their verbose and repetitive nature.

share|improve this answer
    
thanks for reply... –  Arvind Jul 2 '13 at 5:55
    
is there any other way to compress xml files? –  Arvind Jul 2 '13 at 5:55
    
Uh... there are lots and lots and lots of ways... –  Ignacio Vazquez-Abrams Jul 2 '13 at 5:55
    
which is best in linux...that can use less cpu? –  Arvind Jul 2 '13 at 5:59
    
Simple. Don't compress, just store. -0 –  Ignacio Vazquez-Abrams Jul 2 '13 at 6:01

You can limit the cpu usage for zip command to not go beyond certain usage. for example, if you want zip command not to take more then 30% of CPU then you can use the following:

  cpulimit -e zip -l 30
share|improve this answer
    
Not even found in the openSUSE repositories... –  Hauke Laging Jul 2 '13 at 9:45

CPU utilization is high if the task can use a lot of CPU power without being interrupted. You could say: A high CPU utilization is good because it makes increasing the speed of the computer easy...

If you would compress a file which can be compressed with minimal effort (e.g. repeat the same line of text 100000 times), do that on an extremely fast CPU and load the file from an extremely slow disk (or network storage) then the CPU utilization would decrease. But it would do so because the CPU waits for I/O all the time. If the storage is very fast and the CPU very slow then CPU utilization increases because the I/O wait time in relation to the CPU time decreases.

A CPU utilization below 100% means that your CPU has unused resources. That's usually not what you want. A process with high CPU utilization is even better for the other processes on the system because it does not impact their I/O bottleneck.

Which processes are executed more slowly when several processes are really competing for CPU time (each of them could use 100% CPU) depends on the CPU priority which can be seen with ps or top and set with top, nice, and renice. cgroups are a mighty concept for prioritizing groups of processes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.