Summary of CPU Energy Meter

  • news.ycombinator.com
  • HN Threads
  • Summarized Content

    CPU Energy Meter: Linux Software for Intel CPU Energy Monitoring

    CPU Energy Meter is a Linux software tool that enables you to monitor the power consumption of Intel CPUs at granular time intervals (a few tens of milliseconds). This software is designed to provide detailed energy consumption insights across different power domains within your system.

    • Per Package Domain (CPU Socket): Tracks power usage at the CPU socket level.
    • Per Core Domain: Monitors power consumption for all CPU cores within a package.
    • Per Uncore Domain: Measures power usage of uncore components, such as integrated graphics on client CPUs.
    • Per Memory Node: Tracks power usage of memory local to a package, specifically for server CPUs.
    • Per Platform: Provides a comprehensive view of power consumption for all devices powered by the integrated power delivery mechanism, including processor cores, SoC, memory, and peripheral devices.

    How CPU Energy Meter Works

    The software leverages the RAPL (Running Average Power Limit) feature found on Intel CPUs from the Sandy Bridge generation onwards. RAPL allows for precise power consumption measurements within specific time intervals.

    • CPU Energy Meter utilizes the maximum permissible measurement interval, ensuring minimal overhead on system performance. This interval can range from a few minutes to an hour, depending on your hardware configuration.
    • The tool is based on the Intel Power Gadget but has been extended and maintained by the Software Systems Lab at Ludwig-Maximilians-Universität München (LMU Munich).

    Software Installation

    Installing CPU Energy Meter on Debian or Ubuntu systems is straightforward:

    • PPA Method: Add our PPA (Personal Package Archive) to your system using the following commands:
                      sudo add-apt-repository ppa:sosy-lab/benchmarking
                      sudo apt install cpu-energy-meter
                  
    • .deb Package: Download the .deb package from our GitHub releases page and install it using the following command:
                      sudo apt install ./cpu-energy-meter*.deb
                  
    • Source Code: For quick and dirty installation from source code:
                      sudo apt install libcap-dev
                      sudo modprobe msr
                      make
                      sudo ./cpu-energy-meter
                  

    Dependencies

    CPU Energy Meter relies on the following dependencies:

    • libcap: A library that provides capabilities management for Linux. It is usually found as package libcap (Fedora) or libcap2 (Debian/Ubuntu).
    • Linux Kernel with MSR Module: The MSR (Model Specific Registers) module is typically enabled by default in modern Linux kernels.

    Running CPU Energy Meter Without Root

    For running CPU Energy Meter without root privileges, follow these steps:

    • Load the msr and cpuid kernel modules.
    • Create a new group named msr.
    • Configure a Udev rule to grant access to /dev/cpu/*/msr to the msr group. (An example rule is available on the GitHub repository.)
    • Run chgrp msr, chmod 2711, and setcap cap_sys_rawio=ep on the binary. You can use make setup as a shortcut for this.

    Usage

    To use CPU Energy Meter, run the following command in your terminal:

            cpu-energy-meter [-d] [-e sampling_delay_ms] [-r]
        
    • -d: Enables debug output.
    • -e sampling_delay_ms: Overrides the default measurement interval with a custom value in milliseconds. (Default interval is calculated automatically based on hardware.)
    • -r: Prints the output as a raw list, which is easier to parse.

    CPU Energy Meter will continuously monitor energy consumption and report measurements when you send a SIGINT signal (Ctrl+C). You can also send the USR1 signal to receive intermediate measurements.

    Example Output

    Here's an example of the output you would see when running CPU Energy Meter:

            +--------------------------------------+
            | CPU-Energy-Meter            Socket 0 |
            +--------------------------------------+
            Duration                  2.504502 sec
            Package                   3.769287 Joule
            Core                      0.317749 Joule
            Uncore                    0.010132 Joule
            DRAM                      0.727783 Joule
            PSYS                     29.792603 Joule
        

    Key Features

    CPU Energy Meter offers a range of features that make it a valuable tool for developers and system administrators:

    • Detailed Power Consumption Monitoring: Provides fine-grained measurements across various power domains.
    • Minimal Overhead: Uses efficient measurement intervals, ensuring negligible impact on system performance.
    • Easy to Use: Simple command-line interface with straightforward options.
    • Open Source: BSD-3-Clause licensed, allowing for modification and customization.
    • Community Support: Active development and community support on GitHub.

    Comparison with Intel Power Gadget

    CPU Energy Meter is a fork of the Intel Power Gadget software. It builds upon the original features and provides enhanced functionality, including:

    • Expanded Power Domain Monitoring: Supports additional power domains, such as memory nodes.
    • Improved Performance: Optimizes measurement intervals for reduced system overhead.
    • Community-Driven Development: Actively maintained and developed by the open-source community.

    Applications

    CPU Energy Meter can be used in a variety of scenarios:

    • Benchmarking: Accurately measure the energy consumption of different software applications or system configurations.
    • Power Management: Identify areas where power consumption can be optimized and reduce energy usage.
    • Debugging: Analyze power consumption patterns to detect potential performance issues or hardware faults.
    • Research: Investigate energy consumption behaviors of different software workloads.

    Conclusion

    CPU Energy Meter is a powerful and versatile tool for monitoring the power consumption of Intel CPUs on Linux systems. It offers comprehensive measurement capabilities, ease of use, and a community-driven approach, making it an ideal choice for various applications in energy efficiency, benchmarking, and system optimization.

    Ask anything...

    Sign Up Free to ask questions about anything you want to learn.