PowerTrace is a comprehensive framework designed for power measurement, attribution, and control of CPU-bound workloads and benchmarks. It provides tools for:
- Benchmarking: Running various benchmarks and collecting performance data.
- Power Measurement & Estimation: Tools to measure and estimate power consumption.
- Power Attribution: Attributing power usage to specific components or processes.
- Power Control: Implementing power capping and management strategies.
- Power Prediction: Predicting power characteristics.
Before setting up PowerTrace, ensure your system meets the following requirements. Carefully follow each step to avoid common setup issues.
- Ubuntu 22.04 LTS or newer (or a compatible Debian-based distribution).
- Kernel: Linux kernel with cgroup v2 enabled and
cpuset,cpucontrollers available.
PowerTrace relies heavily on cgroup v2. To verify if your system is using cgroup v2, run the following command:
mount | grep cgroupYou should see output similar to this, indicating cgroup2 is mounted:
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
If you see cgroup (without the 2) or no cgroup2 entry, your system might be using cgroup v1 or a hybrid mode. PowerTrace is designed for cgroup v2. Consult your distribution's documentation on how to enable cgroup v2 if it's not active.
sudoaccess is required for installation and cgroup setup.
- At least two CPU sockets are highly recommended for optimal cgroup control setup, especially if you plan to use the
cgroup_ctl_setup.shscript for workload isolation. While PowerTrace can function on single-socket systems, some advanced features related to CPU core isolation across sockets will not be available.
Follow these steps precisely to set up PowerTrace on your system.
First, clone the PowerTrace repository to your local machine:
git clone https://github.com/your-repo/PowerTrace.git # Replace with the actual repository URL
cd PowerTraceExecute the dependencies.sh script to install all necessary packages and Python libraries. This script requires sudo privileges.
Important: This step will install system-wide packages and Python libraries. Ensure you have an active internet connection.
sudo ./dependencies.shThis script will:
- Add a PPA for
stress-ng. - Update package lists.
- Install core system utilities:
python3-pip,luarocks,docker.io,memtier-benchmark,bison,flex,redis,libevent-dev,libssl-dev,cgroup-tools. - Install Linux performance tools:
linux-tools-common,linux-tools-generic,linux-tools-$(uname -r). - Install benchmarking and system utilities:
stress-ng,htop,sysbench,ffmpeg,powercap-utils,ipmitool. - Install Docker Compose.
- Install LuaSocket.
- Install Python libraries listed in
requirements.txt(e.g.,psutil,numpy,pandas,tensorflow,scikit-learn, etc.).
Troubleshooting dependencies.sh:
add-apt-repository: command not found: Installsoftware-properties-common:sudo apt install software-properties-common.Unable to locate package linux-tools-$(uname -r): Ensure your kernel headers are installed. Trysudo apt install linux-headers-$(uname -r). If the issue persists, your kernel version might not have pre-built tools available. You may need to compile them or use a different kernel.E: Unable to locate package ...: Double-check your internet connection and ensure youraptsources are up-to-date (sudo apt update). Some packages might have slightly different names on older Ubuntu versions.
PowerTrace heavily relies on cgroups for resource management and isolation. You need to initialize and configure them.
Critical Warning: These steps require sudo and will modify system-level cgroup configurations. It's highly recommended to reboot your system after these steps to ensure cgroup settings are applied correctly and to avoid unexpected behavior.
Run the cgroup_init.sh script to create the necessary cgroup hierarchies and enable controllers.
sudo ./scripts/cgroup_init.shThis script will:
- Ensure
cpusetandcpucontrollers are enabled at the root cgroup level. - Create
/sys/fs/cgroup/userand/sys/fs/cgroup/criticalcgroups. - Set
cpu.maxto unlimited for bothuserandcriticalcgroups. - Assign all available CPUs to both
userandcriticalcgroups.
Troubleshooting cgroup_init.sh:
rmdir: failed to remove '...': Device or resource busy: This is normal if the cgroups already exist and are in use. The script will attempt to recreate them.echo: write error: Operation not permitted: This usually means the cgroup controller is not enabled or the cgroup filesystem is not mounted correctly as cgroup v2. Re-verify your cgroup v2 setup (see Prerequisites).
If your system has multiple CPU sockets (at least two), you can use cgroup_ctl_setup.sh to assign specific CPU cores from different sockets to the user and critical cgroups. This is crucial for isolating workloads and preventing interference.
sudo ./scripts/cgroup_ctl_setup.shThis script will:
- Auto-detect CPU sockets and assign CPUs from the first socket to the
criticalcgroup and CPUs from the second socket to theusercgroup. - Output the CPU assignments for verification.
Note: If you do not have at least two CPU sockets, this script will exit with an error message. The cgroup_init.sh script provides a basic cgroup setup that will still allow PowerTrace to function, but without socket-level isolation.
Troubleshooting cgroup_ctl_setup.sh:
At least 2 CPU sockets are required.: This means your system does not have enough physical CPU sockets for this script's intended purpose. You can still proceed with PowerTrace, but without this specific CPU isolation.
After configuring cgroups, it is essential to reboot your system to ensure all changes are properly applied and the cgroup hierarchy is stable.
sudo rebootPowerTrace provides various scripts for running benchmarks, collecting data, and analyzing power.
The run-bench-*.sh scripts in the root directory are the primary entry points for executing benchmarks and power experiments.
run-bench.sh: General script for running benchmarks.run-bench-attr.sh: For running benchmarks with power attribution.run-bench-cap.sh: For running benchmarks with power capping.run-bench-consolidated.sh: For consolidated power measurements.run-bench-initial.sh: For initial benchmark runs.run-bench-once.sh: For single benchmark runs.run-bench-predict-single.sh: For single prediction runs.run-bench-qos-powercap.sh: For QoS-aware power capping benchmarks.
You can explore these scripts to understand their specific functionalities and parameters. It's recommended to open them in a text editor and read any comments or usage instructions within the scripts themselves.
attribution/: Contains scripts for attributing power consumption to different system components or processes.benchmark-suites/: Houses various benchmark suites like DeathStarBench, filebench, ML-training, and redis.control/: Includes scripts and configurations for power capping and control mechanisms.data/: Likely stores raw or processed data collected during experiments.estimation/: Contains scripts for estimating CPU and total system power.MLs/: May contain machine learning models or related scripts for power/performance prediction.perf-aware/: Scripts related to performance-aware power management.predxnd/: Tools for power and performance prediction, including cgroup monitoring.results/: Various subdirectories for storing and parsing experimental results.scripts/: Utility scripts for cgroup management, data collection, and result parsing.test/: Contains various test workloads and scripts.train_test/: Scripts for training and testing power models.
A typical workflow might involve:
- Selecting a Benchmark: Choose a benchmark from
benchmark-suites/ortest/. - Running the Benchmark: Use an appropriate
run-bench-*.shscript, potentially modifying it to suit your experimental needs (e.g., setting power caps, specifying attribution methods). - Collecting Data: The
run-bench-*.shscripts often integrate with tools inestimation/orpredxnd/to collect power and performance metrics. - Analyzing Results: Use the
parse.pyor other parsing scripts in theresults/directories to process the collected data and generate reports.
For detailed usage of specific scripts, it is recommended to examine their contents and any inline comments.
(Add information on how to contribute if this is an open-source project)
(Add license information)