Skip to content

btjiong/docker-energy

Repository files navigation

docker-energy

Measuring the impact of the base image choice for different workloads inside Docker containers

Setup

Prerequisites

  • Ubuntu (or a similar Linux distribution)
  • Docker engine
  • Python 3

Installing the dependencies

By default greenserver (which uses AMD uProf) is used as the energy profiler. To use perf as the monitoring tool run the following commands to install:

# install perf
sudo apt-get -y install linux-tools-common linux-tools-generic linux-tools-`uname -r`

# allow perf to be used by non-root users
sudo sh -c 'echo -1 >/proc/sys/kernel/perf_event_paranoid'
sudo sysctl -w kernel.perf_event_paranoid=-1

Install the Python packages to use the monitoring pipeline:

pip install -r requirements.txt

To use the predefined workloads, pull the submodules with the corresponding commit:

# Pull all submodules
git submodule update --init

# Pull a specific submodule
git submodule update --init <name of submodule>

Usage

Measuring the energy consumption

The measure.py script is used to measure the energy consumption of Docker containers for the various workloads using different base images. It takes the following arguments:

  • -l or --workload: Workload to monitor; can be used to for multiple workloads (e.g. -l llama.cpp -l mattermost)
  • -b or --base: Base image to monitor; can be used for multiple base images (e.g. -b ubuntu -b alpine)
  • -n or --runs: Number of monitoring runs per base image (e.g. -n 30) (default 30)
  • -w or --warmup: Warm up time (multiplied by the number of cores in seconds) (e.g. -w 30) (default 10)
  • -p or --pause: Pause time (s) (e.g. -p 60) (default 20)
  • -i or --interval: Interval of monitoring (ms) (e.g. -i 100) (default 100)
  • -m or --monitor: Monitoring tool (e.g. -m "perf") (default "greenserver")
  • --no-shuffle: Disables shuffle mode; regular order of monitoring base images
  • --cpus: Number of CPUs to isolate; will use threads on the same physical core (e.g. --cpus 2)
  • --cpuset: CPUs to isolate (e.g. --cpuset 0-1)
  • --all-images: Monitor all compatible base images (defined in the corresponding config file)
  • --all-workloads: Monitor all compatible workloads (defined in the workloads directory)
  • --full: Monitor all compatible workloads using all compatible base images

Running the script will output the results of the monitoring in the results directory. In this directory the results of an experiment can be found in experiment-{date}T{time}, which contains folders for each workload. Inside these workload folders there are folder for each base image, which contain the monitoring samples for each run.

The logs are stored in similar directories in the logs directory. Furthermore, the logs folder for each workload also contains information about the cpus that were used for the workload, the images that were used, and the total order of the runs.

Examples

In order to run workloads with their corresponding configurations, run one of the following commands:

# Run all workloads with all compatible base images, and the corresponding configurations
python measure.py
python measure.py --full

# Run all workloads with ubuntu base image
python measure.py --all-workloads -b ubuntu@sha256:b060fffe8e1561c9c3e6dea6db487b900100fc26830b9ea2ec966c151ab4c020

# Run the llama.cpp workload with all compatible base images
python measure.py --all-images -l llama.cpp

For example, to obtain 30 energy consumption measurements and power samples of the llama.cpp using ubuntu and debian, on cpus 0 and 12, in shuffle mode, run the following command:

python measure.py -l llama.cpp -b ubuntu@sha256:b060fffe8e1561c9c3e6dea6db487b900100fc26830b9ea2ec966c151ab4c020 -b debian@sha256:60774985572749dc3c39147d43089d53e7ce17b844eebcf619d84467160217ab -n 30 --cpuset "0,12"

The image that is used must also be defined in the configuration file of the workload.

Adding workloads

Adding workloads is done by adding a new folder in the workloads directory. This folder should contain a config.yml, and docker-compose.yml and corresponding Dockerfiles (if the workload is a Docker workload).

The template for the config.yml file is as follows:

name: 'workload' # Name of the workload
description: 'Workload description' # Description of the workload
development: false # Whether the workload is still in development (if true, the workload will not be monitored by default)
cpus: 1 # Number of threads to use for the workload (will allocate threads on the same physical core)
docker: true # Whether the workload is a Docker workload
images: # Compatible base images
    - 'ubuntu@sha256:b060fffe8e1561c9c3e6dea6db487b900100fc26830b9ea2ec966c151ab4c020'
    - 'debian@sha256:60774985572749dc3c39147d43089d53e7ce17b844eebcf619d84467160217ab'
    - 'alpine@sha256:25fad2a32ad1f6f510e528448ae1ec69a28ef81916a004d3629874104f8a7f70'
    - 'centos@sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc'

The template for the docker-compose.yml file is as follows:

services:
    service-name:
        image: workload-${NAME}
        container_name: workload
        cpuset: ${ISOLATE_CPU}
        build:
            context: '${PWD}/workloads/workload'
            dockerfile: '$PWD/workloads/workload/${FILE}'

The workload can then be monitored using the folder name in the following command:

python measure.py -l workload

About

Measuring the impact of the base image choice for different workloads inside Docker containers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors