diff --git a/.github/workflows/demo_test.yml b/.github/workflows/demo_test.yml index ed9b3876..5e761004 100644 --- a/.github/workflows/demo_test.yml +++ b/.github/workflows/demo_test.yml @@ -595,7 +595,7 @@ jobs: run: | sleep ${{ env.nap_time }}; docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/golang/vault && ./run_occlum_vault_test.sh" - + sofaboot_test: runs-on: ubuntu-20.04 steps: @@ -662,7 +662,6 @@ jobs: run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/sysbench/occlum_instance; occlum run /bin/sysbench threads --threads=200 --thread-yields=100 --thread-locks=4 --time=30 run" - Gvisor_syscalls_test: runs-on: ubuntu-20.04 steps: @@ -768,4 +767,22 @@ jobs: - name: Run the LTP demo run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/linux-ltp/ltp_instance; - occlum run /opt/ltp/run-ltp.sh -f syscalls-occlum" \ No newline at end of file + occlum run /opt/ltp/run-ltp.sh -f syscalls-occlum" + + FIO_test: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + with: + submodules: true + + - uses: ./.github/workflows/composite_action/sim + with: + container-name: ${{ github.job }} + 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" + + - 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" diff --git a/demos/README.md b/demos/README.md index 31617eeb..5919eeef 100644 --- a/demos/README.md +++ b/demos/README.md @@ -16,6 +16,7 @@ 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. diff --git a/demos/fio/.gitignore b/demos/fio/.gitignore new file mode 100644 index 00000000..795496e8 --- /dev/null +++ b/demos/fio/.gitignore @@ -0,0 +1,2 @@ +fio_src/ +occlum_instance/ diff --git a/demos/fio/README.md b/demos/fio/README.md new file mode 100644 index 00000000..add21e87 --- /dev/null +++ b/demos/fio/README.md @@ -0,0 +1,16 @@ +# Use Flexible I/O Tester in SGX with Occlum + +This project demonstrates how Occlum enables the [Flexible I/O Tester(FIO)](https://github.com/axboe/fio) in SGX enclaves. + +Step 1: Download and build the FIO +``` +./download_and_build_fio.sh +``` +When completed, the FIO program is generated in the source directory of it. + +Step 2: Run the FIO program to test sequential read inside SGX enclave with Occlum +``` +./run_fio_on_occlum.sh fio-seq-read.fio +``` + +FIO uses a configuration file to run the I/O test. We have already copied and modified some configuration files from the `examples` directory of it. Please see the files in the [configs](configs/) for the detail. diff --git a/demos/fio/configs/fio-rand-read.fio b/demos/fio/configs/fio-rand-read.fio new file mode 100644 index 00000000..7bc8ebf7 --- /dev/null +++ b/demos/fio/configs/fio-rand-read.fio @@ -0,0 +1,16 @@ +; fio-rand-read.job for fiotest + +[global] +name=fio-rand-read +filename=/root/fio-rand-read +rw=randread +bs=4K +direct=0 +numjobs=1 +time_based +runtime=100 + +[file1] +size=256M +ioengine=sync +iodepth=16 diff --git a/demos/fio/configs/fio-rand-write.fio b/demos/fio/configs/fio-rand-write.fio new file mode 100644 index 00000000..e1abcee8 --- /dev/null +++ b/demos/fio/configs/fio-rand-write.fio @@ -0,0 +1,16 @@ +; fio-rand-write.job for fiotest + +[global] +name=fio-rand-write +filename=/root/fio-rand-write +rw=randwrite +bs=4K +direct=0 +numjobs=1 +time_based +runtime=100 + +[file1] +size=256M +ioengine=sync +iodepth=16 diff --git a/demos/fio/configs/fio-seq-read.fio b/demos/fio/configs/fio-seq-read.fio new file mode 100644 index 00000000..de15ce1a --- /dev/null +++ b/demos/fio/configs/fio-seq-read.fio @@ -0,0 +1,14 @@ +[global] +name=fio-seq-read +filename=/root/fio-seq-read +rw=read +bs=256K +direct=1 +numjobs=1 +time_based +runtime=100 + +[file1] +size=256M +ioengine=sync +iodepth=16 diff --git a/demos/fio/configs/fio-seq-write.fio b/demos/fio/configs/fio-seq-write.fio new file mode 100644 index 00000000..3838f3b2 --- /dev/null +++ b/demos/fio/configs/fio-seq-write.fio @@ -0,0 +1,16 @@ +; fio-seq-write.job for fiotest + +[global] +name=fio-seq-write +filename=/root/fio-seq-write +rw=write +bs=256K +direct=0 +numjobs=1 +time_based +runtime=100 + +[file1] +size=256M +ioengine=sync +iodepth=16 diff --git a/demos/fio/disable-fadvise.diff b/demos/fio/disable-fadvise.diff new file mode 100644 index 00000000..cd617382 --- /dev/null +++ b/demos/fio/disable-fadvise.diff @@ -0,0 +1,13 @@ +diff --git a/configure b/configure +index 84ccce04..ba205c92 100755 +--- a/configure ++++ b/configure +@@ -1068,7 +1068,7 @@ int main(int argc, char **argv) + } + EOF + if compile_prog "" "" "posix_fadvise"; then +- posix_fadvise="yes" ++ posix_fadvise="no" + fi + print_config "POSIX fadvise" "$posix_fadvise" + diff --git a/demos/fio/download_and_build_fio.sh b/demos/fio/download_and_build_fio.sh new file mode 100755 index 00000000..2fef878b --- /dev/null +++ b/demos/fio/download_and_build_fio.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +SRC=fio_src + +# Download FIO +if [ ! -d $SRC ];then + rm -rf $SRC && mkdir $SRC + cd $SRC + git clone https://github.com/axboe/fio.git . + git checkout tags/fio-3.28 + git apply ../disable-fadvise.diff +else + cd $SRC +fi + +# Build FIO +./configure --disable-shm --cc=occlum-gcc +make + +echo "Build FIO success!" diff --git a/demos/fio/fio.yaml b/demos/fio/fio.yaml new file mode 100644 index 00000000..880f4f7c --- /dev/null +++ b/demos/fio/fio.yaml @@ -0,0 +1,14 @@ +includes: + - base.yaml +# fio +targets: + # copy bins + - target: /bin + copy: + - files: + - ../fio_src/fio + # copy config files + - target: / + copy: + - dirs: + - ../configs diff --git a/demos/fio/run_fio_on_occlum.sh b/demos/fio/run_fio_on_occlum.sh new file mode 100755 index 00000000..a6d36631 --- /dev/null +++ b/demos/fio/run_fio_on_occlum.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +GREEN='\033[1;32m' +NC='\033[0m' + +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +bomfile=${SCRIPT_DIR}/fio.yaml + +FIO=fio +FIO_CONFIG=$1 + +if [ ! -e ${SCRIPT_DIR}/fio_src/${FIO} ];then + echo "Error: cannot stat '${FIO} in fio_src'" + echo "Please see README and build the ${FIO}" + exit 1 +fi + +if [ ! -e ${SCRIPT_DIR}/configs/${FIO_CONFIG} ] || [ -z ${FIO_CONFIG} ];then + echo "Error: cannot stat '${FIO_CONFIG}' in configs" + echo "Please copy it into configs first" + exit 1 +fi + +# 1. Init Occlum instance +rm -rf occlum_instance && occlum new occlum_instance +cd occlum_instance +TCS_NUM=$(($(nproc) * 2)) +new_json="$(jq --argjson THREAD_NUM ${TCS_NUM} '.resource_limits.max_num_of_threads = $THREAD_NUM ' Occlum.json)" && \ +echo "${new_json}" > Occlum.json + +# 2. Copy files into Occlum instance and build +rm -rf image +copy_bom -f $bomfile --root image --include-dir /opt/occlum/etc/template + +occlum build + +# 3. Run the program +echo -e "${GREEN}occlum run /bin/${FIO} /configs/${FIO_CONFIG}${NC}" +occlum run /bin/${FIO} "/configs/${FIO_CONFIG}"