From 54d9df39033730234540cee49393d40cdfe3658a Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Sun, 20 Mar 2022 08:16:06 +0100 Subject: tcp: Fit struct tcp_conn into a single 64-byte cacheline ...by: - storing the chained-hash next connection pointer as numeric reference rather than as pointer - storing the MSS as 14-bit value, and rounding it - using only the effective amount of bits needed to store the hash bucket number - explicitly limiting window scaling factors to 4-bit values (maximum factor is 14, from RFC 7323) - scaling SO_SNDBUF values, and using a 8-bit representation for the duplicate ACK sequence - keeping window values unscaled, as received and sent Signed-off-by: Stefano Brivio --- tcp.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tcp.h') diff --git a/tcp.h b/tcp.h index 3154b4b..109516d 100644 --- a/tcp.h +++ b/tcp.h @@ -6,11 +6,12 @@ #ifndef TCP_H #define TCP_H -#define REFILL_INTERVAL 1000 /* ms */ +#define REFILL_INTERVAL 1000 /* ms */ #define PORT_DETECT_INTERVAL 1000 #define TCP_TIMER_INTERVAL MIN(REFILL_INTERVAL, PORT_DETECT_INTERVAL) -#define TCP_MAX_CONNS (128 * 1024) +#define TCP_CONN_INDEX_BITS 17 /* 128k */ +#define TCP_MAX_CONNS (1 << TCP_CONN_INDEX_BITS) #define TCP_MAX_SOCKS (TCP_MAX_CONNS + USHRT_MAX * 2) #define TCP_SOCK_POOL_SIZE 32 -- cgit v1.2.3