Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.

Research/code footprint #82

Open
wants to merge 7 commits into
base: research/code-footprint
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ We all stand on the shoulders of giants and get by with a little help from our f
* [Sigar](https://support.hyperic.com/display/SIGAR/Home) (version 1.6.5 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing a portable interface for gathering system information.
* [spray-json](http://spray.io/) (version 1.3.2 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for (de)serializing JSON.
* [scala-influxdb-client](https://github.com/paulgoldbaum/scala-influxdb-client) (version 0.4.5 under [MIT license](https://github.com/paulgoldbaum/scala-influxdb-client/blob/master/LICENSE)), for using an asynchronous scala API for InfluxDB.
* [protobuf-java](https://developers.google.com/protocol-buffers/) (version 2.6.1 under [new BSD license](http://www.opensource.org/licenses/bsd-license.php)), for using the JAVA protobuf API.

# License
This software is licensed under the *GNU Affero General Public License*, quoted below.
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile-cli
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
FROM alpine:latest
FROM alpine:3.3

ENV POWERAPI_PACKAGE powerapi-cli
ENV LIBPFM_PACKAGE libpfm-4.6.0

ENV INSTALL_PACKAGES ca-certificates linux-headers libc-dev make gcc patch
ENV RUNTIME_PACKAGES bluez bluez-dev openjdk7-jre bash procps
ENV RUNTIME_PACKAGES bluez bluez-dev openjdk8-jre bash procps

COPY docker/libpfm/config.mk.patch /root/
COPY ${POWERAPI_PACKAGE}/target/universal/${POWERAPI_PACKAGE}/ /root/${POWERAPI_PACKAGE}/

VOLUME /conf

RUN apk update && apk upgrade && apk add $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
wget https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk && apk --allow-untrusted add glibc-2.21-r2.apk && rm -f glibc-2.21-r2.apk && \
wget https://circle-artifacts.com/gh/sgerrand/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk && apk --allow-untrusted add glibc-2.21-r2.apk && rm -f glibc-2.21-r2.apk && \
wget http://downloads.sourceforge.net/project/perfmon2/libpfm4/${LIBPFM_PACKAGE}.tar.gz && tar -C /root -xzvf ${LIBPFM_PACKAGE}.tar.gz && patch -d /root/$LIBPFM_PACKAGE -p1 < /root/config.mk.patch && (cd /root/$LIBPFM_PACKAGE; make lib; make install) && rm -rf /root/config.mk.patch /root/$LIBPFM_PACKAGE ${LIBPFM_PACKAGE}.tar.gz && \
rm -rf /root/${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
apk del glibc $INSTALL_PACKAGES && \
Expand Down
21 changes: 21 additions & 0 deletions docker/Dockerfile-code-energy-analysis
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM openjdk:8-jre

ENV POWERAPI_PACKAGE powerapi-code-energy-analysis
ENV LIBPFM_PACKAGE libpfm-4.6.0

ENV INSTALL_PACKAGES wget make gcc
ENV RUNTIME_PACKAGES cgroup-tools

COPY ${POWERAPI_PACKAGE}/target/universal/${POWERAPI_PACKAGE} /root/${POWERAPI_PACKAGE}/

VOLUME /conf /tmp

RUN apt-get update && apt-get -y upgrade && apt-get -y install $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
wget http://downloads.sourceforge.net/project/perfmon2/libpfm4/${LIBPFM_PACKAGE}.tar.gz && tar -C /root -xzvf ${LIBPFM_PACKAGE}.tar.gz && (cd /root/$LIBPFM_PACKAGE; make lib; make install) && rm -rf /root/$LIBPFM_PACKAGE ${LIBPFM_PACKAGE}.tar.gz && \
rm -rf /root/${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
apt-get -y remove --auto-remove $INSTALL_PACKAGES && \
rm -rf /var/lib/apt/lists/*

WORKDIR /root/$POWERAPI_PACKAGE

ENTRYPOINT ["./bin/powerapi"]
34 changes: 34 additions & 0 deletions docker/agent/Dockerfile-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:14.04

ARG NB_CORES
ARG UNHALTED_CYCLES_EVT
ARG UNHALTED_REF_CYCLES_EVT

ENV LIBPFM_PACKAGE libpfm-4.6.0

COPY docker/agent/Makefile /root/powerapi-agent/
COPY docker/agent/payload.proto /root/powerapi-agent/
COPY docker/agent/perf_util.c /root/powerapi-agent/
COPY docker/agent/perf_util.h /root/powerapi-agent/
COPY docker/agent/powerapi-agent.c /root/powerapi-agent/
COPY docker/agent/run.sh /root

VOLUME /tmp /apps

ENV INSTALL_PACKAGES ca-certificates pkg-config wget make gcc autoconf automake libtool g++
ENV RUNTIME_PACKAGES libdw-dev libunwind8-dev

RUN apt-get update && apt-get -y upgrade && apt-get -y install $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
wget http://downloads.sourceforge.net/project/perfmon2/libpfm4/${LIBPFM_PACKAGE}.tar.gz && tar -C /root -xzvf ${LIBPFM_PACKAGE}.tar.gz && (cd /root/$LIBPFM_PACKAGE; make lib; make install) && rm -rf /root/$LIBPFM_PACKAGE ${LIBPFM_PACKAGE}.tar.gz && \
wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz && tar -C /root -xzvf protobuf-2.6.1.tar.gz && (cd /root/protobuf-2.6.1; ./autogen.sh; ./configure; make; make install) && rm -rf /root/protobuf-2.6.1 protobuf-2.6.1.tar.gz && \
ldconfig && \
wget https://github.com/protobuf-c/protobuf-c/releases/download/v1.2.1/protobuf-c-1.2.1.tar.gz && tar -C /root -xzvf protobuf-c-1.2.1.tar.gz && (cd /root/protobuf-c-1.2.1; ./configure; make; make install) && rm -rf /root/protobuf-c-1.2.1 protobuf-c-1.2.1.tar.gz && \
ldconfig && \
(cd /root/powerapi-agent; make NB_CORES=${NB_CORES} UNHALTED_CYCLES_EVT=${UNHALTED_CYCLES_EVT} UNHALTED_REF_CYCLES_EVT=${UNHALTED_REF_CYCLES_EVT}) && \
mv /root/powerapi-agent/powerapi-agent /root/powerapi-agent-app && rm -rf /root/powerapi-agent && mv /root/powerapi-agent-app /root/powerapi-agent && \
apt-get -y remove --auto-remove $INSTALL_PACKAGES && \
rm -rf /var/lib/apt/lists/*

WORKDIR /root

ENTRYPOINT ["./run.sh"]
25 changes: 25 additions & 0 deletions docker/agent/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CC=cc
CFLAGS=-c -Wall -O0
INCLUDE=-I/usr/local/include
LDFLAGS=-L/usr/local/lib -lpfm -lprotobuf-c -L/usr/lib -lunwind -lunwind-generic -lunwind-ptrace -ldw
SOURCES=payload.pb-c.c perf_util.c powerapi-agent.c
OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=powerapi-agent

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(OBJECTS) -o $@ $(LDFLAGS)

payload.pb-c.c: payload.proto
protoc-c --c_out=. $<

powerapi-agent.o:
$(CC) $(CFLAGS) -D NB_CORES=$(NB_CORES) -D UNHALTED_CYCLES_EVT=\"$(UNHALTED_CYCLES_EVT)\" -D UNHALTED_REF_CYCLES_EVT=\"$(UNHALTED_REF_CYCLES_EVT)\" $(INCLUDE) powerapi-agent.c -o $@

.c.o:
$(CC) $(CFLAGS) $(INCLUDE) $< -o $@

clean:
rm -f $(OBJECTS) $(EXECUTABLE)
rm -rf payload.pb-c.c payload.pb-c.h
9 changes: 9 additions & 0 deletions docker/agent/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

docker create -v /apps --name apps_binary alpine /bin/true 2>/dev/null

if [ $? -ne 0 ]; then
echo "The docker volume for application binaries has already been created."
fi

exit 0
19 changes: 19 additions & 0 deletions docker/agent/payload.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto2";

option java_package = "org.powerapi.module.libpfm";
option java_outer_classname = "PayloadProtocol";

message MapEntry {
required string key=1;
required uint64 value=2;
}

message Payload {
required uint32 core=1;
required uint32 pid=2;
required uint32 tid=3;
required uint64 timestamp=4;
repeated MapEntry counters=5;
repeated string traces=6;
}

Loading