Energy Efficiency

Minimal footprint. Maximum performance.

Energy-Aware Compiling

Lyx supports Energy-Aware-Compiling to generate energy-efficient machine code, controlled via CLI or function-level pragmas.

CLI Option: --target-energy=<1-5>
# Compile with energy level 1 (battery-optimized, minimal power)
./lyxc program.lyx -o program --target-energy=1

# Compile with energy level 3 (balanced, default)
./lyxc program.lyx -o program --target-energy=3

# Compile with energy level 5 (maximum performance)
./lyxc program.lyx -o program --target-energy=5
1
Minimal
4× Loop Unroll
2
Low
2× Loop Unroll
3
Medium
1× + SIMD
4
High
+ FPU
5
Extreme
8× + AVX2/512
Function-Level Pragma: @energy(level)
// This function compiles with level 1 (battery-optimized)
@energy(1)
fn low_power_task(): int64 {
    var sum: int64 := 0;
    var i: int64 := 0;
    while i < 1000 {
        sum := sum + i;
        i := i + 1;
    }
    return sum;
}

// This function compiles with level 5 (maximum performance)
@energy(5)
fn compute_intensive(): int64 {
    var result: int64 := 0;
    // Heavy computation uses SIMD/FPU
    return result;
}

fn main(): int64 {
    var x: int64 := low_power_task();
    var y: int64 := compute_intensive();
    return x + y;
}

Energy Efficiency

Minimal binary size means minimal energy consumption. Lyx binaries are designed to be efficient from the ground up.

Minimal Footprint

Starting from just 4KB, Lyx binaries require minimal disk space and memory.

  • No runtime overhead
  • No garbage collector
  • Direct syscalls
🔋

Low Memory Usage

Small memory footprint makes Lyx perfect for embedded and resource-constrained environments.

  • Stack allocation by default
  • No interpreter overhead
  • Zero-cost abstractions
🌿

Green Computing

Smaller binaries mean less energy for storage, transmission, and execution.

  • Faster deployment
  • Reduced bandwidth
  • Lower cloud costs
COMPARISON
Language Binary Size Runtime Memory Usage
Go ~2 MB ~10 MB ~5 MB
Rust ~800 KB ~2 MB ~1 MB
Python N/A ~50 MB ~20 MB
Lyx 4-42 KB 0 KB <1 MB

Energy Statistics

The compiler outputs detailed energy statistics after compilation

=== Energy Statistics ===
Energy level:           3
CPU family:             1
Optimize for battery:   TRUE
Avoid SIMD:             TRUE
Avoid FPU:              FALSE
Cache locality:         TRUE
Register over memory:   TRUE

Total ALU operations:   42
Total FPU operations:    0
Total SIMD operations:    0
Total memory accesses:   17
Total branches:          8
Total syscalls:          3

Estimated energy units:  16955
Code size:              846 bytes
L1 cache footprint:    846 bytes
42
ALU Operations
17
Memory Accesses
16955
Energy Units (est.)
846 B
Code Size