diff options
author | 2015-02-09 08:00:02 -0800 | |
---|---|---|
committer | 2015-02-09 08:00:02 -0800 | |
commit | 7d41321306eecdd7fa1dbbcf663cc94fd75db975 (patch) | |
tree | bb4fd766b4c96fff15b069619b978b9e7e8a4d76 /src/core/iomgr/pollset_posix.c | |
parent | 970781bba9982e66c70e012fce1ba08fb8b88da8 (diff) |
Reduce contention on lock
Change the fd watcher from being O(active_pollers) to O(1), reducing time spent under the fd->watcher_mu lock, and ultimately scaling us much better.
Diffstat (limited to 'src/core/iomgr/pollset_posix.c')
-rw-r--r-- | src/core/iomgr/pollset_posix.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index b1c2c64a18..b0404b870b 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -80,7 +80,9 @@ void grpc_pollset_kick(grpc_pollset *p) { } } -void grpc_pollset_force_kick(grpc_pollset *p) { grpc_pollset_kick_kick(&p->kick_state); } +void grpc_pollset_force_kick(grpc_pollset *p) { + grpc_pollset_kick_kick(&p->kick_state); +} /* global state management */ @@ -217,6 +219,7 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, int allow_synchronous_callback) { struct pollfd pfd[2]; grpc_fd *fd; + grpc_fd_watcher fd_watcher; int timeout; int r; @@ -249,7 +252,7 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, pollset->counter = 1; gpr_mu_unlock(&pollset->mu); - pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT); + pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher); r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout); if (r < 0) { @@ -271,7 +274,7 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, } grpc_pollset_kick_post_poll(&pollset->kick_state); - grpc_fd_end_poll(fd, pollset); + grpc_fd_end_poll(&fd_watcher); gpr_mu_lock(&pollset->mu); pollset->counter = 0; |