This project aims at showing how Diff-JJoules works and what can be done.
Diff-JJoules aims at measuring the impact of code changes (commit) on energy consumption.
The algorithm is as follow :
- Clone twice the project
- Each clone is set to a specific version, for example two successive commits
- Execute the tests on the two versions and select the tests as follow :
- Select the tests in the version before the commit that execute the lines that have been removed by the commit
- Select the tests in the version after the commit that execute the lines that have been added by the commit
- Instrument the tests that have been selected with special annotations to measure the energy consumption of each test
- Execute the instrumented tests on the two versions
- Observe the difference of tests' energy consumption program's version-wise; This difference approximate the impact of the commit on the global energy comsumption.
🚧
You need to install libpfm4
git clone https://github.com/davidson-consulting/tlpc-sensor
cd tlpc-sensor/examples/tlpc-sensor
mvn clean install -DskipTests
git clone https://github.com/STAMP-project/dspot.git
cd dspot
mvn clean install -DskipTests
git clone https://github.com/davidson-consulting/diff-jjoules
cd diff-jjoules
mvn clean install -DskipTests
cd diff-jjoules-maven
mvn clean install -DskipTests
sudo chmod -R 777 /sys/devices/virtual/powercap/intel-rapl/intel-rapl:*
sudo -i
echo -1 > /proc/sys/kernel/perf_event_paranoid
export MAVEN_OPTS="-XX:CompileThreshold=1 -XX:-TieredCompilation"
In this demo, the code changes is an artificial increase of the execution time of a method:
public void methodOne() {
consume(2000);
+ consume(2000);
}
🚧
To run the demo, you need to first clone twice this repository:
git clone https://github.com/davidson-consulting/diff-jjoules-demo.git /tmp/v1
git clone https://github.com/davidson-consulting/diff-jjoules-demo.git /tmp/v2
Then, checkout the v2
to the correct version:
cd v2
git checkout demo
Eventually, run diff-jjoules
:
cd /tmp/v1
mvn fr.davidson:diff-jjoules-maven:diff-jjoules -Dpath-dir-second-version=/tmp/v2/ -Dsuspect=false
The project needs perf
to work.
Perf is not as easy as doing apt install
in WSL.
One can have a look at: https://stackoverflow.com/a/74361501/5257140 that seems to work for the installation of perf in WSL.