Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ tokio-util = "0.7.16"
md5 = "0.7.0"
base64 = "0.21.0"
async-compression = { version = "0.4.5", features = ["tokio", "gzip"] }
schemars = "0.8"
schemars = "1.2.1"
simplelog = { version = "0.12.1", default-features = false, features = [
"termcolor",
] }
Expand Down
84 changes: 84 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Architecture

## Execution flow

This diagram shows how the CLI commands, project config, orchestrator (with providers), and executors interact during a benchmark run.

```mermaid
graph TD
subgraph "1. CLI Commands"
RUN["codspeed run <command>"]
EXEC["codspeed exec <command>"]
end

subgraph "2. Config"
PROJ_CFG["ProjectConfig<br/>(codspeed.yaml in repo)<br/>benchmark targets, defaults"]
MERGER["ConfigMerger<br/>CLI args > project config > defaults"]
end

subgraph "3. Orchestrator"
ORCH_CFG["OrchestratorConfig<br/>targets, modes, upload settings"]
ORCH["Orchestrator"]

PROVIDER{" "}
LOCAL["LocalProvider"]
CI["CI Providers<br/>(GitHub Actions, GitLab, Buildkite)"]
PROVIDER_JOIN{" "}

subgraph "Executor (per mode × per target)"
SETUP["1. Setup"]
RUN_STEP["2. Run"]
TEARDOWN["3. Teardown"]
end

UPLOAD["Upload all results to CodSpeed"]
end

subgraph "4. Auth"
CS_CFG["CodSpeedConfig<br/>(~/.config/codspeed/config.yaml)"]
OIDC["OIDC / env token"]
end

%% CLI → Config → OrchestratorConfig
RUN --> MERGER
EXEC --> MERGER
MERGER --> PROJ_CFG
PROJ_CFG -->|"merged config"| ORCH_CFG

%% CLI → Orchestrator
RUN -->|"single command →<br/>Entrypoint target"| ORCH_CFG
RUN -->|"no command + config →<br/>Exec & Entrypoint targets"| ORCH_CFG
EXEC -->|"always creates<br/>Exec target"| ORCH_CFG

%% Orchestrator init
ORCH_CFG -->|"Orchestrator::new()"| ORCH

%% Provider detection
ORCH -->|"auto-detect env"| PROVIDER
PROVIDER --> LOCAL
PROVIDER --> CI

%% Auth → Providers
CS_CFG -->|"auth token"| LOCAL
OIDC -->|"OIDC / env token"| CI

%% Providers → Upload
LOCAL -->|"token + run metadata"| PROVIDER_JOIN{" "}
CI -->|"token + run metadata"| PROVIDER_JOIN
PROVIDER_JOIN --> UPLOAD

%% Orchestrator spawns executors
ORCH -->|"for each target × mode:<br/>spawn executor"| SETUP
SETUP --> RUN_STEP
RUN_STEP --> TEARDOWN

%% All executors done → upload
TEARDOWN -->|"collect results"| UPLOAD
```

### Key interactions

- **CLI → Config**: Both `run` and `exec` merge CLI args with `ProjectConfig` (CLI takes precedence). `run` can source targets from project config; `exec` always creates an `Exec` target.
- **CLI → Orchestrator**: The merged config becomes an `OrchestratorConfig` holding all targets and modes.
- **Orchestrator → Providers**: Auto-detects environment (Local vs CI). Local uses the auth token from `CodSpeedConfig`; CI providers handle OIDC tokens.
- **Orchestrator → Executors**: Groups all `Exec` targets into one exec-harness pipe command, runs each `Entrypoint` independently. For each target group, iterates over all modes, creating an `ExecutionContext` per mode and dispatching to the matching executor (`Valgrind`/`WallTime`/`Memory`). After all runs complete, uploads results with provider metadata.
Loading