βοΈ Pipeline StagesΒΆ
The Energy Pipeline is organized into three types of stages, each responsible for a part of the commit processing workflow.
Each stage operates on a shared context dictionary that allows reading and writing of state and data.
π§± Stage CategoriesΒΆ
Stage Type |
Runs When? |
Purpose |
|---|---|---|
Pre-Stages |
Once per batch (before any commits) |
Verify system setup before running any commit |
Pre-Test Stages |
Once per unique commit (in parallel) |
Prepare the environment and build the commit |
Batch Stages |
For every run of every commit (N times) |
Run test and measure energy consumption |
π§© Stage InterfaceΒΆ
All stages implement the same interface via an abstract base class:
class PipelineStage(ABC):
@abstractmethod
def run(self, context: dict[str, Any]) -> None:
...
π Pre-Stages (run once per batch)ΒΆ
These are safety checks before anything is processed.
β
VerifyPerfStageΒΆ
Verifies
perfaccess permissions.Logs system state and capabilities.
Aborts the pipeline if setup is incorrect.
ποΈ Pre-Test Stages (run once per commit, in parallel)ΒΆ
These prepare each commit for measurement. They run concurrently to speed up processing.
π CopyDirectoryStageΒΆ
Copies the repository to a fresh directory for this commit.
Ensures isolation between batches.
π· SetDirectoryStageΒΆ
Sets the working directory in context to the correct copied repo path.
π² CheckoutStageΒΆ
Checks out the specified commit in the local copy of the repo.
β JavaSetupStageΒΆ
Detects Java version from Maven
pom.xml.Sets environment variables to match that version.
π¨ BuildStageΒΆ
Builds the project using the test command.
Marks the commit as
build_failedin context if it fails.
π Batch Stages (run for each execution of each commit)ΒΆ
These stages are run num_runs * num_repeats times per commit.
π‘οΈ TemperatureCheckStageΒΆ
Monitors CPU temperature.
Waits or aborts if too hot (to avoid noise in energy readings).
π SetDirectoryStage (again)ΒΆ
Redundant set for safety in parallel runs.
β JavaSetupStage (again)ΒΆ
Re-applies Java settings to ensure consistent environment.
β‘ MeasureEnergyStageΒΆ
Runs the test command.
Collects energy metrics from RAPL (e.g.,
energy-pkg,energy-core,energy-gpu).Saves them to a result file with the commit hash.
π§Ή PostTestStageΒΆ
Cleans up temporary files or resets settings if needed.
π§ Execution Flow SummaryΒΆ
[Measure Command]
βββ Batches Commits (X batches of Y commits)
βββ For Each Batch:
βββ Run Pre-Stages
βββ For Each Unique Commit in Parallel:
β βββ Pre-Test Stages (checkout, build, etc.)
βββ For Each Commit N times:
βββ Batch Stages (test, measure, etc.)
β οΈ Stage AbortsΒΆ
Any stage can stop the pipeline by setting:
context["abort_pipeline"] = True
Or, mark that a commit should be skipped due to a failed build:
context["build_failed"] = True
β Adding New StagesΒΆ
Create a new class implementing
PipelineStage.Add it to one of these lists in
main.py:pre_stages = [...] pre_test_stages = [...] batch_stages = [...]
The pipeline will pick it up automatically.
π‘ Example: Writing a Custom StageΒΆ
class LogCommitStage(PipelineStage):
def run(self, context: dict[str, Any]) -> None:
commit = context.get("commit")
print(f"Processing commit: {commit}")
Then add to batch_stages:
batch_stages = [
TemperatureCheckStage(),
LogCommitStage(),
MeasureEnergyStage(),
]