From be2be99f6934c6702138826a32cdb680a75ce5b6 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 17 Nov 2022 07:36:33 -0800 Subject: Remove extraneous XXX from NewParallel logging. Added SCONS_NEW_PARALLEL shell environment variable to turn on NewParallel. This is a temporary mechanism to enable NewParallel --- SCons/Taskmaster/Job.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/SCons/Taskmaster/Job.py b/SCons/Taskmaster/Job.py index c2a825c..58f3f01 100644 --- a/SCons/Taskmaster/Job.py +++ b/SCons/Taskmaster/Job.py @@ -53,6 +53,7 @@ default_stack_size = 256 interrupt_msg = 'Build interrupted.' +USE_NEW_PARALLEL = os.environ.get('SCONS_NEW_PARALLEL', False) class InterruptState: def __init__(self): @@ -91,7 +92,10 @@ class Jobs: stack_size = default_stack_size try: - self.job = NewParallel(taskmaster, num, stack_size) + if USE_NEW_PARALLEL: + self.job = NewParallel(taskmaster, num, stack_size) + else: + self.job = LegacyParallel(taskmaster, num, stack_size) self.num_jobs = num except NameError: pass @@ -547,7 +551,7 @@ else: with self.can_search_cv: if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Gained exclusive access") + self.trace_message(f"{threading.get_ident()} Gained exclusive access") # Capture whether we got here with `task` set, # then drop our reference to the task as we are no @@ -568,19 +572,19 @@ else: # here with a completed task. if self.state == NewParallel.State.STALLED and completed_task: if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Detected stall with completed task, bypassing wait") + self.trace_message(f"{threading.get_ident()} Detected stall with completed task, bypassing wait") self.state = NewParallel.State.READY # Wait until we are neither searching nor stalled. while self.state == NewParallel.State.SEARCHING or self.state == NewParallel.State.STALLED: if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Search already in progress, waiting") + self.trace_message(f"{threading.get_ident()} Search already in progress, waiting") self.can_search_cv.wait() # If someone set the completed flag, bail. if self.state == NewParallel.State.COMPLETED: if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Completion detected, breaking from main loop") + self.trace_message(f"{threading.get_ident()} Completion detected, breaking from main loop") break # Set the searching flag to indicate that a thread @@ -588,7 +592,7 @@ else: # taskmaster work. # if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Starting search") + self.trace_message(f"{threading.get_ident()} Starting search") self.state = NewParallel.State.SEARCHING # Bulk acquire the tasks in the results queue @@ -602,7 +606,7 @@ else: results_queue, self.results_queue = self.results_queue, results_queue if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Found {len(results_queue)} completed tasks to process") + self.trace_message(f"{threading.get_ident()} Found {len(results_queue)} completed tasks to process") for (rtask, rresult) in results_queue: if rresult: rtask.executed() @@ -632,7 +636,7 @@ else: # mark the walk as complete if not. while self.state == NewParallel.State.SEARCHING: if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Searching for new tasks") + self.trace_message(f"{threading.get_ident()} Searching for new tasks") task = self.taskmaster.next_task() if task: @@ -653,13 +657,13 @@ else: else: if not task.needs_execute(): if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Found internal task") + self.trace_message(f"{threading.get_ident()} Found internal task") task.executed() task.postprocess() else: self.jobs += 1 if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Found task requiring execution") + self.trace_message(f"{threading.get_ident()} Found task requiring execution") self.state = NewParallel.State.READY self.can_search_cv.notify() @@ -678,7 +682,7 @@ else: # loop. # if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Found no task requiring execution, but have jobs: marking stalled") + self.trace_message(f"{threading.get_ident()} Found no task requiring execution, but have jobs: marking stalled") self.state = NewParallel.State.STALLED else: # We didn't find a task and there are @@ -691,7 +695,7 @@ else: # sleeping on the condvar. # if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Found no task requiring execution, and have no jobs: marking complete") + self.trace_message(f"{threading.get_ident()} Found no task requiring execution, and have no jobs: marking complete") self.state = NewParallel.State.COMPLETED self.can_search_cv.notify_all() @@ -701,7 +705,7 @@ else: # taskmaster crank in NewParallel. if task: if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Executing task") + self.trace_message(f"{threading.get_ident()} Executing task") ok = True try: if self.interrupted(): @@ -718,7 +722,7 @@ else: # postprocessing work under the taskmaster lock. # if self.trace: - self.trace_message(f"XXX {threading.get_ident()} Enqueueing executed task results") + self.trace_message(f"{threading.get_ident()} Enqueueing executed task results") with self.results_queue_lock: self.results_queue.append((task, ok)) -- cgit v0.12