1

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

3 Answers 3

7

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
1
  • Not even found in the openSUSE repositories... Jul 2, 2013 at 9:45
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.

8
  • is there any other way to compress xml files?
    – Arvind
    Jul 2, 2013 at 5:55
  • Uh... there are lots and lots and lots of ways... Jul 2, 2013 at 5:55
  • which is best in linux...that can use less cpu?
    – Arvind
    Jul 2, 2013 at 5:59
  • Simple. Don't compress, just store. -0 Jul 2, 2013 at 6:01
  • Are you sure, have you tested that? Doesn't make any sense to me. The more compressible a file is the easier should the compression codes be found. That something cannot be compressed is known only after everything has been tried. Jul 2, 2013 at 9:37
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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