The rate at which energy is consumed. Analogy: Car speed (90 km/h).
The total amount used over time.
Energy = Power × Time
Analogy: Distance traveled (200 km).
Our Goal: Minimize the total Joules for a specific task.
Running Average Power Limit
Modern CPUs (Intel/AMD) don't have physical "meters" inside, but they have very accurate Power Models.
Linux exposes RAPL data via the powercap framework in the virtual filesystem:
/sys/class/powercap/intel-rapl/
# A "quick and dirty" measurement script
def read_energy():
with open("/sys/class/powercap/intel-rapl:0/energy_uj", "r") as f:
return int(f.read())
v0 = read_energy()
time.sleep(1)
v1 = read_energy()
print(f"Average Power: {(v1-v0)/1e6:.1f} W")
| Tool | Best For... | Command |
|---|---|---|
| powertop | System-wide diagnosis & "vampire" processes. | sudo powertop |
| powerstat | Real-time monitoring of system drain. | sudo powerstat |
| perf | Precision surgical measurement of a command. | sudo perf stat -e power/energy-pkg/ |
| s-tui | Visualizing stress vs. power vs. frequency. | s-tui |
let's create a 1GB text file
$ tr -dc 'A-Za-z0-9 ' < /dev/urandom | fold -w 80 | head -c 1G > big.txt
$ wc -l big.txt
13256071 big.txt
$ sort big.txt > /dev/null
Takes ~25 seconds.
We could sort using parallelism, but Parallel sorting uses more cores (more Watts). Will it also consume more Energy (Joules)?
$ time sort --parallel=16 big.txt > /dev/null
Takes ~6.4 seconds.
Measure 1: sort single-thread
$SORT_CMD1=sort --parallel=1 big.txt > /dev/null
sudo perf stat -e power/energy-pkg/ -- $SORT_CMD1
Measure 2: sort multi-thread
$SORT_CMD16=sort --parallel=16 big.txt > /dev/null
sudo perf stat -e power/energy-pkg/ -- $SORT_CMD16
Finishing fast and letting the CPU return to "Idle" C-states is often the best strategy.
| Language | Time | Energy (J) |
|---|---|---|
| Python |
50.2 s | 934 J |
| Rust |
2.1 s | 39 J |
For this CPU-bound task, Rust is 23x more energy-efficient.
Note: We used the exact same algorithm for both.
The Problem: In AWS/GCP, the hypervisor hides RAPL. /sys/class/powercap is empty!

(image courtesy of CERN)
A specialized metrology agent written in Rust.
Why efficiency isn't enough to save us.
As technological progress increases the efficiency with which a resource is used (reducing the amount necessary for any one use), the rate of consumption of that resource rises due to increasing demand.
Green computing isn't just for kernel developers.
Energy is being standardized! OTel Semantic Conventions mean your standard APM (Datadog, Jaeger) will soon show Energy by default.
perf stat for surgical benchmarks.@ilmanzoQuestions?
Question: "How many Joules does your last 'git push' cost?" Thermal Throttling: Hot code is slow code.