Skip to content

misc: Add distributed SMT perf runner#936

Merged
jensen-yan merged 6 commits into
xs-devfrom
codex/gem5-distributed-smt-ci
Jul 7, 2026
Merged

misc: Add distributed SMT perf runner#936
jensen-yan merged 6 commits into
xs-devfrom
codex/gem5-distributed-smt-ci

Conversation

@jensen-yan

@jensen-yan jensen-yan commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Motivation

SMT SPEC06 perf CI currently runs all checkpoints on one self-hosted runner through local GNU parallel. SMT slices have noticeably longer wall time, so the feedback loop can be much slower than non-SMT even when there are idle NFS-visible machines.

Approach

  • Add util/xs_scripts/distributed_sim.py, a GEM5-specific distributed launcher that preserves the existing spec_all/<workload>/m5out/stats.txt archive layout.
  • Keep parallel_sim.sh as the default reusable-workflow path when distributed_servers is empty.
  • Enable the distributed path for SMT perf callers with node020-node039, 32 jobs/server, and a lightweight idle-CPU probe.
  • Expose distributed inputs in manual-perf.yml so the path can be tested and tuned before replacing the old local parallel path.

Validation

  • python3 -m py_compile util/xs_scripts/distributed_sim.py
  • YAML load check for touched workflow files
  • Remote idle-probe dry run on node020-node021
  • Prior local/remote 1M-tick SMT mcf smoke wrote completed and m5out/stats.txt in the existing layout

Rollout

This keeps both paths. Existing non-SMT perf workflows continue to use parallel_sim.sh; SMT CI and manual perf can exercise the distributed path first.

Summary by CodeRabbit

  • New Features
    • Added an optional distributed execution mode for performance benchmarks, including a scheduler that runs checkpoint workloads across multiple SSH-reachable servers.
    • Extended the performance workflows with new configuration inputs to control the server pool and per-server concurrency for both template-based and manual runs.
    • When enabled, the run metadata now includes the distributed configuration details and the scheduler can optionally select servers based on remote CPU idleness.

Change-Id: Ib4699ddad80458f69d9b1907bb78446f38ca14b4
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds distributed gem5 benchmark execution across workflow callers and the reusable performance template, plus a new Python scheduler that launches checkpoint jobs locally or over SSH with idle-capacity probing, marker-based completion, and retry handling.

Changes

Distributed simulation support

Layer / File(s) Summary
Core data model and CLI parsing
util/xs_scripts/distributed_sim.py
Defines scheduling constants, dataclasses, and CLI parsing for server selection, workload limits, idle probing, SSH dispatch, environment overrides, and gem5 config/script resolution.
Job script generation and launch
util/xs_scripts/distributed_sim.py
Implements job launcher logic, SSH command construction, dispatch-host wrapping, and remote idle-CPU probing and filtering.
Polling, marker lifecycle, and retry logic
util/xs_scripts/distributed_sim.py
Appends launcher output to logs, waits for completion markers, detects marker-based failures, and schedules retries for specific remote failure cases.
Scheduling loop and entry point
util/xs_scripts/distributed_sim.py
Implements interrupt-safe shutdown, server selection, the main scheduling loop, and CLI-entry wiring for dry-run, workload filtering, and final exit handling.
Workflow template distributed branching
.github/workflows/gem5-perf-template.yml
Adds distributed workflow inputs, resolves the shared server pool and dispatch host, exports resolved distributed values, extends metadata, and switches execution between distributed and local runners.
Workflow callers
.github/workflows/gem5-ideal-btb-perf-weekly.yml, .github/workflows/gem5-smt-spec06-0.3c.yml, .github/workflows/manual-perf.yml
Passes distributed server and concurrency settings through the weekly, SMT, and manual performance workflows.

Estimated code review effort: 4 (Complex) | ~60 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a distributed SMT performance runner.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/gem5-distributed-smt-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 0.4738 -
This PR 0.4738 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

1 similar comment
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 0.4738 -
This PR 0.4738 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@jensen-yan jensen-yan force-pushed the codex/gem5-distributed-smt-ci branch from 34944b7 to 6bdbf4e Compare July 1, 2026 05:22
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 0.4738 -
This PR 0.4738 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@jensen-yan jensen-yan force-pushed the codex/gem5-distributed-smt-ci branch from 6bdbf4e to 04a418c Compare July 1, 2026 05:36
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 0.4738 -
This PR 0.4738 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

Change-Id: I99bc34f6853ecff73f44c9cfa60a20d4be3a04b3
@jensen-yan jensen-yan force-pushed the codex/gem5-distributed-smt-ci branch from 04a418c to 1f52a08 Compare July 1, 2026 05:56
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 0.4738 -
This PR 0.4738 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

