]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DIET/MINOR: http: reduce the size of struct http_txn by 8 bytes
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Dec 2013 22:43:17 +0000 (23:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 15:06:22 +0000 (16:06 +0100)
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.

include/types/proto_http.h
src/proto_http.c

index 5a671b0b90cd213dd8ef75d5730d51e46af4c2d8..52c3c70b18ab7681bb85f336aa8c427cf0e9633c 100644 (file)
@@ -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 */
index a06b0ec8ec9455f1c0c7d1a7fef0f97031b79cb4..c8705d47454332e048bf0d038884872d2c8943ed 100644 (file)
@@ -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;