Skip to content

Commit

Permalink
examples: add osv-memusage
Browse files Browse the repository at this point in the history
this ukbench script measures the peak RSS of an OSv unikernel for
Firecracker and QEMU (helloworld).

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
  • Loading branch information
hlef committed Jan 7, 2021
1 parent 839d5e8 commit a912f89
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/osv-memusage/osv-memusage.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/scripts/firecracker.py b/scripts/firecracker.py
index d0b24071..b26f6cd7 100755
--- a/scripts/firecracker.py
+++ b/scripts/firecracker.py
@@ -237,7 +237,7 @@ def start_firecracker_with_no_api(firecracker_path, firecracker_config_json):
api_file.write(bytes(firecracker_config_json, 'utf-8'))
api_file.flush()
stty_save()
- return subprocess.Popen([firecracker_path, "--no-api", "--config-file", api_file.name],
+ return subprocess.Popen(['/usr/bin/time', '-f', 'Firecracker maxRSS: %M', firecracker_path, "--no-api", "--config-file", api_file.name],
stdout=sys.stdout, stderr=subprocess.STDOUT), api_file.name


diff --git a/scripts/run.py b/scripts/run.py
index c7464bda..d9cdbeaf 100755
--- a/scripts/run.py
+++ b/scripts/run.py
@@ -272,7 +272,7 @@ def start_osv_qemu(options):

qemu_env['OSV_BRIDGE'] = options.bridge
qemu_path = options.qemu_path or ('qemu-system-%s' % options.arch)
- cmdline = [qemu_path] + args
+ cmdline = ['/usr/bin/time', '-f', 'QEMU maxRSS: %M', qemu_path] + args
if options.dry_run:
print(format_args(cmdline))
else:
46 changes: 46 additions & 0 deletions examples/osv-memusage/osv-memusage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
params:
- name: TEST
type: string
only: ["Hello"]

inputs:
- source: osv-memusage.patch
destination: /root/osv-memusage.patch
- source: /etc/resolv.conf
destination: /etc/resolv.conf
- source: /etc/environment
destination: /etc/environment

outputs:
- path: /results.txt

runs:
- name: run
image: hlefeuvre/osv
cores: 1
devices:
- /dev/kvm
- /dev/net/tun
capabilities:
- CAP_NET_ADMIN
cmd:
|
set -xe
for env in $( cat /etc/environment ); do \
export $(echo $env | sed -e 's/"//g'); \
done

env

touch /results.txt

apt update && apt install -y time

cd /root/osv/
git apply --ignore-space-change /root/osv-memusage.patch

script -c '/root/osv/scripts/run.py' -f /tmp/out
cat /tmp/out | grep "QEMU maxRSS: " >> /results.txt
script -c '/root/osv/scripts/firecracker.py' -f /tmp/out
cat /tmp/out | grep "Firecracker maxRSS: " >> /results.txt

0 comments on commit a912f89

Please sign in to comment.