From: Willy Tarreau Date: Sat, 13 Oct 2012 12:33:58 +0000 (+0200) Subject: OPTIM: connection: pack the struct target X-Git-Tag: v1.5-dev13~142 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=378e041797340412cedf14b0b0dd3a85e958ba0b;p=thirdparty%2Fhaproxy.git OPTIM: connection: pack the struct target The struct target contains one int and one pointer, causing it to be 64-bit aligned on 64-bit platforms. By marking it "packed", we can save 8 bytes in struct connection and as many in struct session on such platforms. --- diff --git a/include/types/connection.h b/include/types/connection.h index 5803c2c2ec..299093bee0 100644 --- a/include/types/connection.h +++ b/include/types/connection.h @@ -208,7 +208,7 @@ struct target { struct task *t; /* when type is TARG_TYPE_TASK */ struct listener *l; /* when type is TARG_TYPE_CLIENT */ } ptr; -}; +} __attribute__((packed)); /* This structure describes a connection with its methods and data. * A connection may be performed to proxy or server via a local or remote @@ -218,18 +218,18 @@ struct target { * connections, but other methods for applets. */ struct connection { - const struct xprt_ops *xprt; /* operations at the transport layer */ const struct protocol *ctrl; /* operations at the socket layer */ + const struct xprt_ops *xprt; /* operations at the transport layer */ const struct data_cb *data; /* data layer callbacks */ + unsigned int flags; /* CO_F_* */ + int xprt_st; /* transport layer state, initialized to zero */ + void *xprt_ctx; /* general purpose pointer, initialized to NULL */ void *owner; /* pointer to upper layer's entity (eg: stream interface) */ union { /* definitions which depend on connection type */ struct { /*** information used by socket-based connections ***/ int fd; /* file descriptor for a stream driver when known */ } sock; } t; - unsigned int flags; /* CO_F_* */ - int xprt_st; /* transport layer state, initialized to zero */ - void *xprt_ctx; /* general purpose pointer, initialized to NULL */ struct target target; /* the target to connect to (server, proxy, applet, ...) */ struct { struct sockaddr_storage from; /* client address, or address to spoof when connecting to the server */