From 631ab218386d0b024bf5b86c3b80698671d82907 Mon Sep 17 00:00:00 2001 From: jiangjianfeng Date: Tue, 31 Dec 2024 02:55:30 +0000 Subject: [PATCH] Set hash buckets as 2 to work around performance bottleneck --- kernel/libs/aster-bigtcp/src/socket_table.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/libs/aster-bigtcp/src/socket_table.rs b/kernel/libs/aster-bigtcp/src/socket_table.rs index cc7f615e4..4b25550b1 100644 --- a/kernel/libs/aster-bigtcp/src/socket_table.rs +++ b/kernel/libs/aster-bigtcp/src/socket_table.rs @@ -147,9 +147,11 @@ pub(crate) struct SocketTable { // On Linux, the number of buckets is determined at runtime based on the available memory. // For simplicity, we use fixed values here. // The bucket count should be a power of 2 to ensure efficient modulo calculations. -const LISTENER_BUCKET_COUNT: u32 = 64; +// FIXME: We have reduced the bucket count to 2 because iterating over all buckets has become a bottleneck. +// Once we can avoid such iterations, we should set more meaningful bucket counts. +const LISTENER_BUCKET_COUNT: u32 = 2; const LISTENER_BUCKET_MASK: u32 = LISTENER_BUCKET_COUNT - 1; -const CONNECTION_BUCKET_COUNT: u32 = 8192; +const CONNECTION_BUCKET_COUNT: u32 = 2; const CONNECTION_BUCKET_MASK: u32 = CONNECTION_BUCKET_COUNT - 1; const_assert!(LISTENER_BUCKET_COUNT.is_power_of_two());