A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

Energy Efficiency in Programming Languages

Provides a benchmarking tool to measure energy efficiency across various programming languages using Docker.
https://github.com/nicovank/energy-languages

Category: Consumption
Sub Category: Computation and Communication

Keywords from Contributors

languages clbg compilers zig clang pending gcc transforms archiving measur

Last synced: about 8 hours ago
JSON representation

Repository metadata

README.md

Energy Efficiency in Programming Languages

Nicolas van Kempen,
Hyuk-Je Kwon,
Dung Tuan Nguyen,
Emery Berger.

Read the paper!

Documentation

Requirements

Running the measurement tool requires:

  • an Intel processor with RAPL support.
  • Linux (tested on Ubuntu 22.04).

Docker

The easiest way to run these benchmarks is using Docker:

% sudo modprobe msr # Enable msr kernel module.
% sudo python3 -m scripts.build_docker_image
% sudo docker run --privileged -v [OUTPUT_DIRECTORY]:/root/data energy-languages [OPTIONS]

Here is an example running all languages/benchmarks pairs:

% sudo docker run -it --rm --privileged -v `pwd`/data/`hostname -s`/docker-default:/root/data energy-languages \
    --languages C C++ Rust Go Java C\# JavaScript TypeScript PHP Python PyPy Lua LuaJIT \
    --warmup 1 \
    --iterations 21 \
    --timeout 10000

Running additional experiments:

% sudo docker run -it --rm --privileged -v `pwd`/data/`hostname -s`/docker-default:/root/data energy-languages \
    --benchmark-root experiments \
    --languages "C as C++" "Go-no-GC" "JavaScript as TypeScript" \
    --warmup 1 \
    --iterations 21 \
    --timeout 10000

Running Java-N experiments:

% sudo ./scripts/docker-java-n.sh Java docker-default

Processors can be set to their minimum frequency with the following commands:

# Use frequency-info to check the defaults for your machine.
% cpupower frequency-info

# Pin to lowest possible frequency.
% echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
% sudo cpupower frequency-set --governor powersave
% sudo cpupower frequency-set --max 800Mhz

# Restore defaults after running experiments.
% echo 0 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
% sudo cpupower frequency-set --governor powersave
% sudo cpupower frequency-set --max 3.4GHz

Finally, experiments can be pinned to a single code by using Docker's
--cpuset-cpus option, specifying a core number. For example:

% sudo docker run -it --rm --privileged --cpuset-cpus=13 [...]

Figures

Average power draw as a function of the average number of cores used

Average power draw as a function of the average number of cores used

% python3 -m scripts.normalize_cores \
    --data-root data/`hostname -s`/docker-default \
    --languages C C++ Rust Go Java C\# JavaScript TypeScript PHP Python PyPy Lua LuaJIT

Average power draw as a function of memory activity

Average power draw as a function of memory activity

% python3 -m scripts.dram \
    --data-root data/`hostname -s`/docker-default \
    --languages C C++ Rust Go Java C\# JavaScript TypeScript PHP Python PyPy Lua LuaJIT

Average power draw controlling for external factors

Average power draw controlling for external factors

% python3 -m scripts.fixed_time \
    --data-root data/`hostname -s`/docker-min-freq-cpuset-13 \
    --languages C C++ Rust Go Java C\# JavaScript TypeScript PHP Python PyPy Lua LuaJIT

Other

A few other scripts can be useful to generate figures and results.
Their options are self-explanatory and/or documented in the --help message.
Notably:

  • scripts.table: Build two tables comparing runtime and energy
    consumption for a list of languages.
  • scripts.barchart: Compare two implementations of the same programming
    language.
  • scripts.java_n: Generate a figure for a given benchmark of time per
    iteration as a function of number of iterations.

License

The original benchmark suite, the
Computer Language Benchmark Game,
is under
BSD-3-Clause.

Code from
the repository this one originally forked from
is under
MIT.

Any other code in this repository is under Apache-2.0.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 636
Total Committers: 13
Avg Commits per committer: 48.923
Development Distribution Score (DDS): 0.11

Commits in past year: 189
Committers in past year: 3
Avg Commits per committer in past year: 63.0
Development Distribution Score (DDS) in past year: 0.011

Name Email Commits
Nicolas van Kempen n****p@g****m 566
Dung Tuan Nguyen n****r@g****m 28
MarcoCouto m****0@g****m 11
Hyuk-Je Kwon h****n@g****m 7
root r****t@o****u 7
dependabot[bot] 4****] 6
States r****3@g****m 4
Green Software Lab g****b@d****t 2
Ben Albrecht b****t 1
Felipe Móz 6****z 1
José Nuno Macedo j****o@i****t 1
Logan Kilpatrick 2****3@g****m 1
michaljroszak 4****k 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 9
Total pull requests: 78
Average time to close issues: 3 months
Average time to close pull requests: 2 days
Total issue authors: 1
Total pull request authors: 4
Average comments per issue: 0.78
Average comments per pull request: 0.37
Merged pull request: 71
Bot issues: 0
Bot pull requests: 15

