-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #808 from jprendes/benchmark-memory
Benchmark memory
- Loading branch information
Showing
3 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
# Parse CLI arguments | ||
RUNTIME=${1:-"wasmtime"}; shift || true | ||
IMAGE=${1:-"ghcr.io/containerd/runwasi/wasi-demo-app:latest"}; shift || true | ||
|
||
if [ $IMAGE == "ghcr.io/containerd/runwasi/wasi-demo-app:latest" ] && [ "$#" == "0" ]; then | ||
set -- /wasi-demo-app.wasm echo 'hello' | ||
fi | ||
|
||
# Run the shim and collect logs | ||
LOG_FILE=$(mktemp) | ||
journalctl -fn 0 -u containerd | timeout -k 16s 15s grep -m 2 'peak memory usage was' > $LOG_FILE & | ||
ctr run --null-io --rm --runtime=io.containerd.$RUNTIME.v1 "$IMAGE" testwasm "$@" | ||
|
||
# Parse the logs | ||
wait | ||
SHIM_MEM=$(cat $LOG_FILE | grep 'Shim peak memory usage was' | sed -E 's/.*peak resident set ([0-9]+) kB.*/\1/') | ||
ZYGOTE_MEM=$(cat $LOG_FILE | grep 'Zygote peak memory usage was' | sed -E 's/.*peak resident set ([0-9]+) kB.*/\1/') | ||
rm $LOG_FILE | ||
|
||
if [ "$SHIM_MEM" == "" ] || [ "$ZYGOTE_MEM" == "" ]; then | ||
exit 1 | ||
fi | ||
|
||
TOTAL_MEM=$(( $SHIM_MEM + $ZYGOTE_MEM )) | ||
|
||
# Print the JSON for the benchmark report | ||
cat <<EOF | ||
[ | ||
{ | ||
"name": "$RUNTIME/memory-usage", | ||
"unit": "kB", | ||
"value": $TOTAL_MEM, | ||
"extra": "shim: $SHIM_MEM kB\nzygote: $ZYGOTE_MEM kB" | ||
} | ||
] | ||
EOF |