Add sysbench demo case

This commit is contained in:
Zheng, Qi 2021-11-16 14:27:23 +08:00 committed by Zongmin.Gu
parent fc7ba98ded
commit 94ce37bb9f
4 changed files with 83 additions and 0 deletions

39
demos/sysbench/README.md Normal file

@ -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
```

19
demos/sysbench/dl_and_build.sh Executable file

@ -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

@ -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

@ -0,0 +1,9 @@
includes:
- base.yaml
# sysbench
targets:
# copy sysbench
- target: /bin
copy:
- files:
- ../sysbench-install/bin/sysbench