pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: Jawarilal, Manish <Manish.Jawarilal@dell.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: pgbench bug / limitation
Date: Fri, 5 Jun 2020 20:17:01 +0200 (CEST)
Message-ID: <alpine.DEB.2.22.394.2006052004340.32228@pseudo> (raw )
In-Reply-To: <1507639.1591375547@sss.pgh.pa.us >
References: <BL0PR1901MB1985F219C46C61EDE7036C34ED8E0@BL0PR1901MB1985.namprd19.prod.outlook.com >
<7221.1590687090@sss.pgh.pa.us >
<BL0PR1901MB1985A8B4D3E5B39E32A9EA55ED8F0@BL0PR1901MB1985.namprd19.prod.outlook.com >
<10327.1590763515@sss.pgh.pa.us >
<BL0PR1901MB198583EAC6C8A3B770D20F1AED8A0@BL0PR1901MB1985.namprd19.prod.outlook.com >
<384920.1591027137@sss.pgh.pa.us >
<CAApHDvrjWtJa9oQ98oH+9PCvTgOkGZP+gcmottNX95sjn6o9fQ@mail.gmail.com >
<512846.1591057287@sss.pgh.pa.us >
<CAApHDvpMEAaZMxtzixbnb7ySo=Kb1eUfshEB-y4YOm8SgGrpiw@mail.gmail.com >
<alpine.DEB.2.22.394.2006021258170.87735@pseudo >
<CAApHDvpDBkjj6a+Ld-9YGW=_Bcxss8Yyz_QYjtjus3WUsTb+1g@mail.gmail.com >
<1507639.1591375547@sss.pgh.pa.us >
Hello Tom,
> More to the point, this does nothing to get around the O(N^2) cost of
> adding N FDs to the fd_set with Microsoft's implementation; so I do not
> think it's really going to fix the problem for people who want to use
> lots of connections on Windows.
> Alternatively, if we're going to get in bed with the internals of
> Windows' fd_set implementation anyway, we could implement our own
> version of FD_SET that doesn't do the de-duplication.
Yes. See attached, which I cannot test.
--
Fabien.
Attachments:
pgbench-select-win-3.patch (text/x-diff, 1.1K) download
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 08a5947a9e..f94a13750c 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6698,10 +6698,26 @@ clear_socket_set(socket_set *sa)
sa->maxfd = -1;
}
+#ifndef WIN32
+#define FD_IS_VALID(fd, set) ((fd) >= 0 && (fd) < FD_SETSIZE)
+#else
+/*
+ * Windows implementation is bogus: it does not allocate fd with the lowest
+ * possible number, and FD_SET is implemented as a simple array.
+ *
+ * Filling the set is in O(N^2) because of deduplication, but this is
+ * unnecessary here so we just override the macro.
+ */
+#define FD_IS_VALID(fd, set) ((fd) >= 0 && (set)->fd_count < FD_SETSIZE)
+#undef FD_SET
+/* no array overflow if FD_IS_VALID is ok */
+#define FD_SET(fd, set) (set)->fd_array[(set)->fd_count++] = (fd)
+#endif /* WIN32 */
+
static void
add_socket_to_set(socket_set *sa, int fd, int idx)
{
- if (fd < 0 || fd >= FD_SETSIZE)
+ if (!FD_IS_VALID(fd, &sa->fds))
{
/*
* Doing a hard exit here is a bit grotty, but it doesn't seem worth
view thread (26+ messages) latest in thread
Message-ID: <alpine.DEB.2.22.394.2006052004340.32228@pseudo>
Permalink: ../alpine.DEB.2.22.394.2006052004340.32228@pseudo/
Also on: postgresql.org/message-id/alpine.DEB.2.22.394.2006052004340.32228@pseudo
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: coelho@cri.ensmp.fr, tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, Manish.Jawarilal@dell.com, pgsql-bugs@lists.postgresql.org
Subject: Re: pgbench bug / limitation
In-Reply-To: <alpine.DEB.2.22.394.2006052004340.32228@pseudo>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox