Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zlvya-0005wK-MS for pgsql-performance@arkaria.postgresql.org; Tue, 13 Oct 2015 09:34:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZlvyZ-0007yl-O2 for pgsql-performance@arkaria.postgresql.org; Tue, 13 Oct 2015 09:34:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zlvwv-00069b-3Q for pgsql-performance@postgresql.org; Tue, 13 Oct 2015 09:32:49 +0000 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Zlvwr-0008RW-BS for pgsql-performance@postgresql.org; Tue, 13 Oct 2015 09:32:47 +0000 Received: by pabrc13 with SMTP id rc13so16577007pab.0 for ; Tue, 13 Oct 2015 02:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=q9KxTl6kNSkN0K9OyLSe0P/5JI297YqlAxkUfEV9aAg=; b=Vep40VaOj5HGzj5SoBk09UfLHfheVIvACnXeRd+8VM2Ed6kvc7TeqLeOieYoUMKmjx ukbSiUe/JqQTmGOjJ8QsTTq8E9Wqy71ugZhoOn8fOU/Ee8kTv1U0TL4IOJMynB/Xmoa0 f5aeE4PU1qYlTHutiVxw97g43N/N9UwMaIjvQIudL3+rIvTjmDGny2ZrI8G0HRgi/48J tyRo7WSKlGem12wTfHGyTEQaFcQIBnxrTR4ugk9TGN36bA0CvYBZ6dECNEMlhTCZiRw6 wStrhrt1rdfvb5YWj9uQOmLR059kiiZHYvVQE0cLiXzPBAS5s3ojfsfPv6T15G1krHCK khSQ== X-Received: by 10.68.178.131 with SMTP id cy3mr39097677pbc.52.1444728763966; Tue, 13 Oct 2015 02:32:43 -0700 (PDT) Received: from [10.64.248.10] ([216.253.193.158]) by smtp.gmail.com with ESMTPSA id w9sm2736623pbt.29.2015.10.13.02.32.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Oct 2015 02:32:43 -0700 (PDT) Message-ID: <561CCFB6.6040405@iki.fi> Date: Tue, 13 Oct 2015 12:32:38 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Shaun Thomas , Andres Freund CC: pgsql-performance@postgresql.org Subject: Re: Having some problems with concurrent COPY commands References: <20151012182808.GB10323@awork2.anarazel.de> In-Reply-To: Content-Type: multipart/mixed; boundary="------------050406030208090702050809" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org This is a multi-part message in MIME format. --------------050406030208090702050809 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 10/12/2015 11:14 PM, Shaun Thomas wrote: > On Mon, Oct 12, 2015 at 1:28 PM, Andres Freund wrote: > >> Any chance >> you could provide profiles of such a run? > > This is as simple as I could make it reliably. With one copy running, > the thread finishes in about 1 second. With 2, it's 1.5s each, and > with all 4, it's a little over 3s for each according to the logs. I > have log_min_duration_statement set to 1000, so it's pretty obvious. > The scary part is that it's not even scaling linearly; performance is > actually getting *worse* with each subsequent thread. > > Regarding performance, all of this fits in memory. The tables are only > 100k rows with the COPY statement. The machine itself is 8 CPUs with > 32GB of RAM, so it's not an issue of hardware. So far as I can tell, > it happens on every version I've tested on, from 9.2 to 9.4. I also > take back what I said about wal_level. Setting it to minimal does > nothing. Disabling archive_mode and setting max_wal_senders to 0 also > does nothing. With 4 concurrent processes, each takes 3 seconds, for a > total of 12 seconds to import 400k rows when it would take 4 seconds > to do sequentially. Sketchy. I was not able reproduce that behaviour on my laptop. I bumped the number of rows in your script 100000, to make it run a bit longer. Attached is the script I used. The total wallclock time the COPYs takes on 9.4 is about 8 seconds for a single COPY, and 12 seconds for 4 concurrent COPYs. So it's not scaling as well as you might hope, but it's certainly not worse-than-serial either, as you you're seeing. If you're seeing this on 9.2 and 9.4 alike, this can't be related to the XLogInsert scaling patch, although you might've found a case where that patch didn't help where it should've. I ran "perf" to profile the test case, and it looks like about 80% of the CPU time is spent in the b-tree comparison function. That doesn't leave much scope for XLogInsert scalability to matter one way or another. I have no explanation for what you're seeing though. A bad spinlock implementation perhaps? Anything special about the hardware at all? Can you profile it on your system? Which collation? - Heikki --------------050406030208090702050809 Content-Type: application/x-sh; name="launch4.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="launch4.sh" psql </dev/null & #psql -c "COPY test_copy2 FROM '/tmp/loadtest1.csv'" &>/dev/null & #psql -c "COPY test_copy3 FROM '/tmp/loadtest1.csv'" &>/dev/null & #psql -c "COPY test_copy4 FROM '/tmp/loadtest1.csv'" &>/dev/null & date wait date --------------050406030208090702050809 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance --------------050406030208090702050809--