From 3e9de33fa693a14e05143346646b2f87993cca4d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 4 Dec 2022 14:02:45 -0800 Subject: Added --experimental=tm_v2 which switches to use Andrew Morrow's new ParallelJob implementation. WHich should scale much better for highly parallel builds --- CHANGES.txt | 2 ++ RELEASE.txt | 3 +++ SCons/Script/SConsOptions.py | 4 ++-- SCons/Taskmaster/Job.py | 7 ++++--- doc/man/scons.xml | 5 +++-- test/option/taskmastertrace.py | 3 +-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 5e7f6d4..8818eed 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -32,6 +32,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Moved rpm and debian directories under packaging - Added logic to help packagers enable reproducible builds into packaging/etc/. Please read packaging/etc/README.txt if you are interested. + - Added --experimental=tm_v2, which enables Andrew Morrow's new NewParallel Job implementation. + This should scale much better for highly parallel builds. From Dan Mezhiborsky: - Add newline to end of compilation db (compile_commands.json). diff --git a/RELEASE.txt b/RELEASE.txt index 801062a..c7e7c4d 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -24,6 +24,9 @@ NEW FUNCTIONALITY - Added ValidateOptions() which will check that all command line options are in either those specified by SCons itself, or by AddOption() in SConstruct/SConscript. It should not be called until all AddOption() calls are completed. Resolves Issue #4187 +- Added --experimental=tm_v2, which enables Andrew Morrow's NewParallel Job implementation. + This should scale much better for highly parallel builds. + DEPRECATED FUNCTIONALITY ------------------------ diff --git a/SCons/Script/SConsOptions.py b/SCons/Script/SConsOptions.py index f3b4708..a3e3ea8 100644 --- a/SCons/Script/SConsOptions.py +++ b/SCons/Script/SConsOptions.py @@ -40,7 +40,7 @@ SUPPRESS_HELP = optparse.SUPPRESS_HELP diskcheck_all = SCons.Node.FS.diskcheck_types() -experimental_features = {'warp_speed', 'transporter', 'ninja'} +experimental_features = {'warp_speed', 'transporter', 'ninja', 'tm_v2'} def diskcheck_convert(value): @@ -65,7 +65,7 @@ def diskcheck_convert(value): class SConsValues(optparse.Values): """ Holder class for uniform access to SCons options, regardless - of whether or not they can be set on the command line or in the + of whether they can be set on the command line or in the SConscript files (using the SetOption() function). A SCons option value can originate three different ways: diff --git a/SCons/Taskmaster/Job.py b/SCons/Taskmaster/Job.py index 853fe63..ef10df5 100644 --- a/SCons/Taskmaster/Job.py +++ b/SCons/Taskmaster/Job.py @@ -40,6 +40,7 @@ from enum import Enum import SCons.Errors import SCons.Warnings + # The default stack size (in kilobytes) of the threads used to execute # jobs in parallel. # @@ -53,8 +54,6 @@ default_stack_size = 256 interrupt_msg = 'Build interrupted.' -USE_NEW_PARALLEL = os.environ.get('SCONS_NEW_PARALLEL', False) - class InterruptState: def __init__(self): self.interrupted = False @@ -84,6 +83,7 @@ class Jobs: class can't do it, it gets reset to 1. Wrapping interfaces that care should check the value of 'num_jobs' after initialization. """ + from SCons.Script import GetOption self.job = None if num > 1: @@ -92,10 +92,11 @@ class Jobs: stack_size = default_stack_size try: - if USE_NEW_PARALLEL: + if 'tm_v2' in GetOption('experimental'): self.job = NewParallel(taskmaster, num, stack_size) else: self.job = LegacyParallel(taskmaster, num, stack_size) + self.num_jobs = num except NameError: pass diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 0278d87..4f1987d 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -1125,11 +1125,12 @@ the mechanisms in the specified order. the special tokens all or none. A comma-separated string can be used to select multiple features. The default setting is none. - Current available features are: ninja. + Current available features are: ninja, tm_v2. No Support offered for any features or tools enabled by this flag. - Available since &scons; 4.2. + ninjaAvailable since &scons; 4.2. + tm_v2Available since &scons; 4.4.1 diff --git a/test/option/taskmastertrace.py b/test/option/taskmastertrace.py index 0e44896..f30d725 100644 --- a/test/option/taskmastertrace.py +++ b/test/option/taskmastertrace.py @@ -55,8 +55,7 @@ test.run(arguments='--taskmastertrace=trace.out .', stdout=expect_stdout) test.must_match_file('trace.out', 'taskmaster_expected_file_1.txt', mode='r') # Test NewParallel Job implementation -os.environ['SCONS_NEW_PARALLEL'] = "1" -test.run(arguments='-j 2 --taskmastertrace=new_parallel_trace.out .') +test.run(arguments='-j 2 --experimental=tm_v2 --taskmastertrace=new_parallel_trace.out .') new_trace = test.read('new_parallel_trace.out', mode='r') thread_id = re.compile(r'\[Thread:\d+\]') -- cgit v0.12