From 3c11d589f40b778c2ff85065b11d75260dcfc466 Mon Sep 17 00:00:00 2001 From: "Zheng, Qi" Date: Wed, 30 Nov 2022 14:14:57 +0800 Subject: [PATCH] [demos] Move all the benchmark demos together --- .github/workflows/demo_test.yml | 16 ++++---- demos/README.md | 11 +++++- demos/benchmarks/README.md | 9 +++++ demos/{ => benchmarks}/fio/.gitignore | 0 demos/{ => benchmarks}/fio/README.md | 0 .../fio/configs/fio-rand-read.fio | 0 .../fio/configs/fio-rand-write.fio | 0 .../fio/configs/fio-seq-read.fio | 0 .../fio/configs/fio-seq-write.fio | 0 .../{ => benchmarks}/fio/disable-fadvise.diff | 0 .../fio/download_and_build_fio.sh | 0 demos/{ => benchmarks}/fio/fio.yaml | 0 .../{ => benchmarks}/fio/run_fio_on_occlum.sh | 0 demos/{ => benchmarks}/iperf2/README.md | 0 demos/{ => benchmarks}/iperf2/build.sh | 2 +- demos/{ => benchmarks}/iperf2/iperf2.yaml | 2 +- demos/benchmarks/iperf3/README.md | 28 +++++++++++++ demos/benchmarks/iperf3/build.sh | 39 +++++++++++++++++++ demos/benchmarks/iperf3/iperf3.yaml | 13 +++++++ demos/{ => benchmarks}/sysbench/README.md | 0 .../{ => benchmarks}/sysbench/dl_and_build.sh | 0 .../sysbench/prepare_sysbench.sh | 2 +- demos/{ => benchmarks}/sysbench/sysbench.yaml | 0 23 files changed, 110 insertions(+), 12 deletions(-) create mode 100644 demos/benchmarks/README.md rename demos/{ => benchmarks}/fio/.gitignore (100%) rename demos/{ => benchmarks}/fio/README.md (100%) rename demos/{ => benchmarks}/fio/configs/fio-rand-read.fio (100%) rename demos/{ => benchmarks}/fio/configs/fio-rand-write.fio (100%) rename demos/{ => benchmarks}/fio/configs/fio-seq-read.fio (100%) rename demos/{ => benchmarks}/fio/configs/fio-seq-write.fio (100%) rename demos/{ => benchmarks}/fio/disable-fadvise.diff (100%) rename demos/{ => benchmarks}/fio/download_and_build_fio.sh (100%) rename demos/{ => benchmarks}/fio/fio.yaml (100%) rename demos/{ => benchmarks}/fio/run_fio_on_occlum.sh (100%) rename demos/{ => benchmarks}/iperf2/README.md (100%) rename demos/{ => benchmarks}/iperf2/build.sh (96%) rename demos/{ => benchmarks}/iperf2/iperf2.yaml (70%) create mode 100644 demos/benchmarks/iperf3/README.md create mode 100755 demos/benchmarks/iperf3/build.sh create mode 100644 demos/benchmarks/iperf3/iperf3.yaml rename demos/{ => benchmarks}/sysbench/README.md (100%) rename demos/{ => benchmarks}/sysbench/dl_and_build.sh (100%) rename demos/{ => benchmarks}/sysbench/prepare_sysbench.sh (92%) rename demos/{ => benchmarks}/sysbench/sysbench.yaml (100%) diff --git a/.github/workflows/demo_test.yml b/.github/workflows/demo_test.yml index bcc03c8d..96662fff 100644 --- a/.github/workflows/demo_test.yml +++ b/.github/workflows/demo_test.yml @@ -653,13 +653,13 @@ jobs: build-envs: 'OCCLUM_RELEASE_BUILD=1' - name: Run sysbench download and build - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/sysbench && SGX_MODE=SIM ./dl_and_build.sh" + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/sysbench && SGX_MODE=SIM ./dl_and_build.sh" - name: Run prepare sysbench occlum instance - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/sysbench && SGX_MODE=SIM ./prepare_sysbench.sh" + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/sysbench && SGX_MODE=SIM ./prepare_sysbench.sh" - name: Run sysbench threads benchmark - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/sysbench/occlum_instance; + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/sysbench/occlum_instance; occlum run /bin/sysbench threads --threads=200 --thread-yields=100 --thread-locks=4 --time=30 run" Gvisor_syscalls_test: @@ -735,16 +735,16 @@ jobs: build-envs: 'OCCLUM_RELEASE_BUILD=1' - name: Build iperf2 - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/iperf2; SGX_MODE=SIM ./build.sh" + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/iperf2; SGX_MODE=SIM ./build.sh" - name: Start iperf2 server - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/iperf2/occlum_server; + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/iperf2/occlum_server; occlum run /bin/iperf -s -p 6888 &" - name: Start iperf2 client run: | sleep ${{ 5 }}; - docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/iperf2/occlum_client; + docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/iperf2/occlum_client; occlum run /bin/iperf -c 127.0.0.1 -p 6888 -P 16" Linux_LTP_test: @@ -782,7 +782,7 @@ jobs: build-envs: 'OCCLUM_RELEASE_BUILD=1' - name: Build fio dependencies - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/fio && ./download_and_build_fio.sh" + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/fio && ./download_and_build_fio.sh" - name: Run fio test - run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/fio && SGX_MODE=SIM ./run_fio_on_occlum.sh fio-seq-read.fio" + run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/benchmarks/fio && SGX_MODE=SIM ./run_fio_on_occlum.sh fio-seq-read.fio" diff --git a/demos/README.md b/demos/README.md index 5919eeef..9c1e4671 100644 --- a/demos/README.md +++ b/demos/README.md @@ -16,7 +16,6 @@ This set of demos shows how real-world apps can be easily run inside SGX enclave * [bash](bash/): A demo of [Bash](https://www.gnu.org/software/bash/) shell script. * [cluster_serving](cluster_serving/): A demo of [Analytics Zoo Cluster Serving](https://analytics-zoo.github.io/master/#ClusterServingGuide/ProgrammingGuide/) inference solution. -* [fio](fio/): A demo of [Flexible I/O Tester](https://github.com/axboe/fio). * [fish](fish/): A demo of [FISH](https://fishshell.com) shell script. * [flink](flink/): A demo of [Apache Flink](https://flink.apache.org). * [font](font/font_support_for_java): A demo of supporting font with Java. @@ -33,6 +32,16 @@ This set of demos shows how real-world apps can be easily run inside SGX enclave * [vault](golang/vault/): A demo of [HashiCorp Vault](https://github.com/hashicorp/vault). * [xgboost](xgboost/): A demo of [XGBoost](https://xgboost.readthedocs.io/en/latest). +## Benchmark demos + +This set of demos shows how commonly used benchmarking tools can be run inside SGX enclaves with Occlum. + +* [fio](benchmarks/fio/): A demo of [Flexible I/O Tester](https://github.com/axboe/fio). +* [iperf2](benchmarks/iperf2/): A demo of [Iperf2](https://sourceforge.net/projects/iperf2/), a tool for measuring Internet bandwidth performance. +* [iperf3](benchmarks/iperf3/): A demo of [Iperf3](https://github.com/esnet/iperf), a tool for measuring Internet bandwidth performance. +* [sysbench](benchmarks/sysbench/): A demo of [Sysbench](https://github.com/akopytov/sysbench), a scriptable multi-threaded benchmark tool for Linux. + + ## Programming language demos This set of demos shows how apps written with popular programming languages can be run inside SGX enclaves with Occlum. diff --git a/demos/benchmarks/README.md b/demos/benchmarks/README.md new file mode 100644 index 00000000..3e664bf7 --- /dev/null +++ b/demos/benchmarks/README.md @@ -0,0 +1,9 @@ +# Benchmark Demos + +This set of demos shows how commonly used benchmarking tools can be run inside SGX enclaves with Occlum. + +* [fio](fio/): A demo of [Flexible I/O Tester](https://github.com/axboe/fio). +* [iperf2](iperf2/): A demo of [Iperf2](https://sourceforge.net/projects/iperf2/), a tool for measuring Internet bandwidth performance. +* [iperf3](iperf3/): A demo of [Iperf3](https://github.com/esnet/iperf), a tool for measuring Internet bandwidth performance. +* [sysbench](sysbench/): A demo of [Sysbench](https://github.com/akopytov/sysbench), a scriptable multi-threaded benchmark tool for Linux. + diff --git a/demos/fio/.gitignore b/demos/benchmarks/fio/.gitignore similarity index 100% rename from demos/fio/.gitignore rename to demos/benchmarks/fio/.gitignore diff --git a/demos/fio/README.md b/demos/benchmarks/fio/README.md similarity index 100% rename from demos/fio/README.md rename to demos/benchmarks/fio/README.md diff --git a/demos/fio/configs/fio-rand-read.fio b/demos/benchmarks/fio/configs/fio-rand-read.fio similarity index 100% rename from demos/fio/configs/fio-rand-read.fio rename to demos/benchmarks/fio/configs/fio-rand-read.fio diff --git a/demos/fio/configs/fio-rand-write.fio b/demos/benchmarks/fio/configs/fio-rand-write.fio similarity index 100% rename from demos/fio/configs/fio-rand-write.fio rename to demos/benchmarks/fio/configs/fio-rand-write.fio diff --git a/demos/fio/configs/fio-seq-read.fio b/demos/benchmarks/fio/configs/fio-seq-read.fio similarity index 100% rename from demos/fio/configs/fio-seq-read.fio rename to demos/benchmarks/fio/configs/fio-seq-read.fio diff --git a/demos/fio/configs/fio-seq-write.fio b/demos/benchmarks/fio/configs/fio-seq-write.fio similarity index 100% rename from demos/fio/configs/fio-seq-write.fio rename to demos/benchmarks/fio/configs/fio-seq-write.fio diff --git a/demos/fio/disable-fadvise.diff b/demos/benchmarks/fio/disable-fadvise.diff similarity index 100% rename from demos/fio/disable-fadvise.diff rename to demos/benchmarks/fio/disable-fadvise.diff diff --git a/demos/fio/download_and_build_fio.sh b/demos/benchmarks/fio/download_and_build_fio.sh similarity index 100% rename from demos/fio/download_and_build_fio.sh rename to demos/benchmarks/fio/download_and_build_fio.sh diff --git a/demos/fio/fio.yaml b/demos/benchmarks/fio/fio.yaml similarity index 100% rename from demos/fio/fio.yaml rename to demos/benchmarks/fio/fio.yaml diff --git a/demos/fio/run_fio_on_occlum.sh b/demos/benchmarks/fio/run_fio_on_occlum.sh similarity index 100% rename from demos/fio/run_fio_on_occlum.sh rename to demos/benchmarks/fio/run_fio_on_occlum.sh diff --git a/demos/iperf2/README.md b/demos/benchmarks/iperf2/README.md similarity index 100% rename from demos/iperf2/README.md rename to demos/benchmarks/iperf2/README.md diff --git a/demos/iperf2/build.sh b/demos/benchmarks/iperf2/build.sh similarity index 96% rename from demos/iperf2/build.sh rename to demos/benchmarks/iperf2/build.sh index 44809748..75fe9e81 100755 --- a/demos/iperf2/build.sh +++ b/demos/benchmarks/iperf2/build.sh @@ -35,4 +35,4 @@ function build_occlum_instance() dl_and_build_iperf build_occlum_instance occlum_server -build_occlum_instance occlum_client \ No newline at end of file +build_occlum_instance occlum_client diff --git a/demos/iperf2/iperf2.yaml b/demos/benchmarks/iperf2/iperf2.yaml similarity index 70% rename from demos/iperf2/iperf2.yaml rename to demos/benchmarks/iperf2/iperf2.yaml index 23f9ef7c..1b638f57 100644 --- a/demos/iperf2/iperf2.yaml +++ b/demos/benchmarks/iperf2/iperf2.yaml @@ -6,4 +6,4 @@ targets: - target: /bin copy: - files: - - ${IPERF_INSTALL_DIR}/bin/iperf \ No newline at end of file + - ${IPERF_INSTALL_DIR}/bin/iperf diff --git a/demos/benchmarks/iperf3/README.md b/demos/benchmarks/iperf3/README.md new file mode 100644 index 00000000..d3dc817b --- /dev/null +++ b/demos/benchmarks/iperf3/README.md @@ -0,0 +1,28 @@ +# Run iperf3 on Occlum + +[`Iperf3`](https://github.com/esnet/iperf) is a popular tool for measuring Internet bandwidth performance. + +### Build +``` +./build.sh +``` + +If everything goes well, it generates two occlum instances. +``` +occlum_server +occlum_client +``` + +### Run the test + +* Start the iperf3 server for on one time benchmark +``` +cd occlum_server +occlum run /bin/iperf3 -s -p 6777 -1 +``` + +* Start the iperf3 client with 16 streams +``` +cd occlum_client +occlum run /bin/iperf3 -c 127.0.0.1 -p 6777 -P 16 +``` diff --git a/demos/benchmarks/iperf3/build.sh b/demos/benchmarks/iperf3/build.sh new file mode 100755 index 00000000..2de4cef8 --- /dev/null +++ b/demos/benchmarks/iperf3/build.sh @@ -0,0 +1,39 @@ +#! /bin/bash +set -e + +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +export IPERF3_INSTALL_DIR=${script_dir}/iperf-install + +function dl_and_build_iperf() +{ + rm -rf iperf-* + rm -rf 3.11* + mkdir -p ${IPERF3_INSTALL_DIR} + wget https://github.com/esnet/iperf/archive/refs/tags/3.11.tar.gz + tar zxf 3.11.tar.gz + pushd iperf-3.11 + ./configure + make install exec_prefix=${IPERF3_INSTALL_DIR} + popd +} + +function build_occlum_instance() +{ + name=$1 + rm -rf ${name} + occlum new ${name} + pushd ${name} + copy_bom -f ../iperf3.yaml --root image --include-dir /opt/occlum/etc/template + + new_json="$(jq '.resource_limits.user_space_size = "1000MB" | + .resource_limits.max_num_of_threads = 64 ' Occlum.json)" && \ + echo "${new_json}" > Occlum.json + + occlum build + popd +} + +dl_and_build_iperf +build_occlum_instance occlum_server +build_occlum_instance occlum_client diff --git a/demos/benchmarks/iperf3/iperf3.yaml b/demos/benchmarks/iperf3/iperf3.yaml new file mode 100644 index 00000000..f70f89e3 --- /dev/null +++ b/demos/benchmarks/iperf3/iperf3.yaml @@ -0,0 +1,13 @@ +includes: + - base.yaml +# bash +targets: + # copy iperf + - target: /bin + copy: + - files: + - ${IPERF3_INSTALL_DIR}/bin/iperf3 + - target: /opt/occlum/glibc/lib + copy: + - files: + - ${IPERF3_INSTALL_DIR}/lib/libiperf.so.0 diff --git a/demos/sysbench/README.md b/demos/benchmarks/sysbench/README.md similarity index 100% rename from demos/sysbench/README.md rename to demos/benchmarks/sysbench/README.md diff --git a/demos/sysbench/dl_and_build.sh b/demos/benchmarks/sysbench/dl_and_build.sh similarity index 100% rename from demos/sysbench/dl_and_build.sh rename to demos/benchmarks/sysbench/dl_and_build.sh diff --git a/demos/sysbench/prepare_sysbench.sh b/demos/benchmarks/sysbench/prepare_sysbench.sh similarity index 92% rename from demos/sysbench/prepare_sysbench.sh rename to demos/benchmarks/sysbench/prepare_sysbench.sh index 69d0e4eb..c99b3596 100755 --- a/demos/sysbench/prepare_sysbench.sh +++ b/demos/benchmarks/sysbench/prepare_sysbench.sh @@ -10,7 +10,7 @@ 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 +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/benchmarks/sysbench/sysbench.yaml similarity index 100% rename from demos/sysbench/sysbench.yaml rename to demos/benchmarks/sysbench/sysbench.yaml