Overview

License: GPL v3 Ada

PowerJoular Logo

PowerJoular is a command line software to monitor, in real time, the power consumption of software and hardware components, across multiple platforms and virtual machines.

PowerJoular is part of the Joular Project project.

PowerJoular can monitor the power consumption, in real time, of the CPU and the GPU in general, and also for a specific application (through its name or PID). It works on a Linux system and on multiple platforms (x86_64, ARM) and devices (computers, servers, Raspberry Pi, etc.).

The official website of PowerJoular is: https://www.noureddine.org/research/joular/powerjoular.

Features

  • Monitor power consumption of CPU and GPU of PC/servers
  • Monitor power consumption inside virtual machines
  • Monitor power consumption of individual applications or processes in GNU/Linux
  • Expose power consumption to the terminal and CSV files
  • Provides a systemd service (daemon) to continuously monitor power of devices
  • Low overhead (written in Ada and compiled to native code)

Cite this work

To cite our work in a research paper, please cite our paper in the 18th International Conference on Intelligent Environments (IE2022).

  • PowerJoular and JoularJX: Multi-Platform Software Power Monitoring Tools. Adel Noureddine. In the 18th International Conference on Intelligent Environments (IE2022). Biarritz, France, 2022.
@inproceedings{noureddine-ie-2022,
  title = {PowerJoular and JoularJX: Multi-Platform Software Power Monitoring Tools},
  author = {Noureddine, Adel},
  booktitle = {18th International Conference on Intelligent Environments (IE2022)},
  address = {Biarritz, France},
  year = {2022},
  month = {Jun},
  keywords = {Power Monitoring; Measurement; Power Consumption; Energy Analysis}
}

License

PowerJoular is licensed under the GNU GPL 3 license only (GPL-3.0-only).

Copyright (c) 2020-2024, Adel Noureddine, Université de Pau et des Pays de l'Adour. All rights reserved. This program and the accompanying materials are made available under the terms of the GNU General Public License v3.0 only (GPL-3.0-only) which accompanies this distribution, and is available at: https://www.gnu.org/licenses/gpl-3.0.en.html

Author : Adel Noureddine

Supported Platforms

PowerJoular monitors the following platforms:

  • PC/Servers using a RAPL supported Intel processor (since Sandy Bridge) or a RAPL supported AMD processor (since Ryzen), and optionally an Nvidia graphic card.
  • Raspberry Pi devices (multiple models) and Asus Tinker Board.
  • Inside virtual machines in all supported host platforms.

In all platforms, PowerJoular works currently only on GNU/Linux.

On PC/Servers, PowerJoular uses powercap Linux interface to read Intel RAPL (Running Average Power Limit) energy consumption.

PowerJoular supports RAPL package domain (core, including integrated graphics, and dram), and for more recent processors, we support Psys package (which covers the energy consumption of the entire SoC).

On virtual machines, PowerJoular requires two steps:

  • Installing PowerJoular itself or another power monitoring tool in the host machine. Then monitoring the virtual machine power consumption every second and writing it to a file (to be shared with the guest VM).
  • Installing PowerJoular in the guest VM, then running PowerJoular while specifying the path of the power file shared with the host and its format.

On Raspberry Pi and Asus Tinker Board, PowerJoular uses its own research-based empirical regression models to estimate the power consumption of the ARM processor.

The supported list of Raspberry Pi and Asus Tinker Board models are listed below. We support all revisions of each model lineup. However, the model is generated and trained on a specific revision (listed between brackets), and the accuracy is best on this particular revision.

We currently support the following Raspberry Pi models and Asus Tinker Board models:

  • Model Zero W (rev 1.1), for 32 bits OS
  • Model 1 B (rev 2), for 32 bits OS
  • Model 1 B+ (rev 1.2), for 32 bits OS
  • Model 2 B (rev 1.1), for 32 bits OS
  • Model 3 B (rev 1.2), for 32 bits OS
  • Model 3 B+ (rev 1.3), for 32 bits OS
  • Model 4 B (rev 1.1, and rev 1.2), for both 32 bits and 64 bits OS
  • Model 400 (rev 1.0), for 64 bits OS
  • Model 5 B (rev 1.0), for 64 bits OS
  • Asus Tinker Board (S)
PlatformSupported OSBased onSupported Architecture
Raspberry PiGNU/LinuxOur regression modelsARM
Asus Tinker BoardGNU/LinuxOur regression modelsARM
Linux PC/ServerGNU/LinuxRAPL (using powercap), Nvidia-smix86, x86_64
Linux Virtual MachineGNU/Linux guest, any hostHost's architecture (RAPL, regression models, others)x86, x86_64, ARM

Installation

PowerJoular is written in Ada and can be easily compiled, and its unique binary added to your system PATH.

