Tech Tip #3: Measure before and after, on the same setup

If you didn't measure it twice, you didn't save it.

Video created by explainapaper.com

The problem

Teams make code faster and call it greener, but speed and energy do not always move together. In GreenCode research, the GPU energy of a widely used AI inference engine fell by 4.7% while its speed rose by only 3%.

The fix you can use today

  • Measure energy before you change anything.
  • Measure again after every change, on the same machines under the same load.
  • Keep a change only if it saves energy and nothing else got worse.

GreenCode researchers measure each change before and after, and keep only the ones that save energy.

Tools that help

  • green-languages (GreenCode researchers): a command-line tool that measures the energy of whole programs or marked sections of code, across languages
  • GreenCode Constitution profiler (profile.sh) (GreenCode researchers): a script from the Constitution tooling that measures the energy of a command from processor counters, GPU sensors and an optional smart plug, and writes the result as JSON
  • Scaphandre: measures the power drawn by each process on a Linux server and exports it to Prometheus and other monitoring stacks
  • CodeCarbon: a Python package that estimates the energy and CO2 of a run from hardware power and regional grid intensity
  • perf (RAPL counters): Linux perf reads the processor's RAPL energy counters, e.g. `perf stat -e power/energy-pkg/`

How GreenCode helps

GreenCode helps tackle this by measuring energy before any change and after every optimisation pass, on the same infrastructure under the same load. A saving only counts if quality, security and error rate did not get worse. More on this.

Tags

#measurement#governance

Sources

Transcript

If you didn't measure it twice, you didn't save it. Teams often make code faster, and call it greener. But faster is not always greener. In GreenCode research, the energy of a widely used AI program fell nearly five percent. Its speed rose by only three percent. Speed and energy do not always move together. Here is the fix you can use today. Measure energy before you change anything. Measure again after every change, on the same machines, under the same load. Keep a change only if it saves energy, and nothing else got worse. Many processors and graphics cards report their own energy use. So you don't have to guess. Read them using tools like GreenCode's green-languages, perf on Linux, and Scaphandre. Two numbers, before and after, are something your whole team can trust. GreenCode researchers measure each change before and after. They keep only the ones that save energy. GreenCode helps tackle this by measuring your system under the same load, before and after. A saving only counts if quality, security and error rate did not get worse. That was GreenCode Tech Tip number three. Follow for the next tip, and find more on greencode.ai/tech-tips.

All GreenCode Tech Tips · All GreenCode videos

  • Tip #3
  • For CTOs and technical leads
  • Length 1:16
  • Category Measuring energy
GreenCode

Want this checked on your own system? Talk to the GreenCode team.

Get in touch