From: Willy Tarreau Date: Fri, 6 Dec 2013 22:43:17 +0000 (+0100) Subject: DIET/MINOR: http: reduce the size of struct http_txn by 8 bytes X-Git-Tag: v1.5-dev20~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c8987b3664a703440ed80a2086d262898873d173;p=thirdparty%2Fhaproxy.git DIET/MINOR: http: reduce the size of struct http_txn by 8 bytes Here again we had some oversized and misaligned entries. The method and the status don't need 4 bytes each, and there was a hole after the status that does not exist anymore. That's 8 additional bytes saved from http_txn and as much for the session. Also some fields were slightly moved to present better memory access patterns resulting in a steady 0.5% performance increase. --- diff --git a/include/types/proto_http.h b/include/types/proto_http.h index 5a671b0b90..52c3c70b18 100644 --- a/include/types/proto_http.h +++ b/include/types/proto_http.h @@ -217,7 +217,7 @@ enum { }; /* Known HTTP methods */ -typedef enum { +enum http_meth_t { HTTP_METH_NONE = 0, HTTP_METH_OPTIONS, HTTP_METH_GET, @@ -228,7 +228,7 @@ typedef enum { HTTP_METH_TRACE, HTTP_METH_CONNECT, HTTP_METH_OTHER, -} http_meth_t; +} __attribute__((packed)); enum { HTTP_AUTH_WRONG = -1, /* missing or unknown */ @@ -405,13 +405,13 @@ struct http_res_rule { * response message (which can be empty). */ struct http_txn { - struct http_msg req; /* HTTP request message */ struct hdr_idx hdr_idx; /* array of header indexes (max: global.tune.max_http_hdr) */ - unsigned int flags; /* transaction flags */ - http_meth_t meth; /* HTTP method */ - - int status; /* HTTP status from the server, negative if from proxy */ struct http_msg rsp; /* HTTP response message */ + struct http_msg req; /* HTTP request message */ + unsigned int flags; /* transaction flags */ + enum http_meth_t meth; /* HTTP method */ + /* 1 unused byte here */ + short status; /* HTTP status from the server, negative if from proxy */ char *uri; /* first line if log needed, NULL otherwise */ char *cli_cookie; /* cookie presented by the client, in capture mode */ diff --git a/src/proto_http.c b/src/proto_http.c index a06b0ec8ec..c8705d4745 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -294,7 +294,7 @@ void init_proto_http() * up to 3 entries (2 valid, 1 null). */ struct http_method_desc { - http_meth_t meth; + enum http_meth_t meth; int len; const char text[8]; }; @@ -767,7 +767,7 @@ struct chunk *http_error_message(struct session *s, int msgnum) * returns HTTP_METH_NONE if there is nothing valid to read (empty or non-text * string), HTTP_METH_OTHER for unknown methods, or the identified method. */ -static http_meth_t find_http_meth(const char *str, const int len) +static enum http_meth_t find_http_meth(const char *str, const int len) { unsigned char m; const struct http_method_desc *h;