Skip to main content

EnergAt: A software energy attribution tool.

Project description

EnergAt 🔋🎯

version License: MIT Maintenance PRs Welcome build PyPI version

EnergAt is a prototype implementation of the thread-level, NUMA-aware energy attribution model for multi-tenancy, as proposed in our paper. It offers precise tracking of the energy consumption of your software application, even when it is running alongside other jobs from different users.

Install

To use EnergAt, the following requirements have to be met:

  • Python 3.10
  • Linux with root permission
  • Intel RAPL with sysfs power capping interface

Note There are several ways of accessing RAPL meters on Linux (e.g., via model-specific registers or perf), but the current implementation only supports the powercap interface. Contributions are more than welcome!

Please run the following commands:

# * Configure the host system.
$ ./scripts/setup/init_system.sh
# * Use root permission for invoking energat with `sudo` later.
$ sudo python -m pip install energat

Usage

Warning Please always first estimate the static power of the machine by running the following command.

$ sudo energat -basepower

Python API

import psutil, time
from energat.tracer import EnergyTracer

def xyz():
    tmp = 20_000
    for _ in range(100): 
        time.sleep(0.1)
        tmp = tmp * 0.314

with EnergyTracer(psutil.Process().pid, output='xyz_energy') as tracer:
    xyz()

# * The traces of `xyz()` will be saved to ./xyz_energy.csv at this point.

Command line interface

First, check the system setup by running:

$ sudo energat -check

EnergAt @ Jul 03 10:30:27] INFO     | Socket count:        2
EnergAt @ Jul 03 10:30:27] INFO     | Host CPU times:      [334541.14, 334861.87]
EnergAt @ Jul 03 10:30:27] INFO     | Total NUMA memories: [32094.24, 32211.02]
EnergAt @ Jul 03 10:30:27] INFO     | RAPL domain ranges:  [262143.32885, 65712.999613]
EnergAt @ Jul 03 10:30:27] INFO     | System check passed!

Then, you can attach EnergAt to a running application for which you want to trace the energy consumption by providing its PID:

$ sudo energat -pid <PID>

Other command-line options include:

$ sudo energat [FLAGS]

Commands:
  --pid PID                PID of the target application
                           (default: -1)
  --name NAME              Name of the target application
  --check                  Check hardware support
                           (default: False)
  --basepower              Estimate static power
                           (default: False)

Configurations:
  --output OUTPUT          Output directory
                           (default: ./data/results)
  --basefile BASEFILE      File recording the baseline power
                           (default: ./data/baseline_power.json)
  --base_period BASE_PERIOD
                           Sampling period in seconds for baseline power estimation
                           (default: 2)
  --rapl_period RAPL_PERIOD
                           Sampling period in seconds for RAPL power meters
                           (default: 0.01)
  --interval INTERVAL      Interval in seconds between two power estimations
                           (default: 1)
  --gamma GAMMA            Non-linear scaling factor for CPU power
                           (default: 0.3)
  --delta DELTA            Non-linear scaling factor for DRAM power
                           (default: 0.2)
  --logging LOGGING        Logging interval in seconds (with `loglvl=debug` only)
                           (default: 1)
  --loglvl LOGLVL          Logging level (info/debug)
                           (default: debug)

Once the target application finishes, EnergAt will save the energy traces to the -output directory and exits. You can also stop the tracing by Ctrl+C, and EnergAt will still save your result before exiting.

Development

EnergAt has been heavily tested on a few dual- and single-socket machines on CloudLab.

To set up the development environment, please run the following commands.

# * Run the setup script.
./scripts/setup/init_cloudlab.sh
# * Install python dependencies.
pip install -r requirements.txt
# * Configure git hooks.
pip install pre-commit
pre-commit install
pre-commit autoupdate

Runtime Configuration

There are several ways by which you can change the configurations of EnergAt:

  1. Directly change the default parameters in configs/default.py.
  2. Provide your own config file in the configs/ directory and specify it in the command line, e.g.,:
$ sudo energat -config=./configs/your_config.py
  1. Overwrite the default parameters through command-line flags, e.g.,:
$ sudo energat -config.OUTPUT_DIR='./out' -config.DELTA_MEM=0.1

Contributing

Pull requests (PRs) are most welcome! Please follow the PR template: .github/pull_request_template.md.

Citation

If you find this tool useful, please cite our paper:

@inproceedings{hotcarbon2023energat,
  author = {Hè, Hongyu and Friedman, Michal and Rekatsinas, Theodoros},
  title = {EnergAt: Fine-Grained Energy Attribution for Multi-Tenancy},
  booktitle = {2nd Workshop on Sustainable Computer Systems (HotCarbon '23)},
  year = {2023},
  month = {July},
  day = {9},
  location = {Boston, MA, USA},
  publisher = {ACM},
  address = {New York, NY, USA},
  pages = {8},
  doi = {10.1145/3604930.3605716},
  url = {https://doi.org/10.1145/3604930.3605716}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

energat-1.0.6.tar.gz (7.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

energat-1.0.6-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file energat-1.0.6.tar.gz.

File metadata

  • Download URL: energat-1.0.6.tar.gz
  • Upload date:
  • Size: 7.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for energat-1.0.6.tar.gz
Algorithm Hash digest
SHA256 bd51ba54c65429352dcfd46479063ff11031e799cdb6ecbb675548ce6dc6e75b
MD5 54d40c76562f60276c76752eb8abd9b4
BLAKE2b-256 0676fbf8525b49574cf63244adbc9b5625d02c622ab3aead1cb60add72f17108

See more details on using hashes here.

File details

Details for the file energat-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: energat-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for energat-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 714e0118854c5c829d8813f01a58277018db215bc98512e6a2cd369878c9e903
MD5 4c817bd3e86d8c5e6b14721231aa74aa
BLAKE2b-256 2c034558d95fce665a53accaf4de54421fa70f44c30266cb8a8ac5dbb48918b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page