• Bruce Dawson's avatar
    Mitigate Python 3 multiprocessing bug on Windows · 8254f06b
    Bruce Dawson authored
    The multiprocessing module on Windows has a bug where if you ask for
    more than 60 child processes then it will hang. This is related to the
    MAXIMUM_WAIT_OBJECTS (64) limit of WaitForMultipleObjects. Other sources
    have listed the multiprocessing limit as being 61, or have said that the
    the maximum number of objects that can be waited on is actually 63, but
    those details don't really matter.
    
    The original fix for this class of issues was crrev.com/c/2785844. This
    change extends those fixes to depot_tools, which was missed last year.
    This change also updates how PyLint is called by further limiting the
    number of jobs to the number of files being processed divided by 10.
    This is because there is a significant cost to creating PyLint
    subprocesses - each takes about 0.5 s on my test machine. So there needs
    to be enough parallelism to justify this.
    
    Patches for PyLint and a bug for cpython are planned.
    
    This will stop PyLint from hanging during presubmits on many-core
    machines. The command used to reproduce the hangs and validate the fix
    was:
    
      git cl presubmit -v --force --files "chrome/test/mini_installer/*.py"
    
    Prior to this change this command would use (on my many-core test
    machine) 96 processes and would hang. How it uses just two processes
    because there are only 16 files to analyze.
    
    Output before:
      Pylint (16 files using ['--disable=cyclic-import'] on 96 cores)
    Output after:
      Pylint (16 files using ['--disable=cyclic-import'] on 2 processes)
    
    This is actually not quite true because the hang would prevent the
    old message from being displayed.
    
    Bug: 1190269, 1336854
    Change-Id: Ie82baf91df4364a92eb664a00cf9daf167e0a548
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3711282Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
    Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
    8254f06b
presubmit_support.py 73.3 KB