Skip to content

Commit b520927

Browse files
committed
fix: resource runtime weighting
1 parent f3d5cc0 commit b520927

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

wfcommons/wfbench/bench.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
from logging import Logger
2222
from typing import Dict, Optional, List, Set, Tuple, Type, Union
2323

24-
from numpy import isin
25-
2624
from ..common import File, FileLink, Task, Workflow
2725

2826
from ..wfchef.wfchef_abstract_recipe import WfChefWorkflowRecipe
@@ -126,23 +124,28 @@ def create_benchmark_from_synthetic_workflow(
126124

127125
cores, lock = self._creating_lock_files(lock_files_folder)
128126

129-
max_runtime = max(task.runtime for task in self.workflow.tasks.values())
127+
task_max_runtimes = {}
128+
for task in self.workflow.tasks.values():
129+
if task.category not in task_max_runtimes or task.runtime > task_max_runtimes[task.category]:
130+
task_max_runtimes[task.category] = task.runtime
131+
max_runtime = max(runtime for runtime in task_max_runtimes.values())
132+
130133
for task in self.workflow.tasks.values():
131-
# scale argument parameters to achieve a runtime distribution
132134
runtime_factor = task.runtime / max_runtime
133-
task_percent_cpu = percent_cpu[task.category] if isinstance(percent_cpu, dict) else percent_cpu
134-
task_percent_cpu *= runtime_factor
135-
if cpu_work:
136-
task_cpu_work = cpu_work[task.category] if isinstance(cpu_work, dict) else cpu_work
137-
task_cpu_work = int(task_cpu_work * runtime_factor) if task_cpu_work else None
135+
task_runtime_factor = task.runtime / task_max_runtimes[task.category]
136+
# scale argument parameters to achieve a runtime distribution
137+
task_percent_cpu = percent_cpu[task.category] * task_runtime_factor if isinstance(percent_cpu, dict) else percent_cpu * runtime_factor
138+
if cpu_work is not None:
139+
task_cpu_work = cpu_work[task.category] * task_runtime_factor if isinstance(cpu_work, dict) else cpu_work * runtime_factor
140+
task_cpu_work = int(task_cpu_work)
138141
else:
139142
task_cpu_work = None
140-
if gpu_work:
141-
task_gpu_work = gpu_work[task.category] if isinstance(gpu_work, dict) else gpu_work
142-
task_gpu_work *= runtime_factor
143+
if gpu_work is not None:
144+
task_gpu_work = gpu_work[task.category] * task_runtime_factor if isinstance(gpu_work, dict) else gpu_work * runtime_factor
145+
task_gpu_work = int(task_gpu_work)
143146
else:
144147
task_gpu_work = None
145-
task_memory = int(mem * runtime_factor) if mem else None
148+
task_memory = mem * runtime_factor if mem else None
146149
self._set_argument_parameters(
147150
task,
148151
task_percent_cpu,
@@ -177,8 +180,8 @@ def create_benchmark_from_synthetic_workflow(
177180
f"Creating {str(file_path)} ({file.size} bytes) ... file {i+1} out of {len(workflow_input_files)}",
178181
end='\r'
179182
)
180-
with open(file_path, 'wb') as fp:
181-
fp.write(os.urandom(int(file.size)))
183+
with open(save_dir.joinpath("to_create.txt"), "a+") as fp:
184+
fp.write(f"{file.name} {file.size}\n")
182185
self.logger.debug(f"Created file: {str(file_path)}")
183186

184187
self.logger.info(f"Saving benchmark workflow: {json_path}")

0 commit comments

Comments
 (0)