Skip to content

Commit

Permalink
revert iouring
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed May 24, 2024
1 parent 9ce89a8 commit 49716c9
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 823 deletions.
12 changes: 0 additions & 12 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ PHP_ARG_ENABLE([cares],
[AS_HELP_STRING([--enable-cares],
[Enable cares])], [no], [no])

PHP_ARG_ENABLE([iouring],
[enable io-uring support],
[AS_HELP_STRING([--enable-iouring],
[Enable io-uring (Experimental)])], [no], [no])

PHP_ARG_WITH([openssl_dir],
[dir of openssl],
[AS_HELP_STRING([[--with-openssl-dir[=DIR]]],
Expand Down Expand Up @@ -903,13 +898,6 @@ EOF
PHP_ADD_LIBRARY(cares, 1, SWOOLE_SHARED_LIBADD)
fi

if test "$PHP_IOURING" = "yes"; then
AC_CHECK_LIB(uring, io_uring_queue_init, [
AC_DEFINE(SW_USE_IOURING, 1, [have io_uring])
PHP_ADD_LIBRARY(uring, 1, SWOOLE_SHARED_LIBADD)
])
fi

AC_SWOOLE_CPU_AFFINITY
AC_SWOOLE_HAVE_REUSEPORT
AC_SWOOLE_HAVE_FUTEX
Expand Down
3 changes: 0 additions & 3 deletions ext-src/php_swoole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,6 @@ PHP_MINFO_FUNCTION(swoole) {
#endif
#ifdef SW_USE_SQLITE
php_info_print_table_row(2, "coroutine_sqlite", "enabled");
#endif
#ifdef SW_USE_IOURING
php_info_print_table_row(2, "io_uring", "enabled");
#endif
php_info_print_table_end();

Expand Down
4 changes: 0 additions & 4 deletions ext-src/php_swoole_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ extern PHPAPI int php_array_merge(zend_array *dest, zend_array *src);
#error "thread context cannot be used with ZTS"
#endif

#if defined(SW_USE_IOURING) && !defined(__linux__)
#error "only linux support iouring"
#endif

//--------------------------------------------------------
#define SW_MAX_FIND_COUNT 100 // for swoole_server::connection_list
#define SW_PHP_CLIENT_BUFFER_SIZE 65535
Expand Down
6 changes: 0 additions & 6 deletions ext-src/swoole_async_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ void php_swoole_set_aio_option(HashTable *vht) {
if (php_swoole_array_get_value(vht, "aio_max_idle_time", ztmp)) {
SwooleG.aio_max_idle_time = zval_get_double(ztmp);
}
#if defined(__linux__) && defined(SW_USE_IOURING)
if (php_swoole_array_get_value(vht, "iouring_entries", ztmp)) {
zend_long v = zval_get_long(ztmp);
SwooleG.iouring_entries = SW_MAX(0, SW_MIN(v, UINT32_MAX));
}
#endif
}

PHP_FUNCTION(swoole_async_set) {
Expand Down
13 changes: 0 additions & 13 deletions include/swoole.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
#include <list>
#include <functional>

#ifdef SW_USE_IOURING
#include <liburing.h>
#endif

typedef unsigned long ulong_t;

#ifndef PRId64
Expand Down Expand Up @@ -204,9 +200,6 @@ struct Socket;
struct Address;
} // namespace network
class AsyncThreads;
#ifdef SW_USE_IOURING
class AsyncIouring;
#endif
namespace async {
class ThreadPool;
}
Expand Down Expand Up @@ -667,9 +660,6 @@ struct ThreadGlobal {
Reactor *reactor;
Timer *timer;
AsyncThreads *async_threads;
#ifdef SW_USE_IOURING
AsyncIouring *async_iouring;
#endif
uint32_t signal_listener_num;
uint32_t co_signal_listener_num;
int error;
Expand Down Expand Up @@ -750,9 +740,6 @@ struct Global {
//-----------------------[AIO]--------------------------
uint32_t aio_core_worker_num;
uint32_t aio_worker_num;
#ifdef SW_USE_IOURING
uint32_t iouring_entries;
#endif
double aio_max_wait_time;
double aio_max_idle_time;
network::Socket *aio_default_socket;
Expand Down
106 changes: 0 additions & 106 deletions include/swoole_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
#include <atomic>
#include <queue>

#ifdef SW_USE_IOURING
#include "linux/version.h"
#include <liburing.h>
#endif

#ifndef O_DIRECT
#define O_DIRECT 040000
#endif
Expand All @@ -42,32 +37,16 @@ enum AsyncFlag {

struct AsyncEvent {
size_t task_id;
#ifdef SW_USE_IOURING
size_t count;
#endif
uint8_t canceled;
int error;
/**
* input & output
*/
void *data;
#ifdef SW_USE_IOURING
const char *pathname;
const char *pathname2;
struct statx *statxbuf;
void *rbuf;
const void *wbuf;
#endif
/**
* output
*/
ssize_t retval;
#ifdef SW_USE_IOURING
int fd;
int flags;
int opcode;
mode_t mode;
#endif
/**
* internal use only
*/
Expand Down Expand Up @@ -124,91 +103,6 @@ class AsyncThreads {
std::mutex init_lock;
};

#ifdef SW_USE_IOURING
class AsyncIouring {
private:
int ring_fd;
uint64_t task_num = 0;
uint64_t entries = 8192;
struct io_uring ring;
std::queue<AsyncEvent *> waitEvents;
network::Socket *iou_socket = nullptr;
Reactor *reactor = nullptr;

inline struct io_uring_sqe *get_iouring_sqe() {
struct io_uring_sqe *sqe = io_uring_get_sqe(&ring);
// We need to reset the values of each sqe structure so that they can be used in a loop.
if (sqe) {
memset(sqe, 0, sizeof(struct io_uring_sqe));
}
return sqe;
}

inline void set_iouring_sqe_data(struct io_uring_sqe *sqe, void *data) {
io_uring_sqe_set_data(sqe, data);
}

inline void *get_iouring_cqe_data(struct io_uring_cqe *cqe) {
return io_uring_cqe_get_data(cqe);
}

inline int get_iouring_cqes(struct io_uring_cqe **cqe_ptr, unsigned count) {
return io_uring_peek_batch_cqe(&ring, cqe_ptr, count);
}

inline void finish_iouring_cqes(unsigned count) {
io_uring_cq_advance(&ring, count);
}

inline bool submit_iouring_sqe() {
return io_uring_submit(&ring);
}

public:
AsyncIouring(Reactor *reactor_);
~AsyncIouring();

enum opcodes {
SW_IORING_OP_OPENAT = IORING_OP_OPENAT,
SW_IORING_OP_CLOSE = IORING_OP_CLOSE,
SW_IORING_OP_STATX = IORING_OP_STATX,
SW_IORING_OP_READ = IORING_OP_READ,
SW_IORING_OP_WRITE = IORING_OP_WRITE,
SW_IORING_OP_RENAMEAT = IORING_OP_RENAMEAT,
SW_IORING_OP_UNLINKAT = IORING_OP_UNLINKAT,
SW_IORING_OP_MKDIRAT = IORING_OP_MKDIRAT,

SW_IORING_OP_FSTAT = 1000,
SW_IORING_OP_LSTAT = 1001,
SW_IORING_OP_UNLINK_FILE = 1002,
SW_IORING_OP_UNLINK_DIR = 1003,
SW_IORING_OP_FSYNC = 1004,
SW_IORING_OP_FDATASYNC = 1005,
};

void add_event();
void delete_event();
bool wakeup();
bool open(AsyncEvent *event);
bool close(AsyncEvent *event);
bool wr(AsyncEvent *event);
bool statx(AsyncEvent *event);
bool mkdir(AsyncEvent *event);
bool unlink(AsyncEvent *event);
bool rename(AsyncEvent *event);
bool fsync(AsyncEvent *event);
inline bool is_empty_wait_events() {
return waitEvents.size() == 0;
}

inline uint64_t get_task_num() {
return task_num;
}

static int callback(Reactor *reactor, Event *event);
};
#endif

namespace async {

typedef void (*Handler)(AsyncEvent *event);
Expand Down
16 changes: 0 additions & 16 deletions include/swoole_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,6 @@ class Coroutine {
namespace coroutine {
bool async(async::Handler handler, AsyncEvent &event, double timeout = -1);
bool async(const std::function<void(void)> &fn, double timeout = -1);
#ifdef SW_USE_IOURING
int async(AsyncIouring::opcodes opcode,
const char *pathname,
const char *pathname2 = nullptr,
mode_t mode = 0,
int flags = 0,
struct statx *statxbuf = nullptr,
double timeout = -1);
int async(AsyncIouring::opcodes opcode,
int fd,
void *rbuf = nullptr,
const void *wbuf = nullptr,
struct statx *statxbuf = nullptr,
size_t count = 0,
double timeout = -1);
#endif
bool run(const CoroutineFunc &fn, void *arg = nullptr);
} // namespace coroutine
//-------------------------------------------------------------------------------
Expand Down
19 changes: 0 additions & 19 deletions include/swoole_coroutine_c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,6 @@ int swoole_coroutine_statvfs(const char *path, struct statvfs *buf);
int swoole_coroutine_close_file(int fd);
int swoole_coroutine_fsync(int fd);
int swoole_coroutine_fdatasync(int fd);
/**
* io_uring
*/
#ifdef SW_USE_IOURING
int swoole_coroutine_iouring_open(const char *pathname, int flags, mode_t mode);
int swoole_coroutine_iouring_close_file(int fd);
ssize_t swoole_coroutine_iouring_read(int sockfd, void *buf, size_t count);
ssize_t swoole_coroutine_iouring_write(int sockfd, const void *buf, size_t count);
int swoole_coroutine_iouring_rename(const char *oldpath, const char *newpath);
int swoole_coroutine_iouring_mkdir(const char *pathname, mode_t mode);
int swoole_coroutine_iouring_unlink(const char *pathname);
int swoole_coroutine_iouring_fstat(int fd, struct stat *statbuf);
int swoole_coroutine_iouring_stat(const char *path, struct stat *statbuf);
int swoole_coroutine_iouring_lstat(const char *path, struct stat *statbuf);
int swoole_coroutine_iouring_rmdir(const char *pathname);
int swoole_coroutine_iouring_fsync(int fd);
int swoole_coroutine_iouring_fdatasync(int fd);
void swoole_statx_to_stat(const struct statx *statxbuf, struct stat *statbuf);
#endif
/**
* stdio
*/
Expand Down
16 changes: 0 additions & 16 deletions include/swoole_file_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@

#include "swoole_coroutine_c_api.h"

#ifdef SW_USE_IOURING
#define open(pathname, flags, mode) swoole_coroutine_iouring_open(pathname, flags, mode)
#define close_file(fd) swoole_coroutine_iouring_close_file(fd)
#define read(fd, buf, count) swoole_coroutine_iouring_read(fd, buf, count)
#define write(fd, buf, count) swoole_coroutine_iouring_write(fd, buf, count)
#define rename(oldpath, newpath) swoole_coroutine_iouring_rename(oldpath, newpath)
#define mkdir(pathname, mode) swoole_coroutine_iouring_mkdir(pathname, mode)
#define unlink(pathname) swoole_coroutine_iouring_unlink(pathname)
#define fstat(fd, statbuf) swoole_coroutine_iouring_fstat(fd, statbuf)
#define stat(path, statbuf) swoole_coroutine_iouring_stat(path, statbuf)
#define lstat(path, statbuf) swoole_coroutine_iouring_lstat(path, statbuf)
#define rmdir(pathname) swoole_coroutine_iouring_rmdir(pathname)
#define fsync(fd) swoole_coroutine_iouring_fsync(fd)
#define fdatasync(fd) swoole_coroutine_iouring_fdatasync(fd)
#else
#define open(pathname, flags, mode) swoole_coroutine_open(pathname, flags, mode)
#define close_file(fd) swoole_coroutine_close_file(fd)
#define read(fd, buf, count) swoole_coroutine_read(fd, buf, count)
Expand All @@ -49,7 +34,6 @@
#define rename(oldpath, newpath) swoole_coroutine_rename(oldpath, newpath)
#define fsync(fd) swoole_coroutine_fsync(fd)
#define fdatasync(fd) swoole_coroutine_fdatasync(fd)
#endif

#define access(pathname, mode) swoole_coroutine_access(pathname, mode)
#define fopen(pathname, mode) swoole_coroutine_fopen(pathname, mode)
Expand Down
1 change: 0 additions & 1 deletion scripts/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ COMPILE_PARAMS="--enable-openssl \
--enable-swoole-curl \
--enable-cares \
--enable-swoole-pgsql \
--enable-iouring \
--with-swoole-odbc=unixODBC,/usr \
--enable-swoole-sqlite"

Expand Down
Loading

0 comments on commit 49716c9

Please sign in to comment.