Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume and reboot modes #74

Merged
merged 29 commits into from
Nov 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0aa1af1
Travis-ci supports Python2.7 only. Documentation updated to match.
Oct 27, 2015
a1932a3
Add command-line arguments. --reboot and --resume now allowed.
Oct 22, 2015
bf59ced
Reboot mode implemented.
Oct 26, 2015
a7e6c9b
Basic test suit added for krun.util
Oct 26, 2015
0fcbf29
Refactoring krun and krun.util. Json code moved to krun.util and test…
Oct 26, 2015
cfb1684
Test whether two audits are from identical platforms
Oct 26, 2015
627cb2b
krun.util now provides functions to read results files
Oct 26, 2015
c2b26e5
Resume mode checks platform integrity.
Oct 26, 2015
52f2483
Implement resume mode.
Oct 27, 2015
7be48fd
Dry runs and debug levels now CLI options. Fixed an existing bug in d…
Oct 27, 2015
ed47933
Log files appended to in resume mode.
Oct 27, 2015
bb0d4cf
Ignore cpuinfo when comparing audits.
Oct 28, 2015
db88dcf
Disallow --reboot without --resume
Oct 29, 2015
18e5c4d
Resume mode does not send emails after every execution.
Oct 29, 2015
4a73de6
Reboot mode waits for network to come up after reboot.
Oct 29, 2015
0a93d88
Documented reboot and resume modes.
Oct 27, 2015
bcbbb28
Document --dryrun and --debug
Oct 27, 2015
c09e385
Example /etc/rc.local for reboot mode.
Oct 27, 2015
476fa3b
Add clean target to example benchmark Makefile.
Oct 28, 2015
f3335be
Implement --started-by-init. To be used by any script which automatic…
vext01 Oct 30, 2015
d6593b3
Add --started-by-init to example rc.local.linux
Oct 30, 2015
271e688
Document --started-by-init. Use the Krun name correctly.
Oct 30, 2015
d24c3e6
Don't reboot if exec queue is empty.
Nov 1, 2015
38e68b7
Basic tests for krun.env.
Nov 2, 2015
5d04e3d
Mocks for platform and mailer objects.
Nov 2, 2015
7a2541c
Extend tests for krun.util.
Nov 2, 2015
59a7a93
Refactor krun. Add tests for the scheduler and time estimate formatte…
Nov 2, 2015
62a0715
Add dependencies to travis install. Track test coverage in travis.
Nov 2, 2015
903fe78
Improvements to logging output.
vext01 Nov 2, 2015
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
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[run]
branch = True
omit = krun/tests/*

[report]
exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
# ignore abstract methods/properties mocked with pass
pass
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
examples/*.log
examples/*.json
examples/*.bz2
Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
language: python

python:
- "2.6"
- "2.7"

script: py.test
install:
- pip install cffi
- pip install pytest-cov

script: py.test --cov-report term --cov=krun krun
24 changes: 24 additions & 0 deletions etc/rc.local.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh -e
#
# /etc/rc.local
#
# This script is executed at the end of each multiuser runlevel.
# This means that once Krun has rebooted the machine, you will not
# see a login prompt until all benchmarks have finished.
#
# Verify this script by running:
# sudo service rc.local start
#

# Re-direct STDOUT and STDERR to a log file.
exec 2>>/var/log/rc.local.log
exec 1>&2

# Print commands as they are executed.
set -x

cd /home/krun/krun/examples
PYTHONPATH=../ python ../krun.py --resume --reboot --started-by-init --debug=INFO example.krun

# rc.local must always "exit 0" on success or any other value on error.
exit 0
81 changes: 71 additions & 10 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# krun example
# Krun example

This directory contains a simple experiment using krun.
This is a good starting point for setting up your own krun configuration.
This directory contains a simple experiment using Krun.
This is a good starting point for setting up your own Krun configuration.

The example here contains two benchmark programs (*nbody* and *dummy*),
executed on two VMs (*cPython* and a standard *JVM* such as HotSpot).
Expand All @@ -14,18 +14,22 @@ This configuration can be found in the file `examples/example.krun`.

## Step 1: prepare the benchmarking machine

krun currently only runs on Unix-like environments.
Krun currently only runs on Unix-like environments.
To run this example experiment, you need superuser rights to the machine you are
using, e.g. on Linux you should be able to run `sudo`.

### Dependencies

You need to have the following installed:

* Python
* Python2.7 (other versions of Python are not supported)
* a Java SDK (version 7)
* GNU make, a C compiler and libc (e.g. `sudo apt-get install build-essential`)
* cpufrequtils (e.g. `sudo apt-get install cpufrequtils`)
* cffi (e.g. `sudo apt-get install python-cffi`)

### Kernel arguments

If you are using a Linux system, you will need to set some kernel arguments.
If your Linux bootloader is Grub, you can follow these steps:

Expand All @@ -34,7 +38,7 @@ If your Linux bootloader is Grub, you can follow these steps:
* Add `intel_pstate=disable` to `GRUB_CMDLINE_LINUX_DEFAULT`
* Run `sudo update-grub`

Also for a Linux system, krun will insist that the kernel is running in
Also for a Linux system, Krun will insist that the kernel is running in
"tickless" mode. Tickless mode is a compile time kernel parameter, so if it is
not enabled, you will need to build a custom kernel. You can verify the
tickless mode of the current kernel with:
Expand All @@ -59,6 +63,8 @@ boot kernel.
For more information on tickless mode, see
[the kernel docs](https://www.kernel.org/doc/Documentation/timers/NO_HZ.txt).

### Create a user called krun

You will need to create a new user called `krun`, with minimal permissions:

```bash
Expand All @@ -68,7 +74,7 @@ sudo useradd krun
You will want to add this user to the `sudoers` group and make sure that
the user does not need a password for `sudo` as root.

## Step 2: Fetch the krun source
## Step 2: Fetch the Krun source

```bash
$ git clone https://github.com/softdevteam/krun.git
Expand All @@ -80,15 +86,15 @@ $ cd krun
```bash
$ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
```
## Step 4: Build krun
## Step 4: Build Krun

The krun Makefile honours the standard variables: `CC`, `CPPFLAGS`, `CFLAGS`
The Krun Makefile honours the standard variables: `CC`, `CPPFLAGS`, `CFLAGS`
and `LDFLAGS`. For example, if you wish to use `clang` rather than `gcc` you
can append `CC=/bin/clang` to the options here:

```bash
$ pwd
.../krun
.../Krun
$ make JAVA_CPPFLAGS='"-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux"' \
JAVA_LDFLAGS=-L${JAVA_HOME}/lib ENABLE_JAVA=1
```
Expand All @@ -114,6 +120,61 @@ $ PYTHONPATH=../ ../krun.py example.krun
You should see a log scroll past, and results will be stored in the file:
`../krun/examples/example_results.json.bz2`.

## Testing your configurations

It is often useful to test a configuration file, without actually
running a full benchmark (especially if the benchmark program is
long).
Krun supports this with the `--dryrun` command line switch:

```bash
$ PYTHONPATH=../ ../krun.py --dryrun --debug=INFO example.krun
```

By passing in `--debug=INFO` you will see a full log of krun actions
printed to STDOUT.
Valid debug levels are: `DEBUG`, `INFO`, `WARN`, `DEBUG`,
`CRITICAL`, `ERROR`.

## Running in reboot and resume modes

Krun can resume an interrupted benchmark by passing in the `--resume`
flag.
This will read and re-use results from previous executions of your
benchmarks, and run the remaining executions detailed in your configuration
file.

```bash
$ PYTHONPATH=../ ../krun.py --resume example.krun
```

You may wish to use this facility to reboot after every execution.
To do this, you can pass in the `--reboot` flag when you start Krun:

```bash
$ PYTHONPATH=../ ../krun.py --reboot example.krun
```

You will also need to ensure that Krun is restarted once the machine has
rebooted.
You can do this by hand, or by using the boot configuration provided by
your OS.
A boot configuration file should pass in the `--reboot`, `--resume` and
`started-by-init` flags to Krun.
This will suppress some emails that Krun sends out.

The `krun/etc` directory contains an `rc.local.linux` file which goes
with the examples here.
This file is compatible with some Linux machines.

### Testing a benchmark run with `--reboot`

If you need to test a benchmark configuration with `--reboot`, you can
still use the `--dryrun` flag.
In a dry run, Krun will not reboot your machine (it will simulate
rebooting by restarting Krun automatically) and will not pause to
wait for your network interface to come up.

## Creating your own experiments

The configuration file `examples/example.krun` controls the experiment here.
Expand Down
8 changes: 8 additions & 0 deletions examples/benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ JAVAC ?= javac

BENCHMARKS = dummy nbody

.PHONY: all clean

all:
for i in ${BENCHMARKS}; do \
echo "Building java benchmark $${i}..."; \
cd ${HERE}/$${i}/java && \
CLASSPATH=../../../../../krun/iterations_runners/ ${JAVAC} *.java; \
done

clean:
for i in ${BENCHMARKS}; do \
cd ${HERE}/$${i}/java && \
rm *.class; \
done
Loading