Easy-to-use installation scripts are available in the installer folder. Just open the installer folder and run the appropriate file to build and/or install or uninstall the program and systemd service.

  • build-install.sh: will build (using gprbuild) and install the program binary to /usr/bin and systemd service. It requires having installed GNAT and gprbuild (see Compilation).
  • uninstall.sh: deletes the program binary and systemd service.

We also provide Debian installation packages (.deb) for a number of CPU architectures (for Debian, Ubuntu, Raspberry Pi OS, etc.).

Quick Usage

To use PowerJoular, just run the command powerjoular. On PC/servers, PowerJoular uses Intel's RAPL through the Linux powercap sysfs, and therefore requires root/sudo access on the latest Linux kernels (5.10 and newer): sudo powerjoular.

By default, the software will show the power consumption of the CPU and its utilization. The difference (increase or decrease) of power consumption from last metric will also be shown.

To monitor a specific application, just run PowerJoular with the -a appName parameter. PowerJoular is a powerful tool with many functionalities that can be accessed using specific parameters. Check the Command Line Options page for the detailed list.

Compilation

PowerJoular is written with Ada, and requires a modern Ada compiler, such as GNAT.

PowerJoular depends on the following commands and libraries for certain of its functions, but can function without them:

  • nvidia-smi: for monitoring power consumption of Nvidia graphic cards
  • Linux powercap with Intel RAPL support: for monitoring power consumption of Intel processors and SoC

On a modern GNU/Linux distribution, just install the GNAT compiler (and GPRBuild), usually available from the distribution's repositories:

Fedora:
sudo dnf install fedora-gnat-project-common gprbuild gcc-gnat

Debian, Ubuntu or Raspberry Pi OS:
sudo apt install gnat gprbuild

For other distributions, use their package manager to download the compiler, or check this article for easy instruction for various distributions, including RHEL and its clones which does not ship with Ada support in GCC.

Compilation with the GNAT compiler and GPRBuild

To compile the project, just type gprbuild if using the latest GPRBuild versions.

Or, on older versions, create the /obj folder first, then type gprbuild powerjoular.gpr.

The PowerJoular binary will be created in the obj/ folder.

By default, the project will statically link the required libraries, and therefore the PowerJoular binary can be copied to any compatible system and used as-is.

To build with dynamic linking, remove or comment the static switch in the powerjoular.gpr file, in particular these lines:

package Binder is
    for Switches ("Ada") use ("-static");
end Binder;

Compilation with the GNAT compiler only

You can also compile PowerJoular with the GNAT compiler only (without the need for GPRBuild).

Just compile using gnatmake. For example, to compile from obj/ folder (so .o and .ali files are generated there), type the following:

mkdir -p obj
cd obj
gnatmake ../src/powerjoular.adb

Compilation with Alire

If you have Alire installed, you can use it to build PowerJoular with:

alr build

Command Line Options

To use PowerJoular, just run the command powerjoular. On PC/servers, PowerJoular uses Intel's RAPL through the Linux powercap sysfs, and therefore requires root/sudo access on the latest Linux kernels (5.10 and newer): sudo powerjoular.

By default, the software will show the power consumption of the CPU and its utilization. The difference (increase or decrease) of power consumption from the last metric will also be shown.

The following options are available:

  • -h: show the help message
  • -v: show version number
  • -p pid: specifiy a particular PID to monitor
  • -a appName: specifiy a particular application name to monitor (will monitor all PIDs of the application)
  • -f filename: save monitoring data to the given filename path
  • -o filename: save only last monitoring data to the given filename path (file overwritten with only latest power measures)
  • -t: print energy data to the terminal
  • -d: print debug info to the terminal
  • -l: use linear regression models (less accurate than the default polynomial models) for Raspberry Pi energy models
  • -m: specify a filename for the power consumption of the virtual machine
  • -s: specify the format of the VM power, either powerjoular format (generated with the -o option: 3 columns csv file with the 3rd containing the power consumption the VM), or watts format (1 column containing just the power consumption of the VM)

You can mix options, i.e., powerjoular -tp 144 will monitor PID 144 and will print to the terminal.

Systemd Service

A systemd service is provided and can be installed (by copying powerjoular.service in systemd folder to /etc/systemd/system/). The service will run the program with the -o option (which only saves the latest power data) and saves data to /tmp/powerjoular-service.csv. The service can be enabled to run automatically on boot.

The systemd service is automatically installed when installing PowerJoular using the installer script.

Integration with Systems and Tools

PowerJoular exports its power data to CSV files, or print the values directly on the terminal. As such, PowerJoular can be used in IDEs, integration systems CI/CD, or alongside other profilers or debugging tools.

All what is needed is to start PowerJoular and read the generated CSV files. PowerJoular can write these CSV files in overwrite mode, and thus reducing the overhead and size of these files.

With the systemd service provided, PowerJoular can run automatically on startup and write power consumption to /tmp folder (which can be changed in the service). Therefore, offering an automatic way for multiple tools and dashboards to get accurate and real-time power metrics in multiple platforms.

