Add the FIO demo

This commit is contained in:
LI Qing 2021-12-07 19:54:35 +08:00 committed by volcano
parent 96166dadc2
commit 3fa049df47
12 changed files with 189 additions and 3 deletions

@ -662,7 +662,6 @@ jobs:
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/sysbench/occlum_instance;
occlum run /bin/sysbench threads --threads=200 --thread-yields=100 --thread-locks=4 --time=30 run" occlum run /bin/sysbench threads --threads=200 --thread-yields=100 --thread-locks=4 --time=30 run"
Gvisor_syscalls_test: Gvisor_syscalls_test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
@ -769,3 +768,21 @@ jobs:
- name: Run the LTP demo - name: Run the LTP demo
run: docker exec ${{ github.job }} bash -c "cd /root/occlum/demos/linux-ltp/ltp_instance; 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" 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"

@ -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. * [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. * [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. * [fish](fish/): A demo of [FISH](https://fishshell.com) shell script.
* [flink](flink/): A demo of [Apache Flink](https://flink.apache.org). * [flink](flink/): A demo of [Apache Flink](https://flink.apache.org).
* [font](font/font_support_for_java): A demo of supporting font with Java. * [font](font/font_support_for_java): A demo of supporting font with Java.

2
demos/fio/.gitignore vendored Normal file

@ -0,0 +1,2 @@
fio_src/
occlum_instance/

16
demos/fio/README.md Normal file

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

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

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

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

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

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

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

14
demos/fio/fio.yaml Normal file

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

40
demos/fio/run_fio_on_occlum.sh Executable file

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