Skip to main content

detect where your code consumes energy the most so you can optimize those functions

Project description

joulehunter

Unit tests

screenshot

Joulehunter helps you find what part of your code is consuming considerable amounts of energy .

This repo is still a work in progress. 😄

Compatibility

Joulehunter runs on Linux machines with Intel RAPL support. This technology has been available since the Sandy Bridge generation.

Installation

pip install joulehunter 

Usage

Joulehunter works similarly to pyinstrument, as we forked the repo and replaced time measuring with energy measuring. Here's pyinstrument's documentation.

joulehunter -l will list the available domains on this machine. These include the packages and their components, such as the DRAM and core.

The command joulehunter main.py will execute main.py and measure the energy consumption of the first package (CPU).

To select the package to analyze use the option -p or --package followed by the package number or the package name. The default value is 0.

The options -c and --component allow you to measure the energy of an individual component by specifying their name or ID. If not specified, the entire package will be selected.

Example

Executing joulehunter -l could output this:

[0] package-0
  [0] core
  [1] uncore
  [2] dram
[1] package-1
  [0] core
  [1] uncore
  [2] dram

If we run joulehunter -p package-1 -c 2 my_file.py, joulehunter will execute my_file.py and measure the energy consumption of package-1's DRAM.

Read permission

Due to a security vulnerability, only root has read permission for the energy files. In order to circumvent this, run the script as root or grant read permissions for the following files:

/sys/devices/virtual/powercap/intel-rapl/intel-rapl:*/energy_uj
/sys/devices/virtual/powercap/intel-rapl/intel-rapl:*/intel-rapl:*:*/energy_uj

More info here.

Acknowledgments

Thanks to Joe Rickerby and all of pyinstrument's contributors.

This fork is being developed by Chakib Belgaid and Alex Kaminetzky. Feel free to ask us any questions!

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

joulehunter-1.0.tar.gz (355.1 kB view hashes)

Uploaded Source

Supported by

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