Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCqQb-0007Bq-8W for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jul 2015 14:34:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZCqQa-00056U-7T for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jul 2015 14:34:24 +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 1ZCqPk-0004Pv-OT for pgsql-bugs@postgresql.org; Wed, 08 Jul 2015 14:33:33 +0000 Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZCqPh-0007Nb-Gt for pgsql-bugs@postgresql.org; Wed, 08 Jul 2015 14:33:31 +0000 Received: by labgy5 with SMTP id gy5so74408631lab.2 for ; Wed, 08 Jul 2015 07:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZIGBDDXm5DqIfi7tXMEkDzzCE1E23HvhTFO2vAYd8b0=; b=WAWIJXIp1y176THOMub/HoeJ1t1XmT1xIvbGifqT0qVupqviSu9zsmaVEFK+pRVCuW Tna3OaPLBfJhcMqPQM30W/GkqdE395wk6AGJF0miZLPMiKRRKX50x/Y5S/MFfR/Oi//1 fpOk2eqaNbjyAL2ayuyjyeLZf21BbamGJ1ZJaj4JGiGcb2MQjvasJF/1uY4zb60ycDO+ Qd9F7LhA3+Mi8R3yhs7TY9YcMnbzzvUGuJbYAClHkszD5vOB6MGecx3bY/doFMOYwa/R o3hO3tRxwY5zED23kkzN2LzMHeGDVw4njaUMXdzbk2WJ2qGRtYMKEGx3hXNpUseJr63V 6Mkw== X-Received: by 10.152.205.67 with SMTP id le3mr9896595lac.50.1436366007841; Wed, 08 Jul 2015 07:33:27 -0700 (PDT) Received: from [192.168.0.101] (ti0056a400-6081.bb.online.no. [85.165.98.212]) by smtp.gmail.com with ESMTPSA id r6sm681641lbw.10.2015.07.08.07.33.26 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jul 2015 07:33:27 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: BUG #13493: pl/pgsql doesn't scale with cpus (PG9.3, 9.4) From: Graeme In-Reply-To: <20150708142241.GQ10242@alap3.anarazel.de> Date: Wed, 8 Jul 2015 16:33:25 +0200 Cc: Tom Lane , grb@skogoglandskap.no, pgsql-bugs@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <7BBCD8DA-3B9C-487B-9B5E-67A85E5C644D@gmail.com> References: <20150707222739.1188.8068@wrigleys.postgresql.org> <31265.1436317984@sss.pgh.pa.us> <20150708091238.GI10242@alap3.anarazel.de> <20150708125512.GL10242@alap3.anarazel.de> <20953.1436363811@sss.pgh.pa.us> <20150708142241.GQ10242@alap3.anarazel.de> To: Andres Freund X-Mailer: Apple Mail (2.2098) X-Pg-Spam-Score: -2.7 (--) 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 By the way, It may be worth increasing the length of the for loop in the pl/pgsql by a = factor of 100-1000x and seeing if you get the same kind of behaviour. I int= entionally left it very low (10000 iterations of nothing is not that much w= ork) to ensure people would see a non-zero number there for the TPS the fir= st time they ran the bench. However in practice the functions that have th= e worst behaviour tend to be longer running ones.=20 Graeme. > On 8 Jul 2015, at 16:22, Andres Freund wrote: >=20 > On 2015-07-08 09:56:51 -0400, Tom Lane wrote: >> Andres Freund writes: >>> So there's an interesting "dip" between 4 and 8 clients. A perf profile >>> doesn't show any actual lock contention on master. Not that surprising, >>> there shouldn't be any exclusive locks here. >>=20 >> What size of machine are you testing on? >=20 > 2xE5520 (=3D> 2 x 4 sockets, 8 threads); numa. >=20 > (note that I intentionally did not fix the volatility of the function) >=20 >> I ran Graeme's tests on a 2-socket, 4-core-per-socket, no-hyperthreading >> machine, which has separate NUMA zones for the 2 sockets. What I saw >> (after fixing the "stable" issue) was that all the 8-client and 16-client >> cases were about 8x faster than 1-client, and 2-client was generally >> within hailing distance of 2x faster, but 4-client was often noticeably >> worse than the expected 4x faster. >=20 >> I figured this was likely some weird NUMA effect, possibly compounded >> by brutally stupid scheduling on the part of my kernel. But I didn't >> have time to look closer. >>=20 >> You might be seeing the same kind of effect, or something different. >> It's hard to tell without knowing more about your machine. >=20 > I think it's likely to be some scheduler effect. The number of cpu > migrations between 4 and 8 is very different: >=20 > 4: >=20 > 64,599 context-switches # 0.003 M/sec = (100.00%) > 172 cpu-migrations # 0.007 K/sec = (100.00%) > 537 page-faults # 0.023 K/sec > 8: > 381,383 context-switches # 0.002 M/sec = (100.00%) > 1,279 cpu-migrations # 0.008 K/sec = (100.00%) > 3,869 page-faults # 0.024 K/sec > 16: >=20 > 514,426 context-switches # 0.003 M/sec = (100.00%) > 1,166 cpu-migrations # 0.007 K/sec = (100.00%) > 6,308 page-faults # 0.039 K/sec >=20 > There's a pretty large increase in the number of migrations between 4 > and 8, but none between 8 and 16. >=20 > My guess is that the kernel tries to move around processes to idle nodes > too aggressively. >=20 > second-by-second pgbench is quite interesting: > progress: 1.0 s, 22915.3 tps, lat 0.346 ms stddev 0.078 > progress: 2.0 s, 15596.8 tps, lat 0.512 ms stddev 0.185 > progress: 3.0 s, 15519.2 tps, lat 0.514 ms stddev 0.499 > progress: 4.0 s, 15535.7 tps, lat 0.512 ms stddev 0.306 > progress: 5.0 s, 15494.3 tps, lat 0.515 ms stddev 0.162 >=20 > so at -j8 we're routinely much faster than later. >=20 > Comparing perf stat pgbench -j8 -T 1 and -T 8: > -T 1 > 46 cpu-migrations > -T 8 > 534 cpu-migrations > so indeed the number of migration rises noticeably after the first > second... >=20 >=20 > --=20 > Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-bugs --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs