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

Commit 7ee3dde

Browse files
committed
feature(code-energy-analysis): create an app for producing power estimation at method level
The new app acts like a daemon for getting information about the function which has been at the origin of the interruption. A PowerAPI agent has to be attached to a program (which can be compiled with the -rdynamic option for now) for setting the interruption mode on it and getting information about the running function when the handler is triggered. The agent then sends data to PowerAPI other Unix sockets for computing power estimation.
1 parent ba56457 commit 7ee3dde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6665
-24
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ We all stand on the shoulders of giants and get by with a little help from our f
5858
* [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.
5959
* [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.
6060
* [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.
61+
* [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.
6162

6263
# License
6364
This software is licensed under the *GNU Affero General Public License*, quoted below.

docker/Dockerfile-cli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
FROM alpine:latest
1+
FROM alpine:3.3
22

33
ENV POWERAPI_PACKAGE powerapi-cli
44
ENV LIBPFM_PACKAGE libpfm-4.6.0
55

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

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

1212
VOLUME /conf
1313

1414
RUN apk update && apk upgrade && apk add $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
15-
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 && \
15+
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 && \
1616
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 && \
1717
rm -rf /root/${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
1818
apk del glibc $INSTALL_PACKAGES && \
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM alpine:3.3
2+
3+
ENV POWERAPI_PACKAGE powerapi-code-energy-analysis
4+
ENV LIBPFM_PACKAGE libpfm-4.6.0
5+
6+
ENV INSTALL_PACKAGES ca-certificates linux-headers libc-dev make gcc patch
7+
ENV RUNTIME_PACKAGES openjdk8-jre bash libcgroup-tools procps
8+
9+
COPY docker/libpfm/config.mk.patch /root/
10+
COPY ${POWERAPI_PACKAGE}/target/universal/${POWERAPI_PACKAGE} /root/${POWERAPI_PACKAGE}/
11+
12+
VOLUME /conf /tmp
13+
14+
RUN apk update && apk upgrade && apk add $INSTALL_PACKAGES $RUNTIME_PACKAGES --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ && \
15+
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 && \
16+
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 && \
17+
rm -rf /root/${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
18+
apk del glibc $INSTALL_PACKAGES && \
19+
rm -rf /var/cache/apk/*
20+
21+
WORKDIR /root/$POWERAPI_PACKAGE
22+
23+
ENTRYPOINT ["./bin/powerapi"]

docker/agent/Dockerfile-agent

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM ubuntu:14.04
2+
3+
ARG NB_CORES
4+
ARG SMPL_THRESHOLD
5+
ARG UNHALTED_CYCLES_EVT
6+
ARG UNHALTED_REF_CYCLES_EVT
7+
8+
ENV LIBPFM_PACKAGE libpfm-4.6.0
9+
10+
COPY docker/agent/Makefile /root/powerapi-agent/
11+
COPY docker/agent/payload.proto /root/powerapi-agent/
12+
COPY docker/agent/perf_util.c /root/powerapi-agent/
13+
COPY docker/agent/perf_util.h /root/powerapi-agent/
14+
COPY docker/agent/powerapi-agent.c /root/powerapi-agent/
15+
COPY docker/agent/run.sh /root
16+
17+
VOLUME /tmp /apps
18+
19+
ENV INSTALL_PACKAGES ca-certificates pkg-config wget make gcc autoconf automake libtool g++
20+
ENV RUNTIME_PACKAGES libdw-dev libunwind8-dev
21+
22+
RUN apt-get update && apt-get -y upgrade && apt-get -y install $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
23+
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 && \
24+
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 && \
25+
wget https://github.com/squidfunk/protobluff/archive/0.5.0.tar.gz && tar -C /root -xzvf 0.5.0.tar.gz && (cd /root/protobluff-0.5.0; ./autogen.sh; ./configure; make; make install) && rm -rf /root/protobluff-0.5.0 0.5.0.tar.gz && \
26+
ldconfig && \
27+
(cd /root/powerapi-agent; make NB_CORES=${NB_CORES} SMPL_THRESHOLD=${SMPL_THRESHOLD} UNHALTED_CYCLES_EVT=${UNHALTED_CYCLES_EVT} UNHALTED_REF_CYCLES_EVT=${UNHALTED_REF_CYCLES_EVT}) && \
28+
mv /root/powerapi-agent/powerapi-agent /root/powerapi-agent-app && rm -rf /root/powerapi-agent && mv /root/powerapi-agent-app /root/powerapi-agent && \
29+
apt-get -y remove --auto-remove $INSTALL_PACKAGES && \
30+
rm -rf /var/lib/apt/lists/*
31+
32+
WORKDIR /root
33+
34+
ENTRYPOINT ["./run.sh"]

docker/agent/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CC=cc
2+
CFLAGS=-c -Wall -O0
3+
INCLUDE=-I/usr/local/include
4+
LDFLAGS=-L/usr/local/lib -lpfm -lprotobluff -L/usr/lib -lunwind -lunwind-generic -lunwind-ptrace -ldw
5+
SOURCES=payload.pb.c perf_util.c powerapi-agent.c
6+
OBJECTS=$(SOURCES:.c=.o)
7+
EXECUTABLE=powerapi-agent
8+
9+
all: $(SOURCES) $(EXECUTABLE)
10+
11+
$(EXECUTABLE): $(OBJECTS)
12+
$(CC) $(OBJECTS) -o $@ $(LDFLAGS)
13+
14+
payload.pb.c: payload.proto
15+
protoc --protobluff_out=. $<
16+
17+
powerapi-agent.o:
18+
$(CC) $(CFLAGS) -D NB_CORES=$(NB_CORES) -D SMPL_THRESHOLD=$(SMPL_THRESHOLD) -D UNHALTED_CYCLES_EVT=\"$(UNHALTED_CYCLES_EVT)\" -D UNHALTED_REF_CYCLES_EVT=\"$(UNHALTED_REF_CYCLES_EVT)\" $(INCLUDE) powerapi-agent.c -o $@
19+
20+
.c.o:
21+
$(CC) $(CFLAGS) $(INCLUDE) $< -o $@
22+
23+
clean:
24+
rm -f $(OBJECTS) $(EXECUTABLE)
25+
rm -rf payload.pb.c payload.pb.h

docker/agent/init.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
docker create -v /apps --name apps_binary alpine /bin/true 2>/dev/null
4+
5+
if [ $? -ne 0 ]; then
6+
echo "The docker volume for application binaries has already been created."
7+
fi
8+
9+
exit 0

docker/agent/payload.pb.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Generated by the protobluff compiler - do not edit.
3+
* ----------------------------------------------------------------------------
4+
* Date: 03/29/16 14:06:32
5+
* Filename: payload.proto
6+
* Package: -
7+
* ----------------------------------------------------------------------------
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
11+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
13+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
14+
* IN THE SOFTWARE.
15+
*/
16+
17+
#include <protobluff/descriptor.h>
18+
19+
#include "payload.pb.h"
20+
21+
/* ----------------------------------------------------------------------------
22+
* Descriptors
23+
* ------------------------------------------------------------------------- */
24+
25+
/* MapEntry : descriptor */
26+
pb_descriptor_t
27+
mapentry_descriptor = { {
28+
(const pb_field_descriptor_t []){
29+
30+
/* required string key = 1 */
31+
{ .tag = 1,
32+
.name = "key",
33+
.type = STRING,
34+
.label = REQUIRED },
35+
36+
/* required uint64 value = 2 */
37+
{ .tag = 2,
38+
.name = "value",
39+
.type = UINT64,
40+
.label = REQUIRED }
41+
42+
}, 2 } };
43+
44+
/* Payload : descriptor */
45+
pb_descriptor_t
46+
payload_descriptor = { {
47+
(const pb_field_descriptor_t []){
48+
49+
/* required uint32 core = 1 */
50+
{ .tag = 1,
51+
.name = "core",
52+
.type = UINT32,
53+
.label = REQUIRED },
54+
55+
/* required uint32 pid = 2 */
56+
{ .tag = 2,
57+
.name = "pid",
58+
.type = UINT32,
59+
.label = REQUIRED },
60+
61+
/* required uint32 tid = 3 */
62+
{ .tag = 3,
63+
.name = "tid",
64+
.type = UINT32,
65+
.label = REQUIRED },
66+
67+
/* required uint64 timestamp = 4 */
68+
{ .tag = 4,
69+
.name = "timestamp",
70+
.type = UINT64,
71+
.label = REQUIRED },
72+
73+
/* repeated MapEntry counters = 5 */
74+
{ .tag = 5,
75+
.name = "counters",
76+
.type = MESSAGE,
77+
.label = REPEATED,
78+
.refer = &mapentry_descriptor },
79+
80+
/* repeated string traces = 6 */
81+
{ .tag = 6,
82+
.name = "traces",
83+
.type = STRING,
84+
.label = REPEATED }
85+
86+
}, 6 } };
87+

0 commit comments

Comments
 (0)