|
5 | 5 | import subprocess |
6 | 6 | import yaml |
7 | 7 | import signal |
8 | | -import tempfile |
9 | 8 | from loguru import logger |
10 | 9 |
|
11 | 10 | from typing import List |
@@ -217,29 +216,23 @@ def stop_profiling_query_engine_pids(qe_perf_procs, store: bool): |
217 | 216 | logger.debug("Stopped profiling for query engine pids") |
218 | 217 |
|
219 | 218 |
|
220 | | -def archive_query_engine_perf_data(experiment_output_dir): |
| 219 | +def convert_query_engine_perf_data(experiment_output_dir): |
221 | 220 | qe_profiles_dir = os.path.join(experiment_output_dir, "query_engine_profiles") |
222 | 221 | data_files = [ |
223 | 222 | os.path.join(qe_profiles_dir, f) |
224 | 223 | for f in os.listdir(qe_profiles_dir) |
225 | 224 | if f.startswith("perf_") and f.endswith(".data") |
226 | 225 | ] |
227 | 226 | for data_file in data_files: |
228 | | - archive_file = f"{data_file}.tar.bz2" |
229 | | - logger.debug(f"Archiving {data_file} to {archive_file}") |
230 | | - with tempfile.TemporaryDirectory(dir=qe_profiles_dir) as archive_dir: |
| 227 | + script_file = data_file.replace(".data", ".script") |
| 228 | + logger.debug(f"Converting {data_file} to {script_file}") |
| 229 | + with open(script_file, "w") as script_output: |
231 | 230 | subprocess.run( |
232 | | - ["perf", "archive", data_file], |
233 | | - cwd=archive_dir, |
| 231 | + ["perf", "script", "--header", "-i", data_file], |
| 232 | + stdout=script_output, |
234 | 233 | check=True, |
235 | 234 | ) |
236 | | - generated_archive = os.path.join(archive_dir, "perf.data.tar.bz2") |
237 | | - if not os.path.isfile(generated_archive): |
238 | | - raise RuntimeError( |
239 | | - f"perf archive did not produce expected file: {generated_archive}" |
240 | | - ) |
241 | | - os.replace(generated_archive, archive_file) |
242 | | - logger.debug(f"Finished archiving {data_file}") |
| 235 | + logger.debug(f"Finished converting {data_file}") |
243 | 236 |
|
244 | 237 |
|
245 | 238 | # TODO Provide some way of specifying which hooks will be used |
@@ -442,7 +435,7 @@ def main(args): |
442 | 435 | if qe_flamegraph_procs: |
443 | 436 | logger.debug("Stopping profiling for query engine pids") |
444 | 437 | stop_profiling_query_engine_pids(qe_flamegraph_procs, store=True) |
445 | | - archive_query_engine_perf_data(args.experiment_output_dir) |
| 438 | + convert_query_engine_perf_data(args.experiment_output_dir) |
446 | 439 |
|
447 | 440 | logger.debug("Stopping process monitors") |
448 | 441 | monitor_info = process_monitor.stop_monitor(monitor, control_pipe, monitor_pipe) |
|
0 commit comments