From b147a8382a9a740b511da35976102331ea318ca0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 13 May 2012 00:35:44 +0200 Subject: [PATCH] CLEANUP: fd: remove unused cb->b pointers in the struct fdtab These pointers were used to hold pointers to buffers in the past, but since we introduced the stream interface, they're no longer used but they were still sometimes set. Removing them shrink the struct fdtab from 32 to 24 bytes on 32-bit machines, and from 52 to 36 bytes on 64-bit machines, which is a significant saving. A quick tests shows a steady 0.5% performance gain, probably due to the better cache efficiency. --- include/types/fd.h | 1 - src/checks.c | 2 -- src/proto_tcp.c | 3 --- src/proto_uxst.c | 1 - src/session.c | 2 -- 5 files changed, 9 deletions(-) diff --git a/include/types/fd.h b/include/types/fd.h index f69886354..559fa0e70 100644 --- a/include/types/fd.h +++ b/include/types/fd.h @@ -69,7 +69,6 @@ enum { struct fdtab { struct { int (*f)(int fd); /* read/write function */ - struct buffer *b; /* read/write buffer */ } cb[DIR_SIZE]; void *owner; /* the session (or proxy) associated with this fd */ struct { /* used by pollers which support speculative polling */ diff --git a/src/checks.c b/src/checks.c index f8ad53e16..3604e5a0e 100644 --- a/src/checks.c +++ b/src/checks.c @@ -1434,9 +1434,7 @@ static struct task *process_chk(struct task *t) fd_insert(fd); fdtab[fd].owner = t; fdtab[fd].cb[DIR_RD].f = &event_srv_chk_r; - fdtab[fd].cb[DIR_RD].b = NULL; fdtab[fd].cb[DIR_WR].f = &event_srv_chk_w; - fdtab[fd].cb[DIR_WR].b = NULL; fdinfo[fd].peeraddr = (struct sockaddr *)&sa; fdinfo[fd].peerlen = get_addr_len(&sa); fdtab[fd].state = FD_STCONN; /* connection in progress */ diff --git a/src/proto_tcp.c b/src/proto_tcp.c index eee65bc9b..416dbf07c 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -451,8 +451,6 @@ int tcp_connect_server(struct stream_interface *si) fdtab[fd].owner = si; fdtab[fd].state = FD_STCONN; /* connection in progress */ fdtab[fd].flags = FD_FL_TCP | FD_FL_TCP_NODELAY; - fdtab[fd].cb[DIR_RD].b = si->ib; - fdtab[fd].cb[DIR_WR].b = si->ob; /* If we have nothing to send or if we want to initialize the sock layer, * we want to confirm that the TCP connection is established before doing @@ -755,7 +753,6 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) fdtab[fd].flags = FD_FL_TCP | ((listener->options & LI_O_NOLINGER) ? FD_FL_TCP_NOLING : 0); fdtab[fd].cb[DIR_RD].f = listener->proto->accept; fdtab[fd].cb[DIR_WR].f = NULL; /* never called */ - fdtab[fd].cb[DIR_RD].b = fdtab[fd].cb[DIR_WR].b = NULL; fdinfo[fd].peeraddr = NULL; fdinfo[fd].peerlen = 0; diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 082599201..dec91aaf0 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -264,7 +264,6 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle fd_insert(fd); fdtab[fd].cb[DIR_RD].f = listener->proto->accept; fdtab[fd].cb[DIR_WR].f = NULL; /* never called */ - fdtab[fd].cb[DIR_RD].b = fdtab[fd].cb[DIR_WR].b = NULL; fdtab[fd].owner = listener; /* reference the listener instead of a task */ fdtab[fd].state = FD_STLISTEN; fdinfo[fd].peeraddr = NULL; diff --git a/src/session.c b/src/session.c index ae20e5b38..036480c83 100644 --- a/src/session.c +++ b/src/session.c @@ -284,9 +284,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr) fdtab[cfd].state = FD_STREADY; fdtab[cfd].flags = 0; fdtab[cfd].cb[DIR_RD].f = s->si[0].sock.read; - fdtab[cfd].cb[DIR_RD].b = s->req; fdtab[cfd].cb[DIR_WR].f = s->si[0].sock.write; - fdtab[cfd].cb[DIR_WR].b = s->rep; fdinfo[cfd].peeraddr = (struct sockaddr *)&s->si[0].addr.from; fdinfo[cfd].peerlen = sizeof(s->si[0].addr.from); EV_FD_SET(cfd, DIR_RD);