Virtual Machines

PowerJoular also works inside virtual machines. All its functionalities (such as monitoring a PID or an application) work the same inside a virtual machine as with bare metal installation.

In virtual machines, PowerJoular in the guest OS needs to get the power consumption of the virtual machine instance itself. This can only be done by installing on the host OS, a power monitoring tool (such as PowerJoular itself or other ones), and monitoring the power consumption of the specific guest virtual machine process.

The power data of the VM process need to be written to a shared file between the host and the guest. Inside the guest, PowerJoular will read this file continuously and use the reported power value as the power of the entire virtual machine.

PowerJoular is agnostic to what power tools in installed in the host and can work with any available tool that is capable of monitoring the VM process.

Use case example with PowerJoular on host and guest

A use case example is using PowerJoular on both the host and the guest.

In the host OS

  • Install PowerJoular
  • Run PowerJoular while specifying the PID of the virtual machine of the guest OS, and writing the power data in a CSV file in overwrite mode.
  • For instance, you can run PowerJoular with the following command: powerjoular -p $VM_PID -o /home/vm/vm.csv
  • Share the /home/vm/vm.csv between the host OS and the guest OS

In the guest OS

  • Install PowerJoular
  • Share the /home/vm/vm.csv between the host OS and the guest OS, potentially having a different path of the file inside the guest. For instance, /opt/vm/vm.csv
  • Run PowerJoular with the -m and -s options to specify the file and the power data format.
  • For example, in our use case example: powerjoular -m /opt/vm/vm.csv -s powerjoular
  • You can add other options for your needs, such as -p or -a to monitor a specific process or application inside your virtual machine.

How PowerJoular Works

PowerJoular monitors the CPU and GPU power consumption in computers and servers. It is written in Ada in order to provide a low-impact tool as Ada is constantly ranked among the most energy efficient programming languages, while also improving code maintainability and safety.

PowerJoular is aimed to software developers, system administrators and to automated tools, with a goal to help these users understand the power consumption of their devices and software, and to build more in-depth tools using our proposed platform.

PowerJoular's power monitoring is based on the Intel RAPL through the Linux Power Capping Framework, and, optionally NVIDIA's System Management Interface. PowerJoular automatically detects the computer configuration and supported modules, and provides power data accordingly.

On Raspberry Pi and Asus Tinker Board (and similar devices), PowerJoular uses its own research-based empirical regression models to estimate the power consumption of the ARM processor.

CPU Power Monitoring

For the CPU, PowerJoular uses the Intel RAPL power data through the Linux powercap interface by reading the appropriate system files (or our regression models on Raspberry Pi and similar devices).

It first detects which power domains are supported by the CPU:

  • Pkg: which is supported since Intel Sandy Bridge CPUs, and provides energy consumption for the CPU cores, integrated graphics, memory controller and last level caches. PowerJoular also checks if DRAM power domain is supported (RAM attached to the memory controller) and adds its power readings to the total.
  • Psys: which is supported since Intel Skylake CPUs, and provides energy consumption for the entire SOC (including Pkg along with other components, such as eDRAM, PCH, System Agent). If Psys is supported, it will be exclusively used by PowerJoular for CPU power consumption instead of Pkg and DRAM, as it provides a more comprehensive power reading of the CPU SOC.

On Raspberry Pi and similar devices, PowerJoular uses regression models we developed (which provides high accuracy, and publish in this repository). The model uses CPU utilization (calculated from CPU cycles statistics from /proc/stat and /proc/pid/stat files).

GPU Power Monitoring

For the GPU, PowerJoular checks if NVIDIA SMI is installed, then uses it to verify if GPU power monitoring is supported to the specific graphic card, and to read GPU power consumption every second.

Finally, PowerJoular aggregates power readings from all supported components to provide an overall power consumption. For instance, if both Intel RAPL and NVIDIA SMI are supported, the tool will provide an aggregated power value for both CPU and GPU.

Monitoring a PID

For monitoring a specific process through its ID (PID), PowerJoular uses the Linux statistics in /proc/stat and /proc/pid/stat, and calculates the proportion of CPU cycles used by the process, and thus calculates the power consumed by the process accordingly.

Monitoring an application by its name

PowerJoular monitors an application by searching for all its PIDs, on every monitoring cycle (by default, every second) because an application can create or destroy process during its runtime. Then, PowerJoular applies the same approach to monitor a PID, but by monitoring all the applications PIDs and calculating the sum of the power of these PIDs.

Systemd service

PowerJoular also provides a systemd service which writes power consumption to /tmp folder, allowing it to bypass the added restrictions on reading powercap energy meters to non-privileged users in Intel CPUs. The restriction was added due to the recently discovered PLATYPUS vulnerability. However, the systemd service still requires privileged access (root/sudo) to be enabled, and the data provided is the runtime power consumption (every second) from aggregate sources (CPU and GPU when available).