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 9FF519DC996 for ; Mon, 2 Jan 2006 14:45:26 -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 74666-06 for ; Mon, 2 Jan 2006 14:45:26 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 7AC9C9DC991 for ; Mon, 2 Jan 2006 14:45:23 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k02IjLoW007839; Mon, 2 Jan 2006 13:45:21 -0500 (EST) To: Bruce Momjian cc: Michael Fuhr , Merlin Moncure , Carlos Benkendorf , PostgreSQL-patches Subject: Re: Stats collector performance improvement In-reply-to: <200601021840.k02Ieed21704@candle.pha.pa.us> References: <200601021840.k02Ieed21704@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Mon, 02 Jan 2006 13:40:40 -0500" Date: Mon, 02 Jan 2006 13:45:21 -0500 Message-ID: <7838.1136227521@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] X-Spam-Score: 0.06 X-Spam-Level: X-Archive-Number: 200601/12 X-Sequence-Number: 18348 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? 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. regards, tom lane