Skip to content

Commit aaaa1a4

Browse files
committed
refactor: remove code duplication and enforce fail-fast for missing taskset
Addresses PR review by removing the fallback unpinned execution logic when taskset is not installed. The script now fails immediately with a clear error message, preventing code duplication.
1 parent 9a3e981 commit aaaa1a4

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

scripts/import_profiler/profiler.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,10 @@ def run_master(iterations, target_module, cpu=0, csv_path=None, clear_cache=True
157157
loaded_modules_val = data["loaded_modules"]
158158
loaded_lines_val = data["loaded_lines"]
159159
except FileNotFoundError as e:
160-
if cpu != NO_CPU_PINNING and i == 0:
161-
print("WARNING: taskset CPU pinning is not available. Falling back to unpinned execution...")
162-
cpu = NO_CPU_PINNING
163-
cmd = python_exe + [__file__, "--worker", f"--module={target_module}"]
164-
try:
165-
data = _run_worker_and_parse(cmd)
166-
times.append(data["time_ms"])
167-
memories.append(data["peak_ram_mb"])
168-
rss_memories.append(data["rss_ram_mb"])
169-
loaded_modules_val = data["loaded_modules"]
170-
loaded_lines_val = data["loaded_lines"]
171-
except subprocess.CalledProcessError as err:
172-
print(f"Error in worker process:\n{err.stderr}", file=sys.stderr)
173-
raise err
174-
else:
175-
raise e
160+
if cpu != NO_CPU_PINNING and cmd and cmd[0] == "taskset":
161+
print("ERROR: 'taskset' command not found. CPU pinning is enabled but taskset is not installed. "
162+
"Install taskset or disable pinning by passing --cpu=-1.", file=sys.stderr)
163+
raise e
176164
except subprocess.CalledProcessError as e:
177165
print(f"Error in worker process:\n{e.stderr}", file=sys.stderr)
178166
raise e

0 commit comments

Comments
 (0)