Limit CPU usage of 7z Process during Compress
A free file archiver for extremely high compression
Brought to you by:
ipavlov
Is there a way for 7z command line tools to limit the CPU/Resource Usage of 7z when creating an archive? With -mmt=on the Process uses almost 90% of CPU, but with -mmt=off just 20-25%. Is there a way to use 50% of CPU?
CPU usage goes up to 90%:
7za a -m0=lzma -mmt=on -mhe=on -mx=3 base.7z {SourcePath}
CPU usage goes up to 25%:
7za a -m0=lzma -mmt=off -mhe=on -mx=3 base.7z {SourcePath}
-m0=lzma -mx=3 uses only 1 cpu thread.
If I use -mmt=off it uses 1 Thread, with -mmt=on as much as possible and with -mmt=2 it tries to use only tow Threads. So this is the only way of limiting the use of CPU ?
Yes,
-mmt
(and-stm
) is the only way to control CPU usage at the moment. I think it would also be useful to adjust CPU and I/O priority, but it is not implemented yet. You can adjust CPU priority viastart
command, and there are third-party tools to adjust both priorities.There is no way to control I/O usage in 7-Zip now (except for manually pausing execution threads). You can implicitly control memory usage by changing dictionary size and the number of threads. For LZMA/LZMA2, 7-Zip allocates a multiple of dictionary size for each pair of threads. See help for details.
Last edit: Shell 2020-01-27
-m0=lzma -mx=3
is 1 thread-m0=lzma -mx=5
is 1or 2 threads-m0=lzma2
is any number of threadsAlternatively, you can run the process in a more dynamic/autoadaptive way by giving it a higher/lower priority level.
In Windows, use start /LOW [ xxxxx.exe + args ]
(Run start /? to check for more values)
start /LOW runs the process in 'idle' mode, meaning it will run only when the processor is idle.
Most other processes will then have priority over it, so it will run slower when the CPU is busy (but it will never be frozen/stopped completely).
The bonus is that it will still use as much processing power as it can when the load diminishes.
The overall result is that your process will run just the same as usual (i.e. full speed) when the computer is under light load, but will yield to other processes when the load increases.
You can even change the priority level after starting a process, using the Windows Task Manager (right-click any process in Details view/tab) or other process management tools like SysInternals 'Process Explorer' (freely available on Microsoft SysInternals Web site - highly recommended)
Under Linux you get to do the same with the nice/renice commands.
Last edit: BRUNO B75 2024-06-14