Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iYAt6-0000xl-TI for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Nov 2019 15:30:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iYAt5-0007lP-MM for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Nov 2019 15:30:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from <9erthalion6@gmail.com>) id 1iYAt5-0007gr-7S for pgsql-hackers@lists.postgresql.org; Fri, 22 Nov 2019 15:30:23 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1iYAsy-0007Yw-By for pgsql-hackers@postgresql.org; Fri, 22 Nov 2019 15:30:21 +0000 Received: by mail-wr1-x42d.google.com with SMTP id b18so9085508wrj.8 for ; Fri, 22 Nov 2019 07:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kA/3fcq58mB44Kv5epV8CLr9Wob2H0iNpxRokoAvh7w=; b=q4QZgP4S/S5C+biALIjtdMG6DhYVwLmQLT4r1weyoQQM05MIjH6hDPHbAMPO1R42aY Iqh3YZwhRoRRZqFD+jdKicupBDMjYNu7AbaGCuI3lHbnYbeVPJoQEslulu42RY5n/hHD WXPWjJmExdLYuyxzfU5xmu+Vf0HGe267g1bv4C04hr5BFpMexUykvS1BLWeQszRcmTBU Stm9lbtbbOTDlBBbYy3RCDwszd40F4UuVIRpe4LjFuPFj+g+lWNcUYko9uzBfn0EwwPF 5lj8Otp0lpw++3EYT9ByxLepcz4w0T950A/u4qZwVhQGMdZAHiUtDL49CiAjJM1OWGXf 4pqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kA/3fcq58mB44Kv5epV8CLr9Wob2H0iNpxRokoAvh7w=; b=YMMX53Jzblx+NHoEegHIL27lNBW/Hq7Abc4rvlPzRj2cmDrf/zm4LMNnr78G33UyBP /8vqrF3uc1mGSuwzlztdgXsx6wsL5fjmZiqwqCyeZodXz6Q0VKl7v2dPSmxvu18oT+KU sLLiY9U2aqXZt2hG0NOGl4BaHde5uomrQBWhASVqBUhpWUjZxmEdFNfB7vsxD8qf17lg dPdoBlJSVFUQwMJpLBimKBF4PAZ2+qWOVrd2eeQ18wHLBwhA1Ga9J4lH+VXfnBeHo/aC xl6pgyYUcPCcX/51RJoV4NTAqFyWGl9HXZcqpRPYybaoeUG2EZP1QCi5AT0snr8JoUlP 11zg== X-Gm-Message-State: APjAAAX1YpEDRAu8/ejvJDHugGTMC/lvwG9ci0blstJxP0+o3xKh4oX1 RCFRjPjsYV0Ho8SPuitBj5+qpzdvyBY= X-Google-Smtp-Source: APXvYqz2WcSkHI7++gHYBNxMV3JV9slelCgniHBCtWqZTvdOP8Muygm/4B1NnuMbXL+twaG6EXJhOQ== X-Received: by 2002:a5d:6b4d:: with SMTP id x13mr17496819wrw.96.1574436614276; Fri, 22 Nov 2019 07:30:14 -0800 (PST) Received: from localhost ([185.85.220.193]) by smtp.gmail.com with ESMTPSA id 65sm8345303wrs.9.2019.11.22.07.30.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Nov 2019 07:30:13 -0800 (PST) Date: Fri, 22 Nov 2019 16:32:22 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Noah Misch Cc: Tom Lane , pgsql-hackers@postgresql.org Subject: Re: SimpleLruTruncate() mutual exclusion Message-ID: <20191122153222.jeb2jsezhso36obu@localhost> References: <20190218073103.GA1434723@rfd.leadboat.com> <20190628170628.GA1238361@rfd.leadboat.com> <29566.1564419497@sss.pgh.pa.us> <20190801065117.GA2355684@rfd.leadboat.com> <20191117115652.doqc77yu7kbrqwmk@localhost> <20191118061426.GA1173376@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191118061426.GA1173376@rfd.leadboat.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Sun, Nov 17, 2019 at 10:14:26PM -0800, Noah Misch wrote: > > Though I did reproduce this bug, I'm motivated by the abstract problem more > than any particular way to reproduce it. Commit 996d273 inspired me; by > removing a GetCurrentTransactionId(), it allowed the global xmin to advance at > times it previously could not. That subtly changed the concurrency > possibilities. I think safe, parallel SimpleLruTruncate() is difficult to > maintain and helps too rarely to justify such maintenance. That's why I > propose eliminating the concurrency. Sure, I see the point and the possibility for the issue itself, but of course it's easier to reason about an issue I can reproduce :) > I wonder about performance in a database with millions of small relations, > particularly considering my intent to back-patch this. In such databases, > vac_update_datfrozenxid() can be a major part of the VACUUM's cost. Two > things work in our favor. First, vac_update_datfrozenxid() runs once per > VACUUM command, not once per relation. Second, Autovacuum has this logic: > > * ... we skip > * this if (1) we found no work to do and (2) we skipped at least one > * table due to concurrent autovacuum activity. In that case, the other > * worker has already done it, or will do so when it finishes. > */ > if (did_vacuum || !found_concurrent_worker) > vac_update_datfrozenxid(); > > That makes me relatively unworried. I did consider some alternatives: Btw, I've performed few experiments with parallel vacuuming of 10^4 small tables that are taking some small inserts, the results look like this: # with patch # funclatency -u bin/postgres:vac_update_datfrozenxid usecs : count distribution 0 -> 1 : 0 | | 2 -> 3 : 0 | | 4 -> 7 : 0 | | 8 -> 15 : 0 | | 16 -> 31 : 0 | | 32 -> 63 : 0 | | 64 -> 127 : 0 | | 128 -> 255 : 0 | | 256 -> 511 : 0 | | 512 -> 1023 : 3 |*** | 1024 -> 2047 : 38 |****************************************| 2048 -> 4095 : 15 |*************** | 4096 -> 8191 : 15 |*************** | 8192 -> 16383 : 2 |** | # without patch # funclatency -u bin/postgres:vac_update_datfrozenxid usecs : count distribution 0 -> 1 : 0 | | 2 -> 3 : 0 | | 4 -> 7 : 0 | | 8 -> 15 : 0 | | 16 -> 31 : 0 | | 32 -> 63 : 0 | | 64 -> 127 : 0 | | 128 -> 255 : 0 | | 256 -> 511 : 0 | | 512 -> 1023 : 5 |**** | 1024 -> 2047 : 49 |****************************************| 2048 -> 4095 : 11 |******** | 4096 -> 8191 : 5 |**** | 8192 -> 16383 : 1 | | In general it seems that latency tends to be a bit higher, but I don't think it's significant.