Past year issues: 0
Past year pull requests: 5
Past year average time to close issues: N/A
Past year average time to close pull requests: 9 days
Past year issue authors: 0
Past year pull request authors: 2
Past year average comments per issue: 0
Past year average comments per pull request: 1.4
Past year merged pull request: 4
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/nicovank/energy-languages

Top Issue Authors

  • nicovank (9)

Top Pull Request Authors

  • nicovank (38)
  • dependabot[bot] (15)
  • hyukjekwon (14)
  • dungwinux (11)

Top Issue Labels

Top Pull Request Labels

  • dependencies (15)

Dependencies

TypeScript/package-lock.json npm
  • @types/node 18.11.9
TypeScript/package.json npm
  • @types/node ^18.11.9
.github/workflows/docker.yml actions
  • actions/checkout v3 composite
.github/workflows/rapl.yml actions
  • actions/checkout v3 composite
Rust/binary-trees/Cargo.lock cargo
  • autocfg 1.1.0
  • cfg-if 1.0.0
  • crossbeam-channel 0.5.8
  • crossbeam-deque 0.8.3
  • crossbeam-epoch 0.9.14
  • crossbeam-utils 0.8.15
  • either 1.8.1
  • hermit-abi 0.2.6
  • libc 0.2.141
  • memoffset 0.8.0
  • num_cpus 1.15.0
  • rayon 1.7.0
  • rayon-core 1.11.0
  • scopeguard 1.1.0
  • typed-arena 2.0.2
Rust/binary-trees/Cargo.toml cargo
Rust/fannkuch-redux/Cargo.lock cargo
  • autocfg 1.1.0
  • cfg-if 1.0.0
  • crossbeam-channel 0.5.8
  • crossbeam-deque 0.8.3
  • crossbeam-epoch 0.9.14
  • crossbeam-utils 0.8.15
  • either 1.8.1
  • hermit-abi 0.2.6
  • libc 0.2.141
  • memoffset 0.8.0
  • num_cpus 1.15.0
  • rayon 1.7.0
  • rayon-core 1.11.0
  • scopeguard 1.1.0
Rust/fannkuch-redux/Cargo.toml cargo
Rust/fasta/Cargo.lock cargo
  • hermit-abi 0.2.6
  • libc 0.2.141
  • num_cpus 1.15.0
Rust/fasta/Cargo.toml cargo
Rust/n-body/Cargo.lock cargo
Rust/n-body/Cargo.toml cargo
Rust/pidigits/Cargo.lock cargo
Rust/pidigits/Cargo.toml cargo
Rust/regex-redux/Cargo.lock cargo
  • aho-corasick 0.7.20
  • memchr 2.5.0
  • regex 1.7.3
  • regex-syntax 0.6.29
Rust/regex-redux/Cargo.toml cargo
Rust/reverse-complement/Cargo.lock cargo
  • autocfg 1.1.0
  • cfg-if 1.0.0
  • crossbeam-channel 0.5.8
  • crossbeam-deque 0.8.3
  • crossbeam-epoch 0.9.14
  • crossbeam-utils 0.8.15
  • either 1.8.1
  • hermit-abi 0.2.6
  • libc 0.2.141
  • memoffset 0.8.0
  • num_cpus 1.15.0
  • rayon 1.7.0
  • rayon-core 1.11.0
  • scopeguard 1.1.0
Rust/reverse-complement/Cargo.toml cargo
Rust/spectral-norm/Cargo.lock cargo
  • autocfg 1.1.0
  • cfg-if 1.0.0
  • crossbeam-channel 0.5.8
  • crossbeam-deque 0.8.3
  • crossbeam-epoch 0.9.14
  • crossbeam-utils 0.8.15
  • either 1.8.1
  • hermit-abi 0.2.6
  • libc 0.2.141
  • memoffset 0.8.0
  • num_cpus 1.15.0
  • rayon 1.7.0
  • rayon-core 1.11.0
  • scopeguard 1.1.0
Rust/spectral-norm/Cargo.toml cargo
TypeScript/k-nucleotide/package-lock.json npm
TypeScript/k-nucleotide/package.json npm
experiments/JavaScript as TypeScript/k-nucleotide/package-lock.json npm
experiments/JavaScript as TypeScript/k-nucleotide/package.json npm
experiments/JavaScript as TypeScript/package-lock.json npm
  • @types/node 18.16.1
experiments/JavaScript as TypeScript/package.json npm
  • @types/node 18.16.1
.github/workflows/scripts.yml actions
  • actions/checkout v4 composite
Python/requirements.txt pypi
  • gmpy2 ==2.1.5
scripts/requirements.txt pypi
  • black ==24.4.2
  • matplotlib ==3.9.0
  • mypy ==1.10.0
  • numpy ==1.26.4
  • pandas ==2.2.2
  • pandas-stubs ==2.2.2.240514
  • rich ==13.7.1
  • scipy ==1.13.1

Score: 5.049856007249537