Triton Repository branch, master, updated. c57e2bc25685af63af02ed0c6542968c5d7f1e58
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Triton Repository". The branch, master has been updated via c57e2bc25685af63af02ed0c6542968c5d7f1e58 (commit) via 47c61f8a0f5112a772a69c128af0f45f4576630d (commit) from 5f6ce92257c426eab3e1dc244f6e9f7a04359e74 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c57e2bc25685af63af02ed0c6542968c5d7f1e58 Author: Phil Carns <[email protected]> Date: Thu Jun 16 22:23:50 2011 -0400 add new ae_resource_wake_pollers() function - alternative to ae_resource_request_poll() for a resource to interrupt the event loop when it doesn't necessarily need to be polled - doesn't do anything yet except skip sending an async event if the event loop is already awake - only being used in the socket resource for now commit 47c61f8a0f5112a772a69c128af0f45f4576630d Author: Phil Carns <[email protected]> Date: Thu Jun 16 21:16:43 2011 -0400 experimental performance tweaks ----------------------------------------------------------------------- Summary of changes: code/src/aesop/resource.c | 59 ++++++++++++++++++++++--- code/src/aesop/resource.h | 1 + code/src/common/libev/ev_epoll.c | 6 +++ code/src/common/resources/aesocket/aesocket.c | 4 +- code/src/socket/triton-socket.ae | 2 +- 5 files changed, 62 insertions(+), 10 deletions(-) Diff of changes: diff --git a/code/src/aesop/resource.c b/code/src/aesop/resource.c index c8932aa..31a80ec 100644 --- a/code/src/aesop/resource.c +++ b/code/src/aesop/resource.c @@ -48,6 +48,7 @@ static int efd = -1; #ifdef __AESOP_LIBEV static struct ev_loop *eloop = NULL; #endif +static pthread_t ev_loop_thread; #define AE_RESOURCE_IDX2ID(reindex) (reindex+16) #define AE_RESOURCE_ID2IDX(rid) (rid-16) @@ -148,6 +149,7 @@ triton_ret_t ae_resource_register(struct ae_resource *resource, int *newid) int reindex = ae_resource_count; int ret; + ev_loop_thread = pthread_self(); if(eloop == NULL) { eloop = EV_DEFAULT; @@ -252,12 +254,8 @@ void ae_resource_request_poll(ae_context_t context, int resource_id) #endif /* __AESOP_EPOLL */ #ifdef __AESOP_LIBEV -/** - * ae_resource_request_poll() is used by a resource to inform aesop that the - * resource needs to be polled. - */ -/* TODO: think about race conditions. Need any locking here? */ -void ae_resource_request_poll(ae_context_t context, int resource_id) + +void find_async_watcher(ae_context_t context, int resource_id, ev_async** async_out, struct ev_loop** loop_out) { ev_async* async = NULL; int i; @@ -285,7 +283,6 @@ void ae_resource_request_poll(ae_context_t context, int resource_id) target_loop = eloop; } - /* TODO: put this in epoll version too */ if(!async) { triton_err(triton_log_default, "Error: context %p is not configured to handle resource with id %d", context, resource_id); @@ -302,6 +299,54 @@ void ae_resource_request_poll(ae_context_t context, int resource_id) } assert(target_loop); + + *async_out = async; + *loop_out = target_loop; + + return; +} + +/** + * ae_resource_wake_pollers() is used by a resource to wake up the event + * loop (for example, after completing an operation and triggering its + * callback) in cases where the resource doesn't necessarily need to be + * polled. + */ +void ae_resource_wake_pollers(ae_context_t context, int resource_id) +{ + ev_async* async = NULL; + struct ev_loop *target_loop = NULL; + + if(pthread_equal(ev_loop_thread, pthread_self())) + { + /* this was called from the event loop thread, so we know that it is + * already awake + */ + return; + } + + find_async_watcher(context, resource_id, &async, &target_loop); + + /* TODO: note that this will actually cause the event loop to poll the + * resource. Technically we could use a separate watcher to wake up the + * event loop without triggering a poll + */ + ev_async_send(target_loop, async); + + return; +} + +/** + * ae_resource_request_poll() is used by a resource to inform aesop that the + * resource needs to be polled. + */ +void ae_resource_request_poll(ae_context_t context, int resource_id) +{ + ev_async* async = NULL; + struct ev_loop *target_loop = NULL; + + find_async_watcher(context, resource_id, &async, &target_loop); + ev_async_send(target_loop, async); return; diff --git a/code/src/aesop/resource.h b/code/src/aesop/resource.h index 78502b9..8b396a4 100644 --- a/code/src/aesop/resource.h +++ b/code/src/aesop/resource.h @@ -59,6 +59,7 @@ struct ae_resource ae_ret_t ae_resource_register(struct ae_resource *resource, int *newid); void ae_resource_unregister(int resource_id); void ae_resource_request_poll(ae_context_t context, int resource_id); +void ae_resource_wake_pollers(ae_context_t context, int resource_id); #ifdef __AESOP_LIBEV /* this function is used by resources that want access to the event loop * used by aesop for this context diff --git a/code/src/common/libev/ev_epoll.c b/code/src/common/libev/ev_epoll.c index 5deb652..07a7a2e 100644 --- a/code/src/common/libev/ev_epoll.c +++ b/code/src/common/libev/ev_epoll.c @@ -84,6 +84,12 @@ epoll_modify (EV_P_ int fd, int oev, int nev) if (!nev) return; + /* TODO: this is temporary for testing purposes; avoid an extra epoll_ctl + * add by trusting epoll not to lose track of sockets + */ + if(oev == nev) + return; + oldmask = anfds [fd].emask; anfds [fd].emask = nev; diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c index 01b3811..946a219 100644 --- a/code/src/common/resources/aesocket/aesocket.c +++ b/code/src/common/resources/aesocket/aesocket.c @@ -51,7 +51,7 @@ static void aesocket_fd_ready( ev_io_stop(eloop, io); ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS); - ae_resource_request_poll(op->ctx, triton_aesocket_resource_id); + ae_resource_wake_pollers(op->ctx, triton_aesocket_resource_id); return; } @@ -190,7 +190,7 @@ static triton_ret_t triton_aesocket_cancel( triton_mutex_unlock(&aesocket_mutex); ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_ERR_CANCELED); - ae_resource_request_poll(ctx, triton_aesocket_resource_id); + ae_resource_wake_pollers(ctx, triton_aesocket_resource_id); } else if(ae_ops_exists(&inflight_oplist, &op->link)) { diff --git a/code/src/socket/triton-socket.ae b/code/src/socket/triton-socket.ae index 13b8f89..75ce7a9 100644 --- a/code/src/socket/triton-socket.ae +++ b/code/src/socket/triton-socket.ae @@ -8,7 +8,7 @@ * that the peer has closed the socket; this is a hack to weed out * spurious zero byte reads that can show up on some systems. */ -#define ZERO_BYTE_READ_THRESHOLD 4 +#define ZERO_BYTE_READ_THRESHOLD 0 __blocking triton_ret_t triton_accept( int sockfd, hooks/post-receive -- Triton Repository
participants (1)
-
noreply@mcs.anl.gov