From afe83d3bea544e9bd74c0c73177e7f75101c4f92 Mon Sep 17 00:00:00 2001 From: Muzi Date: Mon, 6 Jul 2026 11:18:20 +0800 Subject: [PATCH] feat(trigger): add save db option --- perf_trigger/main.py | 7 +++++++ perf_trigger/modules/gcpt.py | 4 ++++ perf_trigger/modules/server.py | 9 +++++++++ perf_trigger/modules/types.py | 1 + 4 files changed, 21 insertions(+) diff --git a/perf_trigger/main.py b/perf_trigger/main.py index f28b824c..f2a85dc1 100644 --- a/perf_trigger/main.py +++ b/perf_trigger/main.py @@ -480,6 +480,7 @@ def reset_running_gcpt(self): num += 1 gcpt.stdout_path.unlink() gcpt.stderr_path.unlink() + gcpt.db_path.unlink(missing_ok=True) gcpt.result_path.rmdir() gcpt.clear_state() logging.info("Reset %d RUNNING GCPTs", num) @@ -517,6 +518,11 @@ def main(): default="", help="Path to custom constantin file path (empty for default init setting)", ) + parser.add_argument( + "--dump-db", + action="store_true", + help="Run emu with --dump-db and store simulator.db in each checkpoint result directory", + ) # report configs parser.add_argument( @@ -674,6 +680,7 @@ def main(): max_instr=args.max_instr, threads=args.threads, cst_file=cst_file, + dump_db=args.dump_db, dry_run=args.dry_run, ), ) diff --git a/perf_trigger/modules/gcpt.py b/perf_trigger/modules/gcpt.py index 2d827d77..1d70bbdd 100644 --- a/perf_trigger/modules/gcpt.py +++ b/perf_trigger/modules/gcpt.py @@ -64,6 +64,10 @@ def stdout_path(self) -> Path: def stderr_path(self) -> Path: return self.__result_path / "simulator_err.txt" + @property + def db_path(self) -> Path: + return self.__result_path / "simulator.db" + def refresh_state(self) -> "GCPT.State": if ( not self.stdout_path.exists() diff --git a/perf_trigger/modules/server.py b/perf_trigger/modules/server.py index a023b927..34523fd9 100644 --- a/perf_trigger/modules/server.py +++ b/perf_trigger/modules/server.py @@ -321,6 +321,15 @@ def run_gcpt( if emu_config.cst_file else [] ) + + ( + [ + "--dump-db", + "--db-path", + shlex.quote(str(gcpt.db_path)), + ] + if emu_config.dump_db + else [] + ) ) if emu_config.dry_run: cmd_str = " ".join(run_cmd) diff --git a/perf_trigger/modules/types.py b/perf_trigger/modules/types.py index dadcca99..1b4a3054 100644 --- a/perf_trigger/modules/types.py +++ b/perf_trigger/modules/types.py @@ -13,6 +13,7 @@ class EmuConfig: threads: int with_numactl: bool = True cst_file: Path | None = None + dump_db: bool = False dry_run: bool = False