func conn_pool_get_key performance optimization

use_iouring
YuQing 2025-07-26 16:58:25 +08:00
parent a1ae1cbcb0
commit dd0d4dbc19
3 changed files with 7 additions and 3 deletions

View File

@ -52,7 +52,11 @@ static int node_init_for_rdma(ConnectionNode *node,
static inline void conn_pool_get_key(const ConnectionInfo *conn,
char *key, int *key_len)
{
*key_len = sprintf(key, "%s-%u", conn->ip_addr, conn->port);
*key_len = strlen(conn->ip_addr);
memcpy(key, conn->ip_addr, *key_len);
*(key + (*key_len)++) = '-';
*(key + (*key_len)++) = (conn->port >> 8) & 0xFF;
*(key + (*key_len)++) = conn->port & 0xFF;
}
static int close_conn(ConnectionPool *cp, ConnectionManager *cm,

View File

@ -11,7 +11,7 @@ ALL_PRGS = test_allocator test_skiplist test_multi_skiplist test_mblock test_blo
test_server_id_func test_pipe test_atomic test_file_write_hole test_file_lock \
test_pthread_wait test_thread_pool test_data_visible test_mutex_lock_perf \
test_queue_perf test_normalize_path test_sorted_array test_sorted_queue \
test_thread_local test_memcpy mblock_benchmark
test_thread_local test_memcpy mblock_benchmark cpool_benchmark
all: $(ALL_PRGS)

View File

@ -28,7 +28,7 @@
#include "fastcommon/connection_pool.h"
static int thread_count = 2;
static int64_t loop_count = 1000000;
static int64_t loop_count = 10000000;
static ConnectionPool cpool;
static void *thread_run(void *args)