[PATCH 09/11] Router: removed unused structure member proxy_buffers.

Andrew Clayton andrew at digital-domain.net
Thu Jun 16 18:17:06 UTC 2022


On Thu, 16 Jun 2022 18:01:15 +0200
Alejandro Colomar <alx.manpages at gmail.com> wrote:


> BTW, I didn't know about pahole(1).  It would be nice to show the 
> command invocation before the command output, to see how it works :)

Actually I notice with TLS enabled we are back to 4 cachelines

$ pahole -C nxt_socket_conf_t build/unitd
typedef struct {
        uint32_t                   count;                /*     0     4 */

        /* XXX 4 bytes hole, try to pack */

        nxt_queue_link_t           link;                 /*     8    16 */
        nxt_router_conf_t *        router_conf;          /*    24     8 */
        nxt_http_action_t *        action;               /*    32     8 */
        nxt_sockaddr_t *           sockaddr;             /*    40     8 */
        nxt_listen_socket_t *      listen;               /*    48     8 */
        size_t                     header_buffer_size;   /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        size_t                     large_header_buffer_size; /*    64     8 */
        size_t                     large_header_buffers; /*    72     8 */
        size_t                     body_buffer_size;     /*    80     8 */
        size_t                     max_body_size;        /*    88     8 */
        size_t                     proxy_header_buffer_size; /*    96     8 */
        size_t                     proxy_buffer_size;    /*   104     8 */
        nxt_msec_t                 idle_timeout;         /*   112     4 */
        nxt_msec_t                 header_read_timeout;  /*   116     4 */
        nxt_msec_t                 body_read_timeout;    /*   120     4 */
        nxt_msec_t                 send_timeout;         /*   124     4 */
        /* --- cacheline 2 boundary (128 bytes) --- */
        nxt_msec_t                 proxy_timeout;        /*   128     4 */
        nxt_msec_t                 proxy_send_timeout;   /*   132     4 */
        nxt_msec_t                 proxy_read_timeout;   /*   136     4 */

        /* XXX 4 bytes hole, try to pack */

        nxt_websocket_conf_t       websocket_conf;       /*   144    16 */
        nxt_str_t                  body_temp_path;       /*   160    16 */
        uint8_t                    discard_unsafe_fields; /*   176     1 */

        /* XXX 7 bytes hole, try to pack */

        nxt_http_client_ip_t *     client_ip;            /*   184     8 */
        /* --- cacheline 3 boundary (192 bytes) --- */
        nxt_tls_conf_t *           tls;                  /*   192     8 */

        /* size: 200, cachelines: 4, members: 25 */
        /* sum members: 185, holes: 3, sum holes: 15 */
        /* last cacheline: 8 bytes */
} nxt_socket_conf_t;

However if we move count to after the nxt_msec_t's that brings us back
down to 3 again even with TLS enabled.

$ pahole -C nxt_socket_conf_t build/unitd
typedef struct {
        nxt_queue_link_t           link;                 /*     0    16 */
        nxt_router_conf_t *        router_conf;          /*    16     8 */
        nxt_http_action_t *        action;               /*    24     8 */
        nxt_sockaddr_t *           sockaddr;             /*    32     8 */
        nxt_listen_socket_t *      listen;               /*    40     8 */
        size_t                     header_buffer_size;   /*    48     8 */
        size_t                     large_header_buffer_size; /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        size_t                     large_header_buffers; /*    64     8 */
        size_t                     body_buffer_size;     /*    72     8 */
        size_t                     max_body_size;        /*    80     8 */
        size_t                     proxy_header_buffer_size; /*    88     8 */
        size_t                     proxy_buffer_size;    /*    96     8 */
        nxt_msec_t                 idle_timeout;         /*   104     4 */
        nxt_msec_t                 header_read_timeout;  /*   108     4 */
        nxt_msec_t                 body_read_timeout;    /*   112     4 */
        nxt_msec_t                 send_timeout;         /*   116     4 */
        nxt_msec_t                 proxy_timeout;        /*   120     4 */
        nxt_msec_t                 proxy_send_timeout;   /*   124     4 */
        /* --- cacheline 2 boundary (128 bytes) --- */
        nxt_msec_t                 proxy_read_timeout;   /*   128     4 */
        uint32_t                   count;                /*   132     4 */
        nxt_websocket_conf_t       websocket_conf;       /*   136    16 */
        nxt_str_t                  body_temp_path;       /*   152    16 */
        uint8_t                    discard_unsafe_fields; /*   168     1 */

        /* XXX 7 bytes hole, try to pack */

        nxt_http_client_ip_t *     client_ip;            /*   176     8 */
        nxt_tls_conf_t *           tls;                  /*   184     8 */

        /* size: 192, cachelines: 3, members: 25 */
        /* sum members: 185, holes: 1, sum holes: 7 */
} nxt_socket_conf_t;

So unless there is a good reason that count is the first member then
it's probably worth doing.

Cheers,
Andrew

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.nginx.org/pipermail/unit/attachments/20220616/9d8d85be/attachment.bin>


More information about the unit mailing list