Skip to content

Commit

Permalink
sheep: cache eventfd for local request in thread local storage
Browse files Browse the repository at this point in the history
Creating a fd must be serialized because of the minimum available fd
allocation rule of Posix, so current implementation of the local
request is bad for multicore scalability.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
  • Loading branch information
mitake committed Feb 17, 2017
1 parent 978eeae commit e1a5b01
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sheep/request.c
Expand Up @@ -544,10 +544,16 @@ worker_fn int exec_local_req(struct sd_req *rq, void *data)
{
struct request *req;
int ret;
static __thread int efd = -1;

req = alloc_local_request(data, rq->data_length);
req->rq = *rq;
req->local_req_efd = eventfd(0, 0);

if (unlikely(efd == -1))
efd = eventfd(0, 0);

req->local_req_efd = efd;

if (req->local_req_efd < 0) {
sd_err("eventfd failed, %m");
/* Fake the result to ask for retry */
Expand All @@ -561,7 +567,6 @@ worker_fn int exec_local_req(struct sd_req *rq, void *data)
/* fill rq with response header as exec_req does */
memcpy(rq, &req->rp, sizeof(req->rp));

close(req->local_req_efd);
ret = req->rp.result;
free_local_request(req);

Expand Down

0 comments on commit e1a5b01

Please sign in to comment.