X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id CD9949DC81E for ; Mon, 2 Jan 2006 15:13:58 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83012-01 for ; Mon, 2 Jan 2006 15:13:58 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 328109DC959 for ; Mon, 2 Jan 2006 15:13:55 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id k02JDlh26741; Mon, 2 Jan 2006 14:13:47 -0500 (EST) From: Bruce Momjian Message-Id: <200601021913.k02JDlh26741@candle.pha.pa.us> Subject: Re: Stats collector performance improvement In-Reply-To: <7838.1136227521@sss.pgh.pa.us> To: Tom Lane Date: Mon, 2 Jan 2006 14:13:47 -0500 (EST) CC: Michael Fuhr , Merlin Moncure , Carlos Benkendorf , PostgreSQL-patches X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] X-Spam-Score: 0.121 X-Spam-Level: X-Archive-Number: 200601/13 X-Sequence-Number: 18349 Tom Lane wrote: > Bruce Momjian writes: > > I found if I put a pg_usleep(100) in the buffer process the backend > > speed was good, but packets were lost. What I found worked well was to > > do multiple recv() calls in a loop. The previous code did a select(), > > then perhaps a recv() and pipe write() based on the results of the > > select(). This caused many small packets to be written to the pipe and > > the pipe write overhead seems fairly large. The best fix I found was to > > loop over the recv() call at most 25 times, collecting a group of > > packets that can then be sent to the collector in one pipe write. The > > recv() socket is non-blocking, so a zero return indicates there are no > > more packets available. Patch attached. > > This seems incredibly OS-specific. How many platforms did you test it > on? Only mine. I am posting the patch so others can test it, of course. > A more serious objection is that it will cause the stats machinery to > work very poorly if there isn't a steady stream of incoming messages. > You can't just sit on 24 messages until the 25th one arrives next week. You wouldn't. It exits out of the loop on a not found, checks the pipe write descriptor, and writes on it. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073