Menu

#345 Limit CPU usage of 7z Process during Compress

open
nobody
5
2024-06-14
2020-01-21
No

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}

Discussion

  • Igor Pavlov

    Igor Pavlov - 2020-01-23

    -m0=lzma -mx=3 uses only 1 cpu thread.

     
  • Steffen Müller

    Steffen Müller - 2020-01-23

    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 ?

     
    • Shell

      Shell - 2020-01-27

      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 via start 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
  • Igor Pavlov

    Igor Pavlov - 2020-01-23

    -m0=lzma -mx=3 is 1 thread
    -m0=lzma -mx=5 is 1or 2 threads
    -m0=lzma2 is any number of threads

     
  • BRUNO B75

    BRUNO B75 - 2024-06-14

    Alternatively, 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

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.