Repository: trafficserver Updated Branches: refs/heads/master 5054186f9 -> 86295176c
TS-3044: Use eventfd in AIO_MODE_NATIVE if available Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/86295176 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/86295176 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/86295176 Branch: refs/heads/master Commit: 86295176ccb5b7ef5c96686b398733e1edf6f2ee Parents: 5054186 Author: John Plevyak <[email protected]> Authored: Thu Oct 2 14:34:55 2014 -0600 Committer: Phil Sorber <[email protected]> Committed: Thu Oct 2 14:34:55 2014 -0600 ---------------------------------------------------------------------- CHANGES | 2 ++ iocore/aio/AIO.cc | 33 +++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86295176/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 867e8a3..2184733 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.2.0 + *) [TS-3044] Use eventfd in AIO_MODE_NATIVE if available. + *) [TS-3108] Add port matching condition to header_rewrite. *) [TS-3068] Remove usage of Boost. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/86295176/iocore/aio/AIO.cc ---------------------------------------------------------------------- diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc index 4dea143..877bc61 100644 --- a/iocore/aio/AIO.cc +++ b/iocore/aio/AIO.cc @@ -28,7 +28,7 @@ #include "P_AIO.h" #if AIO_MODE == AIO_MODE_NATIVE -#define AIO_PERIOD -HRTIME_MSECONDS(4) +#define AIO_PERIOD -HRTIME_MSECONDS(10) #else #define MAX_DISKS_POSSIBLE 100 @@ -528,13 +528,11 @@ DiskHandler::mainAIOEvent(int event, Event *e) { AIOCallback *op = NULL; Lagain: int ret = io_getevents(ctx, 0, MAX_AIO_EVENTS, events, NULL); - //printf("%d\n", ret); for (int i = 0; i < ret; i++) { op = (AIOCallback *) events[i].data; op->aio_result = events[i].res; ink_assert(op->action.continuation); complete_list.enqueue(op); - //op->handleEvent(event, e); } if (ret == MAX_AIO_EVENTS) { @@ -542,7 +540,10 @@ Lagain: } if (ret < 0) { - Debug("aio", "io_getevents failed: %s (%d)", strerror(-ret), -ret); + if (errno == EINTR) + goto Lagain; + if (errno == EFAULT || errno == ENOSYS) + Debug("aio", "io_getevents failed: %s (%d)", strerror(-ret), -ret); } ink_aiocb_t *cbs[MAX_AIO_EVENTS]; @@ -579,7 +580,11 @@ ink_aio_read(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { op->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY; op->aiocb.aio_lio_opcode = IO_CMD_PREAD; op->aiocb.data = op; - this_ethread()->diskHandler->ready_list.enqueue(op); + EThread *t = this_ethread(); +#ifdef HAVE_EVENTFD + io_set_eventfd(&op->aiocb, t->evfd); +#endif + t->diskHandler->ready_list.enqueue(op); return 1; } @@ -589,14 +594,19 @@ ink_aio_write(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { op->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY; op->aiocb.aio_lio_opcode = IO_CMD_PWRITE; op->aiocb.data = op; - this_ethread()->diskHandler->ready_list.enqueue(op); + EThread *t = this_ethread(); +#ifdef HAVE_EVENTFD + io_set_eventfd(&op->aiocb, t->evfd); +#endif + t->diskHandler->ready_list.enqueue(op); return 1; } int ink_aio_readv(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { - DiskHandler *dh = this_ethread()->diskHandler; + EThread *t = this_ethread(); + DiskHandler *dh = t->diskHandler; AIOCallback *io = op; int sz = 0; @@ -604,6 +614,9 @@ ink_aio_readv(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { io->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY; io->aiocb.aio_lio_opcode = IO_CMD_PREAD; io->aiocb.data = io; +#ifdef HAVE_EVENTFD + io_set_eventfd(&op->aiocb, t->evfd); +#endif dh->ready_list.enqueue(io); ++sz; io = io->then; @@ -622,7 +635,8 @@ ink_aio_readv(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { int ink_aio_writev(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { - DiskHandler *dh = this_ethread()->diskHandler; + EThread *t = this_ethread(); + DiskHandler *dh = t->diskHandler; AIOCallback *io = op; int sz = 0; @@ -630,6 +644,9 @@ ink_aio_writev(AIOCallback *op, int /* fromAPI ATS_UNUSED */) { io->aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY; io->aiocb.aio_lio_opcode = IO_CMD_PWRITE; io->aiocb.data = io; +#ifdef HAVE_EVENTFD + io_set_eventfd(&op->aiocb, t->evfd); +#endif dh->ready_list.enqueue(io); ++sz; io = io->then;
