|
| 1 | +# Architecture |
| 2 | + |
| 3 | +## Execution flow |
| 4 | + |
| 5 | +This diagram shows how the CLI commands, project config, orchestrator (with providers), and executors interact during a benchmark run. |
| 6 | + |
| 7 | +```mermaid |
| 8 | +graph TD |
| 9 | + subgraph "1. CLI Commands" |
| 10 | + RUN["codspeed run <command>"] |
| 11 | + EXEC["codspeed exec <command>"] |
| 12 | + end |
| 13 | +
|
| 14 | + subgraph "2. Config" |
| 15 | + PROJ_CFG["ProjectConfig<br/>(codspeed.yaml in repo)<br/>benchmark targets, defaults"] |
| 16 | + MERGER["ConfigMerger<br/>CLI args > project config > defaults"] |
| 17 | + end |
| 18 | +
|
| 19 | + subgraph "3. Orchestrator" |
| 20 | + ORCH_CFG["OrchestratorConfig<br/>targets, modes, upload settings"] |
| 21 | + ORCH["Orchestrator"] |
| 22 | +
|
| 23 | + PROVIDER{" "} |
| 24 | + LOCAL["LocalProvider"] |
| 25 | + CI["CI Providers<br/>(GitHub Actions, GitLab, Buildkite)"] |
| 26 | + PROVIDER_JOIN{" "} |
| 27 | +
|
| 28 | + subgraph "Executor (per mode × per target)" |
| 29 | + SETUP["1. Setup"] |
| 30 | + RUN_STEP["2. Run"] |
| 31 | + TEARDOWN["3. Teardown"] |
| 32 | + end |
| 33 | +
|
| 34 | + UPLOAD["Upload all results to CodSpeed"] |
| 35 | + end |
| 36 | +
|
| 37 | + subgraph "4. Auth" |
| 38 | + CS_CFG["CodSpeedConfig<br/>(~/.config/codspeed/config.yaml)"] |
| 39 | + OIDC["OIDC / env token"] |
| 40 | + end |
| 41 | +
|
| 42 | + %% CLI → Config → OrchestratorConfig |
| 43 | + RUN --> MERGER |
| 44 | + EXEC --> MERGER |
| 45 | + MERGER --> PROJ_CFG |
| 46 | + PROJ_CFG -->|"merged config"| ORCH_CFG |
| 47 | +
|
| 48 | + %% CLI → Orchestrator |
| 49 | + RUN -->|"single command →<br/>Entrypoint target"| ORCH_CFG |
| 50 | + RUN -->|"no command + config →<br/>Exec & Entrypoint targets"| ORCH_CFG |
| 51 | + EXEC -->|"always creates<br/>Exec target"| ORCH_CFG |
| 52 | +
|
| 53 | + %% Orchestrator init |
| 54 | + ORCH_CFG -->|"Orchestrator::new()"| ORCH |
| 55 | +
|
| 56 | + %% Provider detection |
| 57 | + ORCH -->|"auto-detect env"| PROVIDER |
| 58 | + PROVIDER --> LOCAL |
| 59 | + PROVIDER --> CI |
| 60 | +
|
| 61 | + %% Auth → Providers |
| 62 | + CS_CFG -->|"auth token"| LOCAL |
| 63 | + OIDC -->|"OIDC / env token"| CI |
| 64 | +
|
| 65 | + %% Providers → Upload |
| 66 | + LOCAL -->|"token + run metadata"| PROVIDER_JOIN{" "} |
| 67 | + CI -->|"token + run metadata"| PROVIDER_JOIN |
| 68 | + PROVIDER_JOIN --> UPLOAD |
| 69 | +
|
| 70 | + %% Orchestrator spawns executors |
| 71 | + ORCH -->|"for each target × mode:<br/>spawn executor"| SETUP |
| 72 | + SETUP --> RUN_STEP |
| 73 | + RUN_STEP --> TEARDOWN |
| 74 | +
|
| 75 | + %% All executors done → upload |
| 76 | + TEARDOWN -->|"collect results"| UPLOAD |
| 77 | +``` |
| 78 | + |
| 79 | +### Key interactions |
| 80 | + |
| 81 | +- **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. |
| 82 | +- **CLI → Orchestrator**: The merged config becomes an `OrchestratorConfig` holding all targets and modes. |
| 83 | +- **Orchestrator → Providers**: Auto-detects environment (Local vs CI). Local uses the auth token from `CodSpeedConfig`; CI providers handle OIDC tokens. |
| 84 | +- **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. |
0 commit comments