Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agIYr-0002U4-Cf for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Mar 2016 21:00:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1agIYq-0006yA-Kx for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Mar 2016 21:00:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agIYp-0006w5-Hl for pgsql-bugs@postgresql.org; Wed, 16 Mar 2016 21:00:55 +0000 Received: from c.mail.sonic.net ([64.142.111.80]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agIYl-0004xD-O7 for pgsql-bugs@postgresql.org; Wed, 16 Mar 2016 21:00:55 +0000 Received: from engels (162-236-13-58.lightspeed.sntcca.sbcglobal.net [162.236.13.58]) (authenticated bits=0) by c.mail.sonic.net (8.15.1/8.15.1) with ESMTPSA id u2GL0Zsl025409 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA256 bits=128 verify=NOT); Wed, 16 Mar 2016 14:00:35 -0700 Date: Wed, 16 Mar 2016 14:00:38 -0700 From: David Gould To: Alvaro Herrera Cc: Jeff Janes , Tom Lane , Pg Bugs , Josh Berkus Subject: Re: BUG #13750: Autovacuum slows down with large numbers of tables. More workers makes it slower. Message-ID: <20160316140038.06a1934d@engels> In-Reply-To: <20160315142816.5dca09dd@engels> References: <20160302034537.0b1c2da7@engels> <20160315204026.GA29216@alvherre.pgsql> <20160315142816.5dca09dd@engels> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Sonic-CAuth: UmFuZG9tSVZ1KQ2AaRojkk/e8WyAoiOHxcurY9uEGyR6W5walHJWgJptYf8RXhfntUa9T82LuOOzNiQCnz3qLO7Kzk+FRtxd X-Sonic-ID: C;CFXMILrr5RG/GJ/fr5/Qwg== M;CM0SIbrr5RG/GJ/fr5/Qwg== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Tue, 15 Mar 2016 14:28:16 -0700 David Gould wrote: > On Tue, 15 Mar 2016 17:40:26 -0300 > Alvaro Herrera wrote: > > > David Gould wrote: > > > On Mon, 29 Feb 2016 18:33:50 -0300 > > > Alvaro Herrera wrote: > > > > > > > Hi David, did you ever post an updated version of this patch? > > > > > > No. Let me fix that now. I've attached my current revision of the patch > > > based on master. This version is significantly better than the original > > > version and resolves multiple issues: > > > > Thanks for the patch. I spent some time studying it and testing it. I > > think there's a minor bug in this latest version: the "continue" when > > the "for" loop exits because of all relids being less than > > highest_oid_claimed should be a "break" instead. Otherwise the worker > > will uselessly loop over the whole list of OIDs only to find each time > > that it has nothing to do. > > Good catch. Thanks! Actually, looking at this more closely, I don't see the problem. I'm assuming you meant the continue after "if (relid ==InvalidOid)": /* * 2. While there are items that have not been visited... */ for(oid_idx = 0; oid_idx < numoids; ) { ... /* * 4a. Skip past the highest_oid_claimed to find the next oid to work on. */ relid = InvalidOid; while (relid <= highest_oid_claimed && oid_idx < numoids) relid = table_oids[oid_idx++]; if (relid <= highest_oid_claimed) relid = InvalidOid; /* 4b. Claim the chosen table by storing its oid in shared memory. */ MyWorkerInfo->wi_tableoid = relid; LWLockRelease(AutovacuumLock); /* If we reached the end of the list there is nothing to do. */ if (relid == InvalidOid) continue; ... } At the continue oid_idx will have been incremented by: while (relid <= highest_oid_claimed && oid_idx < numoids) relid = table_oids[oid_idx++]; to be equal to numoids so the for loop will exit immediately as the loop condition is "oid_idx < numoids". "break" would work as well, but basically there is only one reason to exit the for loop, exhausting the list of oids, so continue seemed preferable. Or am I missing something? -dg -- David Gould 510 282 0869 daveg@sonic.net If simplicity worked, the world would be overrun with insects. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs