From 824a49bb0f38fe7c86d9dc34df08e5e1a4bf102b Mon Sep 17 00:00:00 2001 From: ripatel-fd Date: Sat, 12 Oct 2024 23:26:56 +0200 Subject: [PATCH] quic: remove hashmap sparsity option (#3111) Simplify the fd_quic public API by removing 'sparsity' options from configuration. Tests choose these almost always arbitrarily. fd_quic should instead compute the optimal load factor given the conn table and stream pool size. Co-authored-by: Richard Patel --- contrib/quic/agave_compat/src/main.rs | 2 -- src/app/fdctl/run/tiles/fd_quic.c | 2 -- src/app/fddev/tiles/fd_benchs.c | 2 -- src/app/fddev/txn.c | 2 -- src/waltz/quic/fd_quic.c | 5 +---- src/waltz/quic/fd_quic.h | 2 -- src/waltz/quic/fd_quic_conn.c | 7 ++----- src/waltz/quic/tests/arp/test_quic_arp_client.c | 1 - src/waltz/quic/tests/arp/test_quic_arp_server.c | 1 - src/waltz/quic/tests/fd_quic_test_helpers.c | 2 -- src/waltz/quic/tests/fuzz_quic.c | 1 - src/waltz/quic/tests/fuzz_quic_wire.c | 2 -- src/waltz/quic/tests/test_quic_bw.c | 1 - src/waltz/quic/tests/test_quic_client_flood.c | 1 - src/waltz/quic/tests/test_quic_conn.c | 1 - src/waltz/quic/tests/test_quic_drops.c | 1 - src/waltz/quic/tests/test_quic_hs.c | 1 - src/waltz/quic/tests/test_quic_idle_conns.c | 2 -- src/waltz/quic/tests/test_quic_key_phase.c | 1 - src/waltz/quic/tests/test_quic_retry_integration.c | 1 - src/waltz/quic/tests/test_quic_streams.c | 2 -- src/waltz/quic/tests/test_quic_txns.c | 2 -- 22 files changed, 3 insertions(+), 39 deletions(-) diff --git a/contrib/quic/agave_compat/src/main.rs b/contrib/quic/agave_compat/src/main.rs index ee8f321d99..25133a2ff8 100644 --- a/contrib/quic/agave_compat/src/main.rs +++ b/contrib/quic/agave_compat/src/main.rs @@ -205,10 +205,8 @@ unsafe fn agave_to_fdquic_bench() { conn_cnt: 1, handshake_cnt: 1, conn_id_cnt: 4, - conn_id_sparsity: 4.0, stream_cnt: [0, 0, 1024, 0], initial_stream_cnt: [0, 0, 1024, 0], - stream_sparsity: 4.0, inflight_pkt_cnt: 1024, tx_buf_sz: 0, stream_pool_cnt: 1024, diff --git a/src/app/fdctl/run/tiles/fd_quic.c b/src/app/fdctl/run/tiles/fd_quic.c index 4d0e51365f..b45093be03 100644 --- a/src/app/fdctl/run/tiles/fd_quic.c +++ b/src/app/fdctl/run/tiles/fd_quic.c @@ -83,7 +83,6 @@ quic_limits( fd_topo_tile_t const * tile ) { completing a handshake. Connection migration is not supported either. */ .conn_id_cnt = FD_QUIC_MAX_CONN_ID_PER_CONN, - .conn_id_sparsity = FD_QUIC_DEFAULT_SPARSITY, .inflight_pkt_cnt = tile->quic.max_inflight_quic_packets, .tx_buf_sz = 0, .stream_cnt[ FD_QUIC_STREAM_TYPE_BIDI_CLIENT ] = 0, @@ -94,7 +93,6 @@ quic_limits( fd_topo_tile_t const * tile ) { .initial_stream_cnt[ FD_QUIC_STREAM_TYPE_BIDI_SERVER ] = 0, .initial_stream_cnt[ FD_QUIC_STREAM_TYPE_UNI_CLIENT ] = tile->quic.max_concurrent_streams_per_connection, .initial_stream_cnt[ FD_QUIC_STREAM_TYPE_UNI_SERVER ] = 0, - .stream_sparsity = FD_QUIC_DEFAULT_SPARSITY, .stream_pool_cnt = tile->quic.stream_pool_cnt, }; return limits; diff --git a/src/app/fddev/tiles/fd_benchs.c b/src/app/fddev/tiles/fd_benchs.c index fce4c42969..e3bcbccca8 100644 --- a/src/app/fddev/tiles/fd_benchs.c +++ b/src/app/fddev/tiles/fd_benchs.c @@ -293,8 +293,6 @@ populate_quic_limits( fd_quic_limits_t * limits ) { limits->conn_cnt = 2; limits->handshake_cnt = limits->conn_cnt; limits->conn_id_cnt = 16; - limits->conn_id_sparsity = 4.0; - limits->stream_sparsity = 2.0; limits->inflight_pkt_cnt = 1500; limits->tx_buf_sz = fd_ulong_pow2_up( FD_TXN_MTU ); limits->stream_pool_cnt = 1<<16; diff --git a/src/app/fddev/txn.c b/src/app/fddev/txn.c index d4031c3371..f920bef75c 100644 --- a/src/app/fddev/txn.c +++ b/src/app/fddev/txn.c @@ -145,7 +145,6 @@ txn_cmd_fn( args_t * args, .conn_cnt = 1UL, .handshake_cnt = 1UL, .conn_id_cnt = 4UL, - .conn_id_sparsity = 4.0, .stream_cnt = { 0UL, // FD_QUIC_STREAM_TYPE_BIDI_CLIENT 0UL, // FD_QUIC_STREAM_TYPE_BIDI_SERVER 1UL, // FD_QUIC_STREAM_TYPE_UNI_CLIENT @@ -154,7 +153,6 @@ txn_cmd_fn( args_t * args, 0UL, // FD_QUIC_STREAM_TYPE_BIDI_SERVER 1UL, // FD_QUIC_STREAM_TYPE_UNI_CLIENT 0UL }, // FD_QUIC_STREAM_TYPE_UNI_SERVER - .stream_sparsity = 4.0, .inflight_pkt_cnt = 64UL, .tx_buf_sz = fd_ulong_pow2_up( FD_TXN_MTU ), .stream_pool_cnt = 16 diff --git a/src/waltz/quic/fd_quic.c b/src/waltz/quic/fd_quic.c index 5f5eb30282..2757db0cc9 100644 --- a/src/waltz/quic/fd_quic.c +++ b/src/waltz/quic/fd_quic.c @@ -122,7 +122,6 @@ fd_quic_footprint_ext( fd_quic_limits_t const * limits, ulong conn_cnt = limits->conn_cnt; ulong conn_id_cnt = limits->conn_id_cnt; - double conn_id_sparsity = limits->conn_id_sparsity; ulong handshake_cnt = limits->handshake_cnt; ulong inflight_pkt_cnt = limits->inflight_pkt_cnt; ulong tx_buf_sz = limits->tx_buf_sz; @@ -137,8 +136,6 @@ fd_quic_footprint_ext( fd_quic_limits_t const * limits, /* connection */ if( FD_UNLIKELY( stream_pool_cnt < FD_QUIC_STREAM_MIN * conn_cnt ) ) return 0UL; - if( FD_UNLIKELY( conn_id_sparsity==0.0 ) ) - conn_id_sparsity = FD_QUIC_DEFAULT_SPARSITY; if( FD_UNLIKELY( conn_id_cnt < FD_QUIC_MIN_CONN_ID_CNT )) return 0UL; @@ -163,7 +160,7 @@ fd_quic_footprint_ext( fd_quic_limits_t const * limits, /* allocate space for conn IDs */ offs = fd_ulong_align_up( offs, fd_quic_conn_map_align() ); layout->conn_map_off = offs; - ulong slot_cnt_bound = (ulong)( conn_id_sparsity * (double)conn_cnt * (double)conn_id_cnt ); + ulong slot_cnt_bound = (ulong)( FD_QUIC_DEFAULT_SPARSITY * (double)conn_cnt * (double)conn_id_cnt ); int lg_slot_cnt = fd_ulong_find_msb( slot_cnt_bound - 1 ) + 1; layout->lg_slot_cnt = lg_slot_cnt; ulong conn_map_footprint = fd_quic_conn_map_footprint( lg_slot_cnt ); diff --git a/src/waltz/quic/fd_quic.h b/src/waltz/quic/fd_quic.h index 2b4c4f0088..aaf5a4e11f 100644 --- a/src/waltz/quic/fd_quic.h +++ b/src/waltz/quic/fd_quic.h @@ -109,11 +109,9 @@ struct __attribute__((aligned(16UL))) fd_quic_limits { ulong handshake_cnt; /* instance-wide, max concurrent handshake count */ ulong conn_id_cnt; /* per-conn, max conn ID count (min 4UL) */ - double conn_id_sparsity; /* per-conn, conn ID hashmap sparsity */ ulong stream_cnt[4]; /* per-conn, max concurrent stream count */ ulong initial_stream_cnt[4]; /* per-conn, initial target max concurrent stream count */ - double stream_sparsity; /* per-conn, stream hashmap sparsity */ ulong inflight_pkt_cnt; /* per-conn, max inflight packet count */ diff --git a/src/waltz/quic/fd_quic_conn.c b/src/waltz/quic/fd_quic_conn.c index f5a38d55bb..5fb03abf26 100644 --- a/src/waltz/quic/fd_quic_conn.c +++ b/src/waltz/quic/fd_quic_conn.c @@ -1,6 +1,7 @@ #include "fd_quic_conn.h" #include "fd_quic_common.h" #include "../../util/fd_util.h" +#include "fd_quic_enum.h" #include "fd_quic_pkt_meta.h" #include "fd_quic_private.h" @@ -42,7 +43,6 @@ static ulong fd_quic_conn_footprint_ext( fd_quic_limits_t const * limits, fd_quic_conn_layout_t * layout ) { - double stream_sparsity = limits->stream_sparsity; ulong inflight_pkt_cnt = limits->inflight_pkt_cnt; ulong stream_cnt = ( @@ -54,9 +54,6 @@ fd_quic_conn_footprint_ext( fd_quic_limits_t const * limits, if( FD_UNLIKELY( stream_cnt ==0UL ) ) return 0UL; if( FD_UNLIKELY( inflight_pkt_cnt==0UL ) ) return 0UL; - if( FD_UNLIKELY( stream_sparsity==0.0 ) ) { - stream_sparsity = FD_QUIC_DEFAULT_SPARSITY; - } /* initial stream count not allowed to be larger than max stream count limit */ if( FD_UNLIKELY( limits->initial_stream_cnt[0] > limits->stream_cnt[0] ) ) return 0UL; @@ -73,7 +70,7 @@ fd_quic_conn_footprint_ext( fd_quic_limits_t const * limits, /* allocate space for stream hash map */ /* about a million seems like a decent bound, with expected values up to 20,000 */ ulong lg = 0; - while( lg < 20 && (1ul<stream_map_lg = (int)lg; diff --git a/src/waltz/quic/tests/arp/test_quic_arp_client.c b/src/waltz/quic/tests/arp/test_quic_arp_client.c index bc4778d3a6..e054733a2c 100644 --- a/src/waltz/quic/tests/arp/test_quic_arp_client.c +++ b/src/waltz/quic/tests/arp/test_quic_arp_client.c @@ -240,7 +240,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 2, 2, 2, 2 }, .initial_stream_cnt = { 2, 2, 2, 2 }, diff --git a/src/waltz/quic/tests/arp/test_quic_arp_server.c b/src/waltz/quic/tests/arp/test_quic_arp_server.c index 181c0cd2ee..219f8ece7b 100644 --- a/src/waltz/quic/tests/arp/test_quic_arp_server.c +++ b/src/waltz/quic/tests/arp/test_quic_arp_server.c @@ -123,7 +123,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 2, 2, 2, 2 }, .initial_stream_cnt = { 2, 2, 2, 2 }, diff --git a/src/waltz/quic/tests/fd_quic_test_helpers.c b/src/waltz/quic/tests/fd_quic_test_helpers.c index fa8919d76c..2bc6e924b5 100644 --- a/src/waltz/quic/tests/fd_quic_test_helpers.c +++ b/src/waltz/quic/tests/fd_quic_test_helpers.c @@ -190,10 +190,8 @@ fd_quic_new_anonymous_small( fd_wksp_t * wksp, .conn_cnt = 1UL, .handshake_cnt = 1UL, .conn_id_cnt = 4UL, - .conn_id_sparsity = 4.0, .stream_cnt = { 1, 1, 1, 1 }, .initial_stream_cnt = { 1, 1, 1, 1 }, - .stream_sparsity = 4.0, .inflight_pkt_cnt = 64UL, .tx_buf_sz = 1UL<<15UL, .stream_pool_cnt = 1024 diff --git a/src/waltz/quic/tests/fuzz_quic.c b/src/waltz/quic/tests/fuzz_quic.c index c2c659bf6a..c5e541d31d 100644 --- a/src/waltz/quic/tests/fuzz_quic.c +++ b/src/waltz/quic/tests/fuzz_quic.c @@ -159,7 +159,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) { fd_quic_limits_t const quic_limits = {.conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = {0, 0, 10, 0}, .initial_stream_cnt = {0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/fuzz_quic_wire.c b/src/waltz/quic/tests/fuzz_quic_wire.c index bb0be6f3a8..07a9d8d999 100644 --- a/src/waltz/quic/tests/fuzz_quic_wire.c +++ b/src/waltz/quic/tests/fuzz_quic_wire.c @@ -109,9 +109,7 @@ LLVMFuzzerTestOneInput( uchar const * data, .conn_cnt = 2, .handshake_cnt = 16, .conn_id_cnt = 16, - .conn_id_sparsity = 1.0, .stream_cnt = { 1, 1, 1, 1 }, - .stream_sparsity = 1.0, .inflight_pkt_cnt = 8UL, .tx_buf_sz = 4096UL, .stream_pool_cnt = 1024 diff --git a/src/waltz/quic/tests/test_quic_bw.c b/src/waltz/quic/tests/test_quic_bw.c index 4f13eb5460..2f6e9dc582 100644 --- a/src/waltz/quic/tests/test_quic_bw.c +++ b/src/waltz/quic/tests/test_quic_bw.c @@ -82,7 +82,6 @@ main( int argc, fd_quic_limits_t const quic_limits = { .conn_cnt = 1, .conn_id_cnt = 4, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 0, 0, 10, 0 }, .initial_stream_cnt = { 0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/test_quic_client_flood.c b/src/waltz/quic/tests/test_quic_client_flood.c index f49170a910..588a92e61c 100644 --- a/src/waltz/quic/tests/test_quic_client_flood.c +++ b/src/waltz/quic/tests/test_quic_client_flood.c @@ -279,7 +279,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t quic_limits = {0}; fd_quic_limits_from_env( &argc, &argv, &quic_limits ); - quic_limits.conn_id_sparsity = 4.0; ulong quic_footprint = fd_quic_footprint( &quic_limits ); FD_TEST( quic_footprint ); diff --git a/src/waltz/quic/tests/test_quic_conn.c b/src/waltz/quic/tests/test_quic_conn.c index 25ff1da80b..9aa918da25 100644 --- a/src/waltz/quic/tests/test_quic_conn.c +++ b/src/waltz/quic/tests/test_quic_conn.c @@ -312,7 +312,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 0, 0, 10, 0 }, .initial_stream_cnt = { 0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/test_quic_drops.c b/src/waltz/quic/tests/test_quic_drops.c index 583d27161c..79d0b282cc 100644 --- a/src/waltz/quic/tests/test_quic_drops.c +++ b/src/waltz/quic/tests/test_quic_drops.c @@ -474,7 +474,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 0, 0, 10, 0 }, .initial_stream_cnt = { 0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/test_quic_hs.c b/src/waltz/quic/tests/test_quic_hs.c index bd875b3894..3edfa1a869 100644 --- a/src/waltz/quic/tests/test_quic_hs.c +++ b/src/waltz/quic/tests/test_quic_hs.c @@ -85,7 +85,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 0, 0, 10, 0 }, .initial_stream_cnt = { 0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/test_quic_idle_conns.c b/src/waltz/quic/tests/test_quic_idle_conns.c index 1f2f8004e3..d143582b2e 100644 --- a/src/waltz/quic/tests/test_quic_idle_conns.c +++ b/src/waltz/quic/tests/test_quic_idle_conns.c @@ -226,7 +226,6 @@ main( int argc, .conn_cnt = num_conns, .handshake_cnt = num_conns, .conn_id_cnt = 16UL, - .conn_id_sparsity = 4.0, .stream_cnt = { 0UL, // FD_QUIC_STREAM_TYPE_BIDI_CLIENT 0UL, // FD_QUIC_STREAM_TYPE_BIDI_SERVER 2UL, // FD_QUIC_STREAM_TYPE_UNI_CLIENT @@ -236,7 +235,6 @@ main( int argc, 2UL, // FD_QUIC_STREAM_TYPE_UNI_CLIENT 0UL }, // FD_QUIC_STREAM_TYPE_UNI_SERVER .stream_pool_cnt = num_conns * FD_QUIC_STREAM_MIN, - .stream_sparsity = 4.0, .inflight_pkt_cnt = 64UL, .tx_buf_sz = 0 }; diff --git a/src/waltz/quic/tests/test_quic_key_phase.c b/src/waltz/quic/tests/test_quic_key_phase.c index 597ed745a1..32f431a761 100644 --- a/src/waltz/quic/tests/test_quic_key_phase.c +++ b/src/waltz/quic/tests/test_quic_key_phase.c @@ -426,7 +426,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 0, 0, 10, 0 }, .initial_stream_cnt = { 0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/test_quic_retry_integration.c b/src/waltz/quic/tests/test_quic_retry_integration.c index b2d53f50e3..7619e9b73f 100644 --- a/src/waltz/quic/tests/test_quic_retry_integration.c +++ b/src/waltz/quic/tests/test_quic_retry_integration.c @@ -84,7 +84,6 @@ main( int argc, char ** argv ) { fd_quic_limits_t const quic_limits = { .conn_cnt = 10, .conn_id_cnt = 10, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 0, 0, 10, 0 }, .initial_stream_cnt = { 0, 0, 10, 0 }, diff --git a/src/waltz/quic/tests/test_quic_streams.c b/src/waltz/quic/tests/test_quic_streams.c index dab590d13d..520a13038e 100644 --- a/src/waltz/quic/tests/test_quic_streams.c +++ b/src/waltz/quic/tests/test_quic_streams.c @@ -105,7 +105,6 @@ main( int argc, fd_quic_limits_t const quic_server_limits = { .conn_cnt = 2, .conn_id_cnt = 4, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 20, 20, 20, 20 }, .initial_stream_cnt = { 20, 20, 20, 20 }, @@ -121,7 +120,6 @@ main( int argc, fd_quic_limits_t const quic_client_limits = { .conn_cnt = 2, .conn_id_cnt = 4, - .conn_id_sparsity = 4.0, .handshake_cnt = 10, .stream_cnt = { 20, 20, 20, 20 }, .initial_stream_cnt = { 20, 20, 20, 20 }, diff --git a/src/waltz/quic/tests/test_quic_txns.c b/src/waltz/quic/tests/test_quic_txns.c index fe005de7c2..5f88c1779e 100644 --- a/src/waltz/quic/tests/test_quic_txns.c +++ b/src/waltz/quic/tests/test_quic_txns.c @@ -255,7 +255,6 @@ main( int argc, .conn_cnt = 1024UL, .handshake_cnt = 256UL, .conn_id_cnt = 16UL, - .conn_id_sparsity = 4.0, .stream_cnt = { 0UL, // FD_QUIC_STREAM_TYPE_BIDI_CLIENT 0UL, // FD_QUIC_STREAM_TYPE_BIDI_SERVER 2UL, // FD_QUIC_STREAM_TYPE_UNI_CLIENT @@ -265,7 +264,6 @@ main( int argc, 2UL, // FD_QUIC_STREAM_TYPE_UNI_CLIENT 0UL }, // FD_QUIC_STREAM_TYPE_UNI_SERVER .stream_pool_cnt = 2048UL, - .stream_sparsity = 4.0, .inflight_pkt_cnt = 64UL, .tx_buf_sz = 1UL<<15UL };