The

Art

of Engineering greener (soft computing) software

WCCI'26, Maastricht

JJ Merelo, university of Granada, Spain, jmerelo@ugr.es

Or, how Dutch art (and history) can help us save energy in our evolutionary algorithms

Greatest Dutch invention

🎨 Renaissance!

Art is about problem solving via optimization

Computers need power to operate

Boy, do they need power...

headlines
                                      deepseek

But also...

Do we have a future?

Moore's law is dead

Moore's law
                                      and its trends

You can't make applications run much faster

Make them greener*

Tutorial organization

Energy/power and all that

How and where power is spent

Measuring energy spent

Modeling energy consumption

We need to understand

What are we measuring

How can we measure it

How can we measure our stuff

We do need to measure

It consumes a lot after all

What are we measuring

Socket ~= Processor → x cores → y threads

DRAM/Memory

GPUs

Other units: Apple Neural Engine Architecture, for instance.

Cores are not homogeneous

P cores for performance, e cores for (energy) efficiency

Multi-die architecture

Sometimes with heterogeneous frequency/voltage

System does its best to keep processor temperature in a range

Different states change frequency and voltage

Baseline: system does its best to save energy

Processors run machine code instructions

They take different number of cycles and consume a different amount of energy

And they use on-chip caches, instructions decoders and so on

We need our applications to ride this system

And extract as little power from it as possible

Good engineering can help

It's the system that draws energy

You can mostly measure the whole system

Yet you need to measure a single application

Measure energy drawn from the external plug

Problems: measuring the whole system (hard disk, external graphics card)...

... And synchronization

Good ones can be €€€

Use system APIs and interfaces

Using seudo-registers or system calls to place estimates

IOreport for Apple

Other devices have different interfaces

Running average power limit: RAPL

Prevalent in the Intel world (including AMD)

Provides registers that estimate energy usage

PKG or "package", includes all on-chip energy consumption

Intel chipsets have more granularity: memory, core/PP0, uncore/PP1, "PSys"...

Measuring energy consumed by an application

Command line tools

Language-specific libraries

Let's check the marketplace

CommandPlatformsAttaches to command
scaphandreRAPL, othersSometimes
pinpointRAPL, IOReport for M1, othersYes
perfLinuxNo
pumasMacNo

🤿 scaphandre for process-level power meter

sudo julia  examples/BBOB_sphere_with_baseline.jl 40 10000 50 10 256 &
sudo time scaphandre stdout -s 1 -p 10
Examining
                                          process-level consumption

Using pyJoules

import sys
from pyJoules.energy_meter import measure_energy
from sacrypt import process_text_v0

@measure_energy
def run_process(process_func, file_path):
    process_func(file_path)

if __name__ == "__main__":
    run_process(process_text_v0, file_path)

sudo make me a sandwich

$ sudo ./.venv/bin/python bin/sacrypt-energy.py ../data/3romanzi.txt v1
begin timestamp : 1742670844.3934789; tag : run_process; duration : 0.08716917037963867; package_0 : 3239548.0; core_0 : 55554.0; nvidia_gpu_0 : 1150

We need a methodology

Use different parameters

Repeat for statistical significance

Analyzing Italian literature

Books used in
                                      training
Computing time and PKG for 3 books
MB per J

One does not just measure

Experimental design is needed

But we're measuring the whole system here

A baseline that eliminates system overhead is needed

We can't do that from the program itself

Measuring only energy spent by our workload

E(Workload) = E(measured) - E(baseline)

Baseline includes operating context + runtime overhead

E(measured) = E(workload) + E(framework) + E(system)

System, or framework, or both need to be isolated

Establish a baseline

$ sudo pinpoint sleep 1
Energy counter stats for 'sleep 1':
[interval: 50ms, before: 0ms, after: 0ms, delay: 0ms, runs: 1]

	10.64 J nvml:nvidia_geforce_rtx_4070_super_0
	22.17 J rapl:pkg

	1.00109098 seconds time elapsed 
base
                            energy expenses
real energy spent

Very high variability

Operating context matters

Baseline
                                        measurements

Taken from Best practices in measuring energy consumption in population-based metaheuristics

Interleave workload-baseline measurements

Interleaved  measurements

High variability? Repeat for statistical significance

Choices for greener algorithms: many moving parts

Nouen Watch from the early 16th century, Dutch watchmaker from the same city as Bosch

Machine/OS/Hardware platform

Language

Language-specific optimizations

Some rules of thumb for energy savings

Hardware: several orders of magnitude

Language 2-3 orders of magnitude

Program: 1 order of magnitude

Trade-off energy/time

At the hardware/language level, at least

There's no free lunch, but we can have very cheap lunch at the program level

Can we beat Python

JavaScript is a very popular language

% Copilot rewrite this in node.js

Leaving Python in the dust

Python vs. node

What about different interpreters for JavaScript? node vs. bun

node
                                      vs. bun

Different levels: it's complicated

zig, kotlin and bun

Measuring is important

Like him, always measure when a change is made