Skip to content

Commit

Permalink
1. Adding a flag to track whether any process was parallelized
Browse files Browse the repository at this point in the history
2. Track execution time for each process
3. Modify Schedule.run() to generate feedback messages based on the flag and execution time status.
  • Loading branch information
GawyWOOOHOOO committed Nov 16, 2024
1 parent e09e8d6 commit 71dc3ea
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions compiler/pash.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def main():
return_code = preprocess_and_execute_asts(input_script_path, args, input_script_arguments, shell_name)

log("-" * 40) #log end marker

if args.debug >= 1:
log("Use the '-d 1' option for detailed debugging information.")
## Return the exit code of the executed script
sys.exit(return_code)

Expand Down
29 changes: 27 additions & 2 deletions compiler/pash_compilation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def __init__(self):
self.reader_pipes_are_blocking = True
self.request_processing_start_time = 0
## TODO: Make that be a class or something

## A map that keeps mappings between proc_id and (input_ir, width, exec_time)
self.process_id_input_ir_map = {}
self.parallelized_flag = False
## This is a map from input IRs, i.e., locations in the code, to a list of process_ids
self.input_ir_to_process_id_map = {}

Expand Down Expand Up @@ -295,6 +295,11 @@ def compile_and_add(self, compiled_script_file, var_file, input_ir_file):
pass
else:
self.running_procs += 1

if ast_or_ir is not None:
compile_success = True
if run_parallel:
self.parallelized_flag = True

## Get the time before we start executing (roughly) to determine how much time this command execution will take
command_exec_start_time = datetime.now()
Expand Down Expand Up @@ -336,9 +341,19 @@ def handle_exit(self, input_cmd):
## Get the execution time
command_finish_exec_time = datetime.now()
command_start_exec_time = self.process_id_input_ir_map[process_id].get_start_exec_time()
exec_time = (command_finish_exec_time - command_start_exec_time) / timedelta(milliseconds=1)
exec_time = (command_finish_exec_time - command_start_exec_time).total_seconds()
log("Process:", process_id, "exited. Exec time was:", exec_time)
self.handle_time_measurement(process_id, exec_time)

proc_info = self.process_id_input_ir_map[process_id]
if proc_info.compiler_config.width > 1: # Check if it was parallelized
if exec_time < 1:
log(f"Process {process_id} was parallelized but had negligible execution time: {exec_time:.2f} seconds.")
else:
log(f"Process {process_id} was parallelized successfully. Execution time: {exec_time:.2f} seconds.")
else:
log(f"Process {process_id} was not parallelized. Sequential execution time: {exec_time:.2f} seconds.")

self.remove_process(process_id)
## Necessary so that Exit doesn't block
self.close_last_connection()
Expand Down Expand Up @@ -414,6 +429,16 @@ def run(self):
self.parse_and_run_cmd(input_cmd)

self.connection_manager.close()
if not self.parallelized_flag:
log("No parts of the input script were parallelized. Ensure commands are annotated for parallelization.")
elif all(
proc_info.exec_time is not None and proc_info.exec_time < 1
for proc_info in self.process_id_input_ir_map.values()
):
log("Some script fragments were parallelized, but their execution times were negligible.")
log("Consider optimizing your script to include longer-running tasks.")
else:
log("Parallelization completed successfully.")
shutdown()


Expand Down
2 changes: 2 additions & 0 deletions compiler/pash_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def compile_ir(ir_filename, compiled_script_file, args, compiler_config):
ret = None
try:
ret = compile_optimize_output_script(ir_filename, compiled_script_file, args, compiler_config)
if ret is None:
log("No parallelization opportunities detected for this script.")
except Exception as e:
log("WARNING: Exception caught:", e)
# traceback.print_exc()
Expand Down

0 comments on commit 71dc3ea

Please sign in to comment.