diff --git a/.github/workflows/iouring.yml b/.github/workflows/iouring.yml new file mode 100644 index 00000000000..aab6457ec01 --- /dev/null +++ b/.github/workflows/iouring.yml @@ -0,0 +1,39 @@ +name: Async IO With IOUring + +on: [push, pull_request] + +jobs: + test-linux: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2', '8.3', '8.1-zts', '8.2-zts', '8.3-zts'] + name: ${{ matrix.php }} + steps: + - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + coverage: none + - name: Show machine information + run: | + date + env + uname -a + ulimit -a + php -v + php --ini + ls -al + pwd + echo "`git log -20 --pretty --oneline`" + echo "`git log -10 --stat --pretty --oneline`" + - name: Run Swoole test + run: | + export SWOOLE_BRANCH=${GITHUB_REF##*/} + export SWOOLE_USE_IOURING=1 + export SWOOLE_BUILD_DIR=$(realpath .) + export PHP_VERSION=${{ matrix.php }} + ${SWOOLE_BUILD_DIR}/scripts/route.sh + diff --git a/scripts/docker-compile-with-iouring.sh b/scripts/docker-compile-with-iouring.sh new file mode 100755 index 00000000000..2b40028731c --- /dev/null +++ b/scripts/docker-compile-with-iouring.sh @@ -0,0 +1,31 @@ +#!/bin/sh -e +__CURRENT__=$(pwd) +__DIR__=$(cd "$(dirname "$0")";pwd) + +if [ ! -f "/.dockerenv" ]; then + echo "" && echo "āŒ This script is just for Docker!" + exit +fi + +sh library.sh + +cd "${__DIR__}" && cd .. +./scripts/clear.sh && phpize + +mode=$(php -v | grep zts) +if [ "$mode" != "" ]; then + echo "" && echo "šŸš€ php zts + swoole thread mode + iouring!" + ./configure --enable-iouring --enable-thread +else + echo "" && echo "šŸš€ php nts + swoole + iouring!" + ./configure --enable-iouring +fi + +make -j$(cat /proc/cpuinfo | grep processor | wc -l) +make install +docker-php-ext-enable swoole +php -v +php -m +php --ri curl +php --ri swoole + diff --git a/scripts/docker-iouring-route.sh b/scripts/docker-iouring-route.sh new file mode 100755 index 00000000000..fe2274f23c2 --- /dev/null +++ b/scripts/docker-iouring-route.sh @@ -0,0 +1,23 @@ +#!/bin/sh -e +__CURRENT__=$(pwd) +__DIR__=$(cd "$(dirname "$0")";pwd) +export SWOOLE_USE_IOURING=1 + +# enter the dir +cd "${__DIR__}" + +# show system info +date && echo "" +uname -a && echo "" + +# show php info +php -v && echo "" + +# compile in docker +echo "" && echo "šŸ“¦ Compile ext-swoole[iouring] in docker..." && echo "" +./docker-compile-with-iouring.sh + +# run unit tests +echo "" && echo "šŸ“‹ Run php tests[iouring] in docker..." && echo "" +./run-tests.sh + diff --git a/scripts/library.sh b/scripts/library.sh old mode 100644 new mode 100755 index d28650163c1..fe85638c640 --- a/scripts/library.sh +++ b/scripts/library.sh @@ -12,3 +12,8 @@ echo DISABLE_INTERRUPT=on > ./instantclient/network/admin/sqlnet.ora mv ./instantclient /usr/local/ echo '/usr/local/instantclient' > /etc/ld.so.conf.d/oracle-instantclient.conf ldconfig + +wget https://github.com/axboe/liburing/archive/refs/tags/liburing-2.6.tar.gz +tar zxf liburing-2.6.tar.gz +cd liburing-liburing-2.6 && ./configure && make -j$(cat /proc/cpuinfo | grep processor | wc -l) && make install + diff --git a/scripts/route.sh b/scripts/route.sh index 0b7d9af0ea7..0b6dae02940 100755 --- a/scripts/route.sh +++ b/scripts/route.sh @@ -92,6 +92,16 @@ run_thread_tests_in_docker(){ fi } +run_iouring_tests_in_docker(){ + docker exec swoole touch /.cienv && \ + docker exec swoole /swoole-src/scripts/docker-iouring-route.sh + code=$? + if [ $code -ne 0 ]; then + echo "\nāŒ Run iouring tests failed! ExitCode: $code" + exit 1 + fi +} + remove_tests_resources(){ remove_docker_containers remove_data_files @@ -109,6 +119,8 @@ echo "\nā³ Run tests in docker...\n" if [ "$SWOOLE_THREAD" = 1 ]; then run_thread_tests_in_docker +elif [ "$SWOOLE_USE_IOURING" = 1 ]; then + run_iouring_tests_in_docker else run_tests_in_docker fi diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 774bbf14059..3384dd0c26b 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -61,6 +61,8 @@ if [ "${SWOOLE_BRANCH}" = "valgrind" ]; then options="${options} -m" elif [ "$SWOOLE_THREAD" = 1 ]; then dir="swoole_thread" +elif [ "$SWOOLE_USE_IOURING" = 1 ]; then + dir="swoole_runtime/file_hook" else dir="swoole_*" fi