Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match concurrency to available CPU bandwidth #2300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jun 15, 2023

  1. Match concurrency to available CPU bandwidth

    This change allows ninja to throttle number of parallel tasks based
    on feedback from Linux kernel's PSI (Pressure Stall Information)
    interfacts.  It extends "-l" parameter to accept negative values;
    "-l-NN" means that ninja should limit concurrency when processes
    in current cgroup spend more than NN% of their time stalled on CPU.
    
    E.g., running "ninja -j100 -l-10" on a 32-core machine will quickly
    settle on parallelism of 32-34.
    
    This option is designed to make ninja use all CPU bandwidth available
    to a cgroup-based container, while not starting excessive number of
    processes, which could eat up all RAM.
    
    The motivation for this feature is to automatically reduce
    parallelism when the system is about to run out of RAM.
    If the system has swap enabled, "ninja -l-10" will dance with
    parallelism on the edge of just using a bit of swap.  As soon as
    a process starts swapping, CPU "stalled" cycles increase, and
    parallelism is reduced.  The same argument works when a process is
    waiting for its turn to use IO and/or network.
    maxim-kuvyrkov committed Jun 15, 2023
    Configuration menu
    Copy the full SHA
    92878c3 View commit details
    Browse the repository at this point in the history