send zc done notify callback for recycling buffer
parent
23cd03bc76
commit
ddf6b5dfe9
|
|
@ -51,6 +51,7 @@ struct fast_task_info;
|
||||||
#if IOEVENT_USE_URING
|
#if IOEVENT_USE_URING
|
||||||
#define FC_URING_OP_TYPE(task) (task)->uring.op_type
|
#define FC_URING_OP_TYPE(task) (task)->uring.op_type
|
||||||
#define FC_URING_IS_CLIENT(task) (task)->uring.is_client
|
#define FC_URING_IS_CLIENT(task) (task)->uring.is_client
|
||||||
|
#define FC_URING_IS_SEND_ZC(task) ((task)->uring.op_type == IORING_OP_SEND_ZC)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct ioevent_entry
|
typedef struct ioevent_entry
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ int ioevent_init(IOEventPoller *ioevent, const char *service_name,
|
||||||
ioevent->cqe = NULL;
|
ioevent->cqe = NULL;
|
||||||
ioevent->submit_count = 0;
|
ioevent->submit_count = 0;
|
||||||
ioevent->send_zc_logged = false;
|
ioevent->send_zc_logged = false;
|
||||||
|
ioevent->send_zc_done_notify = false;
|
||||||
#elif IOEVENT_USE_KQUEUE
|
#elif IOEVENT_USE_KQUEUE
|
||||||
ioevent->poll_fd = kqueue();
|
ioevent->poll_fd = kqueue();
|
||||||
if (ioevent->poll_fd < 0) {
|
if (ioevent->poll_fd < 0) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
#define IOEVENT_TIMEOUT (1 << 20)
|
#define IOEVENT_TIMEOUT (1 << 20)
|
||||||
|
#define IOEVENT_NOTIFY (1 << 21) //for io_uring send_zc done callback
|
||||||
|
|
||||||
#if IOEVENT_USE_EPOLL
|
#if IOEVENT_USE_EPOLL
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
|
|
@ -80,6 +81,7 @@ typedef struct ioevent_puller {
|
||||||
struct io_uring ring;
|
struct io_uring ring;
|
||||||
int submit_count;
|
int submit_count;
|
||||||
bool send_zc_logged;
|
bool send_zc_logged;
|
||||||
|
bool send_zc_done_notify; //if callback when send_zc done
|
||||||
#else
|
#else
|
||||||
int poll_fd;
|
int poll_fd;
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -191,6 +193,12 @@ static inline int ioevent_poll_ex(IOEventPoller *ioevent, const int timeout_ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IOEVENT_USE_URING
|
#if IOEVENT_USE_URING
|
||||||
|
static inline void ioevent_set_send_zc_done_notify(
|
||||||
|
IOEventPoller *ioevent, const bool need_notify)
|
||||||
|
{
|
||||||
|
ioevent->send_zc_done_notify = need_notify;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int ioevent_uring_submit(IOEventPoller *ioevent)
|
static inline int ioevent_uring_submit(IOEventPoller *ioevent)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,10 @@ static int ioevent_process(IOEventPoller *ioevent)
|
||||||
pEntry = (IOEventEntry *)ioevent->cqe->user_data;
|
pEntry = (IOEventEntry *)ioevent->cqe->user_data;
|
||||||
if (pEntry != NULL) {
|
if (pEntry != NULL) {
|
||||||
if (ioevent->cqe->flags & IORING_CQE_F_NOTIF) {
|
if (ioevent->cqe->flags & IORING_CQE_F_NOTIF) {
|
||||||
|
if (ioevent->send_zc_done_notify) {
|
||||||
|
pEntry->callback(pEntry->fd, IOEVENT_NOTIFY, pEntry);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef IORING_NOTIF_USAGE_ZC_COPIED
|
#ifdef IORING_NOTIF_USAGE_ZC_COPIED
|
||||||
if (!ioevent->send_zc_logged) {
|
if (!ioevent->send_zc_logged) {
|
||||||
struct fast_task_info *task;
|
struct fast_task_info *task;
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,11 @@ static inline int uring_prep_first_send_zc(struct fast_task_info *task)
|
||||||
sqe, task->event.fd, task->iovec_array.iovs,
|
sqe, task->event.fd, task->iovec_array.iovs,
|
||||||
FC_MIN(task->iovec_array.count, IOV_MAX),
|
FC_MIN(task->iovec_array.count, IOV_MAX),
|
||||||
task);
|
task);
|
||||||
|
} else if (task->send.ptr->length < 4096) {
|
||||||
|
SET_OP_TYPE_AND_HOLD_TASK(task, IORING_OP_SEND);
|
||||||
|
ioevent_uring_prep_send(&task->thread_data->ev_puller,
|
||||||
|
sqe, task->event.fd, task->send.ptr->data,
|
||||||
|
task->send.ptr->length, task);
|
||||||
} else {
|
} else {
|
||||||
SET_OP_TYPE_AND_HOLD_TASK(task, IORING_OP_SEND_ZC);
|
SET_OP_TYPE_AND_HOLD_TASK(task, IORING_OP_SEND_ZC);
|
||||||
ioevent_uring_prep_send_zc(&task->thread_data->ev_puller,
|
ioevent_uring_prep_send_zc(&task->thread_data->ev_puller,
|
||||||
|
|
@ -175,6 +180,11 @@ static inline int uring_prep_next_send_zc(struct fast_task_info *task)
|
||||||
sqe, task->event.fd, task->iovec_array.iovs,
|
sqe, task->event.fd, task->iovec_array.iovs,
|
||||||
FC_MIN(task->iovec_array.count, IOV_MAX),
|
FC_MIN(task->iovec_array.count, IOV_MAX),
|
||||||
task);
|
task);
|
||||||
|
} else if (task->send.ptr->length - task->send.ptr->offset < 4096) {
|
||||||
|
SET_OP_TYPE_AND_HOLD_TASK(task, IORING_OP_SEND);
|
||||||
|
ioevent_uring_prep_send(&task->thread_data->ev_puller, sqe,
|
||||||
|
task->event.fd, task->send.ptr->data + task->send.ptr->offset,
|
||||||
|
task->send.ptr->length - task->send.ptr->offset, task);
|
||||||
} else {
|
} else {
|
||||||
SET_OP_TYPE_AND_HOLD_TASK(task, IORING_OP_SEND_ZC);
|
SET_OP_TYPE_AND_HOLD_TASK(task, IORING_OP_SEND_ZC);
|
||||||
ioevent_uring_prep_send_zc(&task->thread_data->ev_puller, sqe,
|
ioevent_uring_prep_send_zc(&task->thread_data->ev_puller, sqe,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue