Skip to content

Commit

Permalink
quic: remove hashmap sparsity option (#3111)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ripatel-fd and riptl authored Oct 12, 2024
1 parent d5389f4 commit 824a49b
Show file tree
Hide file tree
Showing 22 changed files with 3 additions and 39 deletions.
2 changes: 0 additions & 2 deletions contrib/quic/agave_compat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/app/fdctl/run/tiles/fd_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/app/fddev/tiles/fd_benchs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/app/fddev/txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/waltz/quic/fd_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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 );
Expand Down
2 changes: 0 additions & 2 deletions src/waltz/quic/fd_quic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
7 changes: 2 additions & 5 deletions src/waltz/quic/fd_quic_conn.c
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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 = (
Expand All @@ -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;
Expand All @@ -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<<lg) < (ulong)((double)stream_cnt*stream_sparsity) ) {
while( lg < 20 && (1ul<<lg) < (ulong)((double)stream_cnt*FD_QUIC_DEFAULT_SPARSITY) ) {
lg++;
}
layout->stream_map_lg = (int)lg;
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/arp/test_quic_arp_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/arp/test_quic_arp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions src/waltz/quic/tests/fd_quic_test_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/fuzz_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions src/waltz/quic/tests/fuzz_quic_wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_bw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_client_flood.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_drops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_hs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions src/waltz/quic/tests/test_quic_idle_conns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
};
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_key_phase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
1 change: 0 additions & 1 deletion src/waltz/quic/tests/test_quic_retry_integration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions src/waltz/quic/tests/test_quic_streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions src/waltz/quic/tests/test_quic_txns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
};
Expand Down

0 comments on commit 824a49b

Please sign in to comment.