Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfugT-0005Vo-0M for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2020 00:21:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jfugR-0008NT-OG for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2020 00:21:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfugR-0008NM-Hs for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2020 00:21:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfugO-0005LM-A7 for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2020 00:21:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0520LRHQ512847; Mon, 1 Jun 2020 20:21:27 -0400 From: Tom Lane To: David Rowley cc: "Jawarilal, Manish" , "pgsql-bugs@lists.postgresql.org" Subject: Re: pgbench bug / limitation In-reply-to: References: <7221.1590687090@sss.pgh.pa.us> <10327.1590763515@sss.pgh.pa.us> <384920.1591027137@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 02 Jun 2020 12:07:12 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <512845.1591057287.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 01 Jun 2020 20:21:27 -0400 Message-ID: <512846.1591057287@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > I added the following line to the top of add_socket_to_set(): > printf("add_socket_to_set fd =3D %d\n", fd); > However, on Windows, I get: > add_socket_to_set fd =3D 392 > add_socket_to_set fd =3D 388 > add_socket_to_set fd =3D 408 > add_socket_to_set fd =3D 404 > add_socket_to_set fd =3D 412 > add_socket_to_set fd =3D 420 Interesting. > Shouldn't: if (fd < 0 || fd >=3D FD_SETSIZE) just become: if (idx > FD_S= ETSIZE) ? Certainly not, because it's the fd not the idx that is being added into the fd_set. I am not too sure about the underlying implementation on Windows, but on Unix-like OSes, FD_SETSIZE *is* the size of that bit array. What you suggest would allow memory stomps. Given your results, I'm guessing that we are indeed managing to increase the fd_set size to 1024, but that's not enough to allow order-of-1000 connections because there are other things competing for FD identifiers. Maybe we should just crank up the forced value of FD_SETSIZE (to, say, 8192)? regards, tom lane