Package: joulehunter
joulehunterJoulehunter helps you find what part of your code is consuming considerable amounts of energy.This repo is still a work in progress. 😄CompatibilityJoulehunter runs onLinuxmachines withIntel RAPLsupport. This technology has been available since the Sandy Bridge generation.InstallationYou can install joulehunter with pip:pip install joulehunter.You can also clone the repo and install it directly:git clone https://github.com/powerapi-ng/joulehunter.git
 cd joulehunter
 python setup.py installUsageJoulehunter works similarly topyinstrument, as we forked the repo and replaced time measuring with energy measuring. Here'spyinstrument's documentation. Wheneverpyinstrumentis present in a variable name, it should be replaced withjoulehunter(for example,PYINSTRUMENT_PROFILE_DIRturns intoJOULEHUNTER_PROFILE_DIR).Command linejoulehunter -lwill list the available domains on this machine. These include the packages and their components, such as the DRAM and core.The commandjoulehunter main.pywill executemain.pyand measure the energy consumption of the first package (CPU).To select the package to analyze use the option-por--packagefollowed by the package number or the package name. The default value is 0.The options-cand--componentallow you to measure the energy of an individual component by specifying their name or ID. If not specified, the entire package will be selected.ExampleExecutingjoulehunter -lcould output this:[0] package-0
  [0] core
  [1] uncore
  [2] dram
[1] package-1
  [0] core
  [1] uncore
  [2] dramIf we runjoulehunter -p package-1 -c 2 my_file.py, joulehunter will executemy_file.pyand measure the energy consumption of package-1's DRAM.Profiling chunks of codeAspyinstrument's documentationshows, it's also possible to profile specific chunks of code.Joulehunter's Profiler class can receive two additional arguments:packageandcomponent. They receive the ID (as a string or integer) or name of the desired package/component. Ifpackageis not specified,package-0will be used. IfcomponentisNone, the entire package will be analyzed.Profiling web requests in FlaskPlease refer topyinstrument's documentationfor instructions on how to profile web requests in Flask. As in the previous case, joulehunter'sProfiler()accepts two additional arguments.Profiling web requests in DjangoProfiling web requests in Django as explained inpyinstrument's documentationselects package 0 as the default domain (don't forget to rename thepyinstrumentin variable names withjoulehunter).The user can choose a particular package and component as follows:Query component: The query stringspackageandcomponentare used to select the desired package and component. For example, including?profiler&package=0&component=dramat the end of a request URL will select the first package and the DRAM. If the component query component is present but empty, the package will be analyzed.Variable insettings.py:The user's selection can also be defined insettings.pywith theJOULEHUNTER_PACKAGEandJOULEHUNTER_COMPONENTvariables. These are later passed toPackage().If the package or component is defined both as a query component and insettings.py, the one defined as a query component will be selected.Read permissionDue to asecurity 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_ujMore infohere.AcknowledgmentsThanks toJoe Rickerbyand all ofpyinstrument's contributors.This fork is being developed byChakib BelgaidandAlex Kaminetzky. Feel free to ask us any questions!