[pgpool-general: 3944] Re: accept() scalability issues
Tatsuo Ishii
ishii at postgresql.org
Mon Aug 10 18:25:31 JST 2015
> So if there’s nothing horribly wrong/out of the ordinary with our setup, I’d pretty much say that with a high number of children fencing around select/accept is dearly needed.
Ok, here is the experimental patch to serialize select(2) for listen
fds by using semaphore. Could you please try it out? The patch is
against 3.3-stable.
Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
-------------- next part --------------
diff --git a/child.c b/child.c
index 779cd81..ebe1b23 100644
--- a/child.c
+++ b/child.c
@@ -535,7 +535,9 @@ static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *time
#endif
}
+ pool_semaphore_lock(LISTEN_FD_SEM);
fds = select(Max(unix_fd, inet_fd)+1, &readmask, NULL, NULL, timeoutval);
+ pool_semaphore_unlock(LISTEN_FD_SEM);
save_errno = errno;
/* check backend timer is expired */
diff --git a/pool.h b/pool.h
index 29555d0..6a7e9c9 100644
--- a/pool.h
+++ b/pool.h
@@ -342,11 +342,12 @@ extern int my_master_node_id;
#define NO_LOAD_BALANCE "/*NO LOAD BALANCE*/"
#define NO_LOAD_BALANCE_COMMENT_SZ (sizeof(NO_LOAD_BALANCE)-1)
-#define MAX_NUM_SEMAPHORES 4
+#define MAX_NUM_SEMAPHORES 5
#define CONN_COUNTER_SEM 0
#define REQUEST_INFO_SEM 1
#define SHM_CACHE_SEM 2
#define QUERY_CACHE_STATS_SEM 3
+#define LISTEN_FD_SEM 4
#define MAX_REQUEST_QUEUE_SIZE 10
/*
More information about the pgpool-general
mailing list