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

Commit ddd8b50

Browse files
committed
Merge pull request #80 from Spirals-Team/refactor/v4.0
feature(v4.0): refactoring
2 parents 61b8f46 + 2818e4d commit ddd8b50

File tree

303 files changed

+10389
-24174
lines changed

Some content is hidden

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

303 files changed

+10389
-24174
lines changed

.travis.yml

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,74 @@
1+
sudo: required
2+
3+
services:
4+
- docker
5+
6+
env:
7+
global:
8+
- secure: "BfP5e/OPM62e3ktm4RD2nuBJls2u8zdXg/YjNyght5dpD2vCjL6ZHWhgDM2mNFpzgYPiE3DPsSE7g2ZlsBUJCuK8a7lB5r+OiWFcWkilC1E9QX6OMcDTpEKb5A9InFGcpt0xbjY5+8qaIbaN8TJcdxaxeit0TZEvxeirQa5OOEY=" # COVERALLS_REPO_TOKEN
9+
- secure: "ldIw526YR2Fe6FlfIPlbbOojEeg7etbO4dqiL4TLm00SBhVkKG+DuckhFixVAvAJx1Q1LuVyUPsXaR77OjqiTxSkaH+GbsmR5VIM4qA/kBheD4IiV4wTamg679d+AldRNWcGtLpefgwqlCJ53FcMzUT9TH/MJcbEaOJ5GKW9v+s=" # CODACY_PROJECT_TOKEN
10+
- secure: "MLFJWju96LymkPNIsUeJelNN5J3BK55OV/RXVMONC5kDr4N7T4JyhT6KUa4k+FSJ0S1GTPQMWQQEkWDF1MlZXv5yGwW4h5rN3tt//vqyHk968SyqlhTdygqzx6tO6t3OsfQ2F1AqVWAWsHQckL+VmhEo53VqVXpsqLy9DyLYGjs=" # DOCKER_EMAIL
11+
- secure: "FbLHLKNAtpj7ZVgSobOPgAgdLK3/P4sR6RcaOmpVRsgaqodTPx7VkzGpkf4rOqPwxKU3+96vr0TlIdPRYWAE39Y3gMb1dyZ34+CxsrJ3avJYc2+9NT3kmAuU33Iy1DCo3IEnR7pWVVEyR80ob0c1ASfPAW1JN8DhBRRERpkMyn4=" # DOCKER_USER
12+
- secure: "VLK9NI4yE+hLV8rgjiB0hOfQn1uFO7cEHHL4sEDZKNu1TgvwfTrEWEzMMLvG8pwK/7eG78xfNB489m/Imj7Y52xK6sZuY7Y78Y06mkepZS8PisAJiW59kHWH1Ci84DYHZ0y07NAgvCOSLS9l0ncgLdlGvRboR9KBYDMEWycwEn8=" # DOCKER_PWD
13+
14+
cache:
15+
directories:
16+
- "$HOME/.m2/repository"
17+
- "$HOME/.sbt"
18+
- "$HOME/.ivy2"
19+
120
language: scala
21+
222
scala:
3-
- 2.11.6
23+
- 2.11.7
24+
25+
jdk:
26+
- openjdk7
27+
28+
# workaround for openjdk buffer overflow
29+
addons:
30+
hostname: localhost
31+
432
script:
5-
- sbt clean "project powerapi-core" coverage test
33+
- sbt compile test:compile
34+
- sbt 'set concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)' "project powerapi-core" coverage test
35+
- find $HOME/.sbt -name "*.lock" | xargs rm
36+
37+
before_install:
38+
- wget -O influxdb.deb https://s3.amazonaws.com/influxdb/influxdb_0.10.2-1_amd64.deb
39+
- sudo dpkg -i influxdb.deb
40+
- sudo service influxdb start
41+
- sleep 5; /usr/bin/influx --execute "CREATE USER powerapi WITH PASSWORD 'powerapi'
42+
WITH ALL PRIVILEGES"
43+
644
after_success:
745
- sbt "project powerapi-core" coverageReport
846
- sbt "project powerapi-core" codacyCoverage
947
- sbt "project powerapi-core" coveralls
48+
49+
before_deploy:
50+
- sbt "project powerapi-sampling" universal:packageZipTarball
51+
- sbt "project powerapi-cli" universal:packageZipTarball
52+
- tar -C powerapi-sampling/target/universal -xvf powerapi-sampling/target/universal/powerapi-sampling.tgz
53+
- tar -C powerapi-cli/target/universal -xvf powerapi-cli/target/universal/powerapi-cli.tgz
54+
55+
deploy:
56+
provider: releases
57+
api_key:
58+
secure: IEU1nWNWXW394yjC8/2Ch3naFM18mUmns9q11U0sCWMm9nz7ej4D5crKxCPtIHyHtFlONY1s0udBk6rv3aCVq0UikOysHFiVdPPeJTRCtGptxOb04/pZtq3vITcMzS9+CQc+yV8Y3A2vv15L/30ERMk1fgur+Nb+8vTFfXfzEik=
59+
file:
60+
- "powerapi-sampling/target/universal/powerapi-sampling.tgz"
61+
- "powerapi-cli/target/universal/powerapi-cli.tgz"
62+
skip_cleanup: true
63+
on:
64+
tags: true
65+
repo: Spirals-Team/powerapi
66+
67+
after_deploy:
68+
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PWD
69+
- docker build -f docker/sampling/Dockerfile-sampling -t spirals/powerapi-sampling:$TRAVIS_TAG .
70+
- docker build -f docker/Dockerfile-cli -t spirals/powerapi-cli:$TRAVIS_TAG .
71+
- docker tag spirals/powerapi-sampling:$TRAVIS_TAG spirals/powerapi-sampling:latest
72+
- docker tag spirals/powerapi-cli:$TRAVIS_TAG spirals/powerapi-cli:latest
73+
- docker push spirals/powerapi-sampling
74+
- docker push spirals/powerapi-cli

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ We all stand on the shoulders of giants and get by with a little help from our f
5656
* [Scala IO](http://jesseeichar.github.io/scala-io-doc/0.4.3/index.html#!/overview) (version 0.4.3 under [3-clause BSD license](http://www.scala-lang.org/license.html)), for an extensions of IO.
5757
* [Saddle](http://saddle.github.io/) (version 1.3.4 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for data manipulation.
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.
59-
* [spray-can](http://spray.io/) (version 1.3.3 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing a low-level, low-overhead, high-performance HTTP server and client.
60-
* [spray-client](http://spray.io/) (version 1.3.3 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing high-level HTTP client.
61-
* [spray-routing](http://spray.io/) (version 1.3.3 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing a high-level, very flexible routing DSL for elegantly defining RESTful web services.
62-
* [spray-json](http://spray.io/) (version 1.2.2 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for (de)serializing JSON.
63-
* [nscala-time](https://github.com/nscala-time/nscala-time) (version 2.8.0 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for using a scala wrapper for Joda Time (quality replacement for the Java date and time classes).
59+
* [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.
6460
* [docker-java](https://github.com/docker-java/docker-java) (version 2.1.4 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for using the JAVA Docker API.
61+
* [influxdb-java](https://github.com/influxdata/influxdb-java) (version 2.1 under [MIT license](https://github.com/influxdata/influxdb-java/blob/master/LICENSE)), for using the JAVA InfluxDB API.
6562

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

docker/Dockerfile-cli

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM alpine:latest
2+
3+
ENV POWERAPI_PACKAGE powerapi-cli
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 bluez bluez-dev openjdk7-jre bash 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
13+
14+
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 && \
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/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Docker version of PowerAPI
2+
3+
Lightweight docker images of PowerAPI packaged as docker images.
4+
5+
You have first to create a [data volume](https://docs.docker.com/engine/userguide/containers/dockervolumes/#creating-and-mounting-a-data-volume-container) to store the configuration files (`conf` directory) for PowerAPI.
6+
It will include all parameters needed to PowerAPI for configuring its internal components.
7+
The different parameters to set up are described inside the [Wiki](https://github.com/Spirals-Team/powerapi/wiki).
8+
9+
We assume that two data volumes `powerapi-cli-conf` and `powerapi-sampling-conf` are created on the host system.
10+
11+
### PowerAPI: CLI
12+
13+
This image is used to run automatically a various choices of software-defined power meters.
14+
15+
#### Usage
16+
17+
Show the help text:
18+
19+
```
20+
docker run --rm --privileged --net=host --pid=host \
21+
--volumes-from powerapi-cli-conf \
22+
spirals/powerapi-cli
23+
```
24+
25+
The `--privileged` option is used to get the root access to the host machine,
26+
the `--net=host` option is mandatory to be able to use the PowerSPY bluetooth power meter inside a container,
27+
and the `--pid=host` is required to be able to get an access to the running apps of the host machine.
28+
29+
A classic example with the `ProcFS` module can be:
30+
31+
powerapi.conf:
32+
33+
```
34+
powerapi.cpu.tdp = 35
35+
```
36+
37+
Associated docker command:
38+
39+
```
40+
docker run --rm --privileged --net=host --pid=host \
41+
--volumes-from powerapi-cli-conf \
42+
spirals/powerapi-cli \
43+
modules procfs-cpu-simple monitor --frequency 1000 --all --console
44+
```
45+
46+
### PowerAPI: Sampling
47+
48+
This image is used to build a CPU power model.
49+
50+
#### Usage
51+
52+
Launch the sampling:
53+
54+
```
55+
docker run --rm --privileged --net=host --pid=host \
56+
--volumes-from powerapi-sampling-conf \
57+
spirals/powerapi-sampling
58+
```
59+
60+
Example of a sampling configuration file:
61+
62+
sampling.conf:
63+
64+
```
65+
powerspy.mac = "00:0B:CE:07:1E:9B"
66+
67+
powerapi.cpu.topology = [
68+
{ core = 0, indexes = [0, 4] }
69+
{ core = 1, indexes = [1, 5] }
70+
{ core = 2, indexes = [2, 6] }
71+
{ core = 3, indexes = [3, 7] }
72+
]
73+
74+
powerapi.sampling.dvfs = true
75+
powerapi.sampling.turbo = true
76+
77+
powerapi.cycles-polynom-regression.cpu-base-frequency = 0.133
78+
powerapi.cycles-polynom-regression.cpu-max-frequency = 2.66
79+
powerapi.cycles-polynom-regression.unhalted-cycles-event = "CPU_CLK_UNHALTED:THREAD_P"
80+
powerapi.cycles-polynom-regression.ref-cycles-event = "CPU_CLK_UNHALTED:REF_P"
81+
82+
interval = 1s
83+
powerapi.actors.timeout = 15s
84+
powerapi.sampling.interval = ${interval}
85+
powerspy.interval = ${interval}
86+
powerapi.sampling.steps = [100, 25]
87+
powerapi.sampling.step-duration = 10
88+
```

docker/libpfm/config.mk.patch

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/config.mk
2+
+++ b/config.mk
3+
@@ -194,7 +194,7 @@ endif
4+
CC?=gcc
5+
LIBS=
6+
INSTALL=install
7+
-LDCONFIG=ldconfig
8+
+LDCONFIG=/usr/glibc/usr/bin/ldconfig
9+
LN?=ln -sf
10+
PFMINCDIR=$(TOPDIR)/include
11+
PFMLIBDIR=$(TOPDIR)/lib
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM alpine:latest
2+
3+
ENV POWERAPI_PACKAGE powerapi-sampling
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 bluez bluez-dev openjdk7-jre bash util-linux cpulimit procps
8+
9+
COPY docker/libpfm/config.mk.patch /root/
10+
COPY docker/sampling/run.sh /root/
11+
COPY ${POWERAPI_PACKAGE}/target/universal/${POWERAPI_PACKAGE}/ /root/${POWERAPI_PACKAGE}/
12+
13+
VOLUME /conf
14+
15+
RUN apk update && apk upgrade && apk add $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
16+
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 && \
17+
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 && \
18+
wget http://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz && tar -C /root -xzvf stress-1.0.4.tar.gz && (cd /root/stress-1.0.4; ./configure; make; make install) && rm -rf /root/stress-1.0.4 && \
19+
rm -rf /${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
20+
apk del glibc $INSTALL_PACKAGES && \
21+
rm -rf /var/cache/apk/*
22+
23+
WORKDIR /root
24+
25+
ENTRYPOINT ["./run.sh"]

docker/sampling/run.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+
cd powerapi-sampling && ./bin/sampling --all results/sampling results/processing results/computing
4+
5+
echo ""
6+
echo "Here is your CPU power model to use with PowerAPI"
7+
echo ""
8+
cat results/computing/libpfm-formula.conf
9+
echo ""

powerapi-cli/build.sbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name := "powerapi-cli"
22

3-
mappings in Universal += downloadBluecove.value -> s"lib/${downloadBluecove.value.name}"
4-
5-
mappings in Universal += downloadBluecoveGpl.value -> s"lib/${downloadBluecoveGpl.value.name}"
6-
73
mappings in Universal ++= {
84
val dir = baseDirectory.value.getParentFile
95

@@ -25,4 +21,8 @@ mappings in Universal ++= {
2521

2622
scriptClasspath ++= Seq("../conf", "../scripts")
2723

28-
NativePackagerKeys.executableScriptName := "powerapi"
24+
packageName in Universal := name.value
25+
26+
topLevelDirectory := Some(name.value)
27+
28+
executableScriptName := "powerapi"

0 commit comments

Comments
 (0)