AdaCore / Ada-SPARK-Crate-Of-The-Year

19 stars 2 forks source link

[2022][powerjoular] Multi-platform monitoring of the power consumption of hardware and software #18

Closed adelnoureddine closed 1 year ago

adelnoureddine commented 1 year ago

badge

Multi-platform monitoring of the power consumption of hardware and software.

PowerJoular

Purpose

As energy is a finite resource and its generation is impacting our climate (whether generating electricity or building devices' batteries), it is crucial to optimize the energy consumption of computing devices. The first step in optimizing is to measure and estimate the power consumption of hardware and software. In particular, complex devices do not execute and consume power unless tasked by software (OS, applications, etc.), and therefore it is important to isolate the power consumption of individual software.

PowerJoular is a command line software to monitor, in real time, the power consumption of software and hardware components. It is a multi-platform software capable of measuring or estimating the power consumption of various hardware and software: Intel/AMD x86/64 bits CPUs in servers and computers, Raspberry Pi ARM CPUs, and various other single-board computers (Tinkboard, BeagleBone).

Currently, we support :

PowerJoular is also capable to estimate the power consumption of individual software based on their CPU utilization. It also offers a systemd service for automatic monitoring, and outputs to the terminal or to CSV files.

Usage

PowerJoular can be used either independently, or its units reused and integrated to other Ada software.

To user PowerJoular independently, just run: powerjoular in the terminal. That's it!

PowerJoular

The following options are available:

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

PowerJoular units can be easily reused as we define functions, procedures and datatypes that are self-contained. For instance, if wanting to monitor Raspberry Pi CPU power in your 3rd-party Ada application, just integrate the appropriate unit (in this case, Intel_RAPL_sysfs). Same for Raspberry Pi models (dRaspberry_Pi_CPU_Formula):

-- Function to calculate CPU power consumption based on CPU utilization
function Calculate_CPU_Power (CPU_Utilization : Float; Platform_Name : String; PowerModels_Data : Unbounded_String; Algorithm_Name : String) return Float;

Design

Ada's choice to develop and implement PowerJoular was straightforward: a capable language with strong typing, and very low power overhead (ranking among the best in terms of energy efficiency with C, C++ and Rust). As PowerJoular would be running on low-powerful remote devices, and in many cases continuously, we aimed to limit its energy impact and also limit the possibilities of crashed or bugs.

PowerJoular is designed with 2 main unit categories in mind:

For the former, we built individual units for each device category: RAPL CPUs, Raspberry Pi CPUs, NVIDIA GPUs, etc., along with helper units to calculate CPU statistics and processes' CPU usage. For the latter, we built CSV and terminal unit exports, and we added a systemd service for continuous monitoring.

The architecture design of PowerJoular is further described in this paper.

License

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