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
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.
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:
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