diff --git a/demos/sysbench/README.md b/demos/sysbench/README.md new file mode 100644 index 00000000..9ce715d6 --- /dev/null +++ b/demos/sysbench/README.md @@ -0,0 +1,39 @@ +# Run Linux sysbench + +In this demo, we will show how to run the Linux sysbench inside Occlum. + +Linux [`sysbench`](https://github.com/akopytov/sysbench) is a scriptable multi-threaded benchmark tool. +Occlum could also run the `sysbench` for CPU/Threads/Memory/Mutex/... benchmarks. + +Please note it is configured with "--without-mysql", so no mysql database benchmark can be done. + +## Download and build the Linux sysbench from source code +``` +./dl_and_build.sh +``` + +## Prepare the Occlum instance for sysbench demo +``` +./prepare_sysbench.sh +``` + +## Run the sysbench demo + +For example, + +* CPU benchmark +``` +occlum/demos/sysbench/occlum_instance# occlum run /bin/sysbench cpu --cpu-max-prime=2000 --threads=2 run +``` + +* threads benchmark +``` +# occlum/demos/sysbench/occlum_instance# occlum run /bin/sysbench threads --threads=200 --thread-yields=100 --thread-locks=4 --time=10 run +``` + +More test commands could refer to +``` +# occlum/demos/sysbench/occlum_instance# occlum run /bin/sysbench --help +``` + + diff --git a/demos/sysbench/dl_and_build.sh b/demos/sysbench/dl_and_build.sh new file mode 100755 index 00000000..53160117 --- /dev/null +++ b/demos/sysbench/dl_and_build.sh @@ -0,0 +1,19 @@ +#! /bin/bash +set -e + +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +TAG=1.0.20 +SYSBENCH_ISNTALL_DIR=${SCRIPT_DIR}/sysbench-install + +rm -rf sysbench-* $TAG.tar.gz* +wget https://github.com/akopytov/sysbench/archive/refs/tags/$TAG.tar.gz +tar zxvf $TAG.tar.gz + +pushd sysbench-$TAG +./autogen.sh +./configure --without-mysql --prefix=${SYSBENCH_ISNTALL_DIR} +make -j +make install +popd + diff --git a/demos/sysbench/prepare_sysbench.sh b/demos/sysbench/prepare_sysbench.sh new file mode 100755 index 00000000..69d0e4eb --- /dev/null +++ b/demos/sysbench/prepare_sysbench.sh @@ -0,0 +1,16 @@ +#! /bin/bash +set -e + +rm -rf occlum_instance +occlum new occlum_instance + +cd occlum_instance +rm -rf image +copy_bom -f ../sysbench.yaml --root image --include-dir /opt/occlum/etc/template + +new_json="$(jq '.resource_limits.user_space_size = "800MB" | + .resource_limits.max_num_of_threads = 256 ' Occlum.json)" && \ + echo "${new_json}" > Occlum.json + +occlum build +#occlum run /bin/sysbench threads --threads=200 --thread-yields=100 --thread-locks=4 --time=10 run diff --git a/demos/sysbench/sysbench.yaml b/demos/sysbench/sysbench.yaml new file mode 100644 index 00000000..9ce4651e --- /dev/null +++ b/demos/sysbench/sysbench.yaml @@ -0,0 +1,9 @@ +includes: + - base.yaml +# sysbench +targets: + # copy sysbench + - target: /bin + copy: + - files: + - ../sysbench-install/bin/sysbench