Page MenuHomeFreeBSD

tcp: Allocate t_tcpreq_info on demand
ClosedPublic

Authored by gallatin on Fri, Apr 17, 8:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 18, 7:50 AM
Unknown Object (File)
Sat, Apr 18, 6:16 AM
Subscribers

Details

Summary

When TCP_REQUEST_TRK is enabled, the tcb grows by 600 bytes
to accommodate the t_tcpreq_info[MAX_TCP_TRK_REQ] array.
Even when the option is enabled, not every connection is using
this feature. So let's allocate it on-demand, and save 600
bytes in the common case.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Fri, Apr 17, 8:19 PM

Given this is purely a RACK feature, I would suggest to move it from generic struct tcpcb to struct tcp_rack.

Two options: 1) embed all of this in struct tcp_rack:

#ifdef TCP_REQUEST_TRK
        /* Response tracking addons. */
        uint8_t t_tcpreq_req;   /* Request count */
        uint8_t t_tcpreq_open;  /* Number of open range requests */
        uint8_t t_tcpreq_closed;        /* Number of closed range requests */
        uint32_t tcp_hybrid_start;      /* Num of times we started hybrid pacing */
        uint32_t tcp_hybrid_stop;       /* Num of times we stopped hybrid pacing */
        uint32_t tcp_hybrid_error;      /* Num of times we failed to start hybrid pacing */
        struct tcp_sendfile_track *t_tcpreq_info;
#endif

or 2) create a new structure that holds all of the above, lazily allocate it and have a pointer from struct tcp_rack to it.

Two options: 1) embed all of this in struct tcp_rack:

#ifdef TCP_REQUEST_TRK
        /* Response tracking addons. */
        uint8_t t_tcpreq_req;   /* Request count */
        uint8_t t_tcpreq_open;  /* Number of open range requests */
        uint8_t t_tcpreq_closed;        /* Number of closed range requests */
        uint32_t tcp_hybrid_start;      /* Num of times we started hybrid pacing */
        uint32_t tcp_hybrid_stop;       /* Num of times we stopped hybrid pacing */
        uint32_t tcp_hybrid_error;      /* Num of times we failed to start hybrid pacing */
        struct tcp_sendfile_track *t_tcpreq_info;
#endif

or 2) create a new structure that holds all of the above, lazily allocate it and have a pointer from struct tcp_rack to it.

The same could be said of TCP_ACCOUNTING as well.

In any case, I'd prefer to at least start with this. What you suggest would be much more invasive and require more testing. This is a simple change that delivers 90% of the benefit in terms of shrinking the tcb without a lot of churn or testing required.

I'm not blocking your change. Just suggesting.

I like this first cut simple approach Gleb !!

This revision was automatically updated to reflect the committed changes.