Change-Id: If37627210f930f67ee11981cb09d1a34b5e83a83
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3162 -
This PR 2.3162 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@jensen-yan jensen-yan marked this pull request as ready for review July 1, 2026 09:53
Copilot AI review requested due to automatic review settings July 1, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a distributed checkpoint runner for gem5 perf CI to reduce SMT SPEC06 wall time by spreading workload launches across a list of SSH-reachable servers, while preserving the existing spec_all/<workload>/m5out/stats.txt archive layout.

Changes:

  • Introduce util/xs_scripts/distributed_sim.py to schedule and launch workloads across local or remote servers via SSH, with status markers and retry handling.
  • Extend the reusable perf workflow to optionally switch from parallel_sim.sh to the distributed runner when distributed_servers is provided.
  • Expose distributed-runner knobs in manual-perf.yml and enable distributed execution for SMT perf workflows.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
util/xs_scripts/distributed_sim.py New distributed launcher that mirrors parallel_sim.sh output layout and supports SSH dispatch + idle probing.
.github/workflows/gem5-perf-template.yml Adds distributed-runner inputs and conditionally invokes distributed_sim.py instead of parallel_sim.sh.
.github/workflows/manual-perf.yml Adds workflow_dispatch inputs to pass distributed-runner parameters into the reusable perf workflow.
.github/workflows/gem5-smt-spec06-0.3c.yml Enables the distributed path for SMT SPEC06 perf CI with a concrete server list and dispatch host.
.github/workflows/gem5-ideal-btb-perf-weekly.yml Enables the distributed path for the weekly SMT perf job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread util/xs_scripts/distributed_sim.py
Comment thread util/xs_scripts/distributed_sim.py
Comment thread .github/workflows/manual-perf.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8610ef4e3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread util/xs_scripts/distributed_sim.py Outdated
Comment thread util/xs_scripts/distributed_sim.py Outdated
Change-Id: I38c235ff3688652765ea804d8f17973e113662ee

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 963a547952

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread util/xs_scripts/distributed_sim.py
@jensen-yan jensen-yan added the perf-align Trigger Align BTB performance CI label Jul 1, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/gem5-perf-template.yml:
- Around line 215-222: The shell script in the workflow is directly
interpolating untrusted GitHub Actions expressions into `run:` text, which
creates a template-injection risk on the self-hosted runner. Move the
distributed-run values behind `env:` indirection first, like the existing
`CONFIG_PATH_INPUT` pattern, and have the script read from those environment
variables instead of using `${{ inputs.distributed_servers }}`, `${{
steps.archive.outputs.distributed_servers }}`, `${{
inputs.distributed_jobs_per_server }}`, `${{
steps.archive.outputs.distributed_require_idle_cpus }}`, and `${{
steps.archive.outputs.distributed_dispatch_host }}` inline. Update the affected
distributed setup and archive steps so the `run` block only consumes safe shell
variables, keeping the logic in the relevant workflow jobs consistent with the
guarded pattern already used elsewhere.

In `@util/xs_scripts/distributed_sim.py`:
- Around line 263-313: The server parsing in parse_server_list currently accepts
tokens that begin with “-”, which can later be interpreted by ssh as options;
update this parser to reject any server token or expanded range entry whose
final target starts with “-”, raising a clear ValueError instead. Also add the
same validation for args.dispatch_host before it is passed into
wrap_with_dispatch_host so both server lists and dispatch hosts are protected.
- Around line 854-860: Clear stale non-completed markers before each launch
attempt so SSH failures can still be retried. Update the launch logic around the
`has_any_marker()` / retry check in `distributed_sim.py` to remove stale `abort`
and `running` markers after the completed-skip path but before deciding whether
`result == 255` is retryable. Apply the same cleanup in the second launch path
referenced by the other affected block so both attempt flows behave
consistently.
- Around line 926-987: The scheduler loop in distributed_sim.py can launch jobs
before all checkpoints are validated, so a later find_checkpoint() failure
leaves already-started work running. Pre-resolve the checkpoints for all
selected workloads before entering the launch loop, using the same checkpoint
lookup logic currently done around find_checkpoint() and build_gem5_command(),
and only start scheduling/launching jobs after every required checkpoint has
been found successfully. Also apply the same pre-resolution approach to the
retry/launch path referenced in the later block so both code paths fail fast
before any job is dispatched.
- Around line 399-407: Validate env override keys in parse_env_overrides before
they reach the shell export path, since malformed keys are currently inserted
unquoted into export statements. Update parse_env_overrides to reject any key
that is not a valid shell variable name and apply the same validation anywhere
the overrides are rendered into exports in the distributed_sim script. Use the
existing parse_env_overrides helper and the export-emitting code near the later
override handling to keep invalid keys from becoming shell syntax.
- Around line 467-480: The shell script built in distributed_sim.py is still
vulnerable because shlex.quote() results are wrapped inside double-quoted echo
strings in the workload/checkpoint/command logging block. Update the script
generation in that return block so each logged value is emitted as a single
safely quoted shell argument without outer double quotes, especially for the
echo lines in the distributed_sim command template.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e188f6ca-67e9-4576-8403-c5fe1e119459

📥 Commits

Reviewing files that changed from the base of the PR and between 0fd0540 and 963a547.

📒 Files selected for processing (5)
  • .github/workflows/gem5-ideal-btb-perf-weekly.yml
  • .github/workflows/gem5-perf-template.yml
  • .github/workflows/gem5-smt-spec06-0.3c.yml
  • .github/workflows/manual-perf.yml
  • util/xs_scripts/distributed_sim.py

Comment thread .github/workflows/gem5-perf-template.yml Outdated
Comment thread util/xs_scripts/distributed_sim.py
Comment thread util/xs_scripts/distributed_sim.py
Comment thread util/xs_scripts/distributed_sim.py
Comment thread util/xs_scripts/distributed_sim.py
Comment thread util/xs_scripts/distributed_sim.py
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3162 -
This PR 2.3162 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@XiangShanRobot

Copy link
Copy Markdown

[Generated by GEM5 Performance Robot]
commit: 963a547
workflow: gem5 Align BTB Performance Test(0.3c)

Align BTB Performance

Overall Score

PR Master Diff(%)
Score 18.74 18.74 0.00

Change-Id: I71dc74f9cb1b60e9250be38e4ac0a9a1ea228919

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c682683a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread util/xs_scripts/distributed_sim.py
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3162 -
This PR 2.3162 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

Change-Id: I75266bf1714f07538ae5cb63bf4b594e210c3b9a

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 407881e34c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread util/xs_scripts/distributed_sim.py
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Coremark Smoke Test Results

Branch IPC Change
Base (xs-dev) 2.3162 -
This PR 2.3162 ➡️ 0.0000 (0.00%)

✅ Difftest smoke test passed!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
util/xs_scripts/distributed_sim.py (1)

1170-1177: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Return a non-zero exit code when any workload fails.

failed is counted but ignored, so the GitHub workflow can pass even when distributed jobs failed.

Proposed fix
-    return 0
+    return 1 if failed else 0
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@util/xs_scripts/distributed_sim.py` around lines 1170 - 1177, The summary in
distributed_sim.py currently reports failed workloads but still returns success,
so update the final exit path in the main summary/return block to propagate
failures by returning a non-zero code whenever failed is greater than zero. Use
the existing summary variables in the same scope (failed, completed,
launch_attempts, retry_attempts) and keep the successful 0 return only for the
all-workloads-passed case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@util/xs_scripts/distributed_sim.py`:
- Around line 502-513: The script built in distributed_sim.py does not fail fast
when preparing the job work directory, so a bad mkdir, cd, marker cleanup, or
touch can still let GEM5 continue in the wrong place. Update the shell prologue
returned by the work-dir setup helper to exit on command failures as well as
unset variables, and keep the directory preparation steps in the same block so
failures in mkdir, cd, rm -f abort completed, or touch running stop execution
immediately. Use the existing work_dir setup code and the shell script template
around shell_exports(env) as the place to apply the fix.

---

Outside diff comments:
In `@util/xs_scripts/distributed_sim.py`:
- Around line 1170-1177: The summary in distributed_sim.py currently reports
failed workloads but still returns success, so update the final exit path in the
main summary/return block to propagate failures by returning a non-zero code
whenever failed is greater than zero. Use the existing summary variables in the
same scope (failed, completed, launch_attempts, retry_attempts) and keep the
successful 0 return only for the all-workloads-passed case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14fdf7e7-49c7-404e-b2df-50a89dbdcee8

📥 Commits

Reviewing files that changed from the base of the PR and between 0c68268 and 407881e.

📒 Files selected for processing (3)
  • .github/workflows/gem5-perf-template.yml
  • .github/workflows/manual-perf.yml
  • util/xs_scripts/distributed_sim.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/manual-perf.yml
  • .github/workflows/gem5-perf-template.yml

Comment thread util/xs_scripts/distributed_sim.py
@jensen-yan jensen-yan merged commit 3c4cdea into xs-dev Jul 7, 2026
3 of 4 checks passed
@jensen-yan jensen-yan deleted the codex/gem5-distributed-smt-ci branch July 7, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-align Trigger Align BTB performance CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants