Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsds9-00066B-Df for pgsql-performance@arkaria.postgresql.org; Tue, 08 Jan 2013 18:26:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tsds8-0007Yl-TX for pgsql-performance@arkaria.postgresql.org; Tue, 08 Jan 2013 18:26:00 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsds6-0007X4-V7 for pgsql-performance@postgresql.org; Tue, 08 Jan 2013 18:25:59 +0000 Received: from nm28-vm0.access.bullet.mail.mud.yahoo.com ([66.94.236.229]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsds2-0003p4-Ki for pgsql-performance@postgresql.org; Tue, 08 Jan 2013 18:25:58 +0000 Received: from [66.94.237.127] by nm28.access.bullet.mail.mud.yahoo.com with NNFMP; 08 Jan 2013 18:25:53 -0000 Received: from [98.139.244.50] by tm2.access.bullet.mail.mud.yahoo.com with NNFMP; 08 Jan 2013 18:25:53 -0000 Received: from [127.0.0.1] by smtp112.sbc.mail.bf1.yahoo.com with NNFMP; 08 Jan 2013 18:25:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s1024; t=1357669553; bh=ONtIOFfba9jL/26FWuERrM2omOOdovyEa5ySaP/FXWc=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:From:To:References:Subject:Date:MIME-Version:Content-Type:X-Priority:X-MSMail-Priority:X-Mailer:X-MimeOLE; b=d6e4SjDgXNZ3udyvNLc2QoTwaXimDd584ckdpZjizOy1HvtF1BCu9funifuPIbA3rK12t+bX/IZ1l8CXS0KJiAmN5M/kH6u8XjSa+rBGH6Qs0Nd7MKIBnNYVrRSnfC7+k8qczIAn7N2eWlzm2khhBBC7EOfaTJwvO6aPPJR+5Kk= X-Yahoo-Newman-Id: 528477.77611.bm@smtp112.sbc.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: qvxOozgVM1mAL4Q5WvcKFQ81DP.S7op6CIFr0apf6q.ku4p kzzTdCN29cC6EiIJjeesma5wWPBDio1j4q5XMuN9DNHGOpfS3MD33fxDLaPN _uP9eWwKSOVIIZhUidAY6uroX2a9KnHNC60KXoW5daeH7d_kjnLxEws_Lvcl 823EhdRv7KS1TDYtTbzaldZvLsaNP0JmdwGhv7Vx4M.fxyHYFGgvpqCPcSJ9 nmLg1g5ETieXBdNpVhmKYrLaSTmgXVIcT1bBFJ5VI53vthrSEsBxh0n8hw0h MpzOxJvJJfa_zj9HcUS.hBEUQuMEJM.BsDRGSwMSuteqvgYk.qrZ_.aRc3Dh U2t1JBZ3s_eusUU3VBHX69xSboWjO7IK1Q2YpE9vtID6ZlqmPUo2KfEJVelW zb2wkYl6z8KqnsAa_pBQcoljIaL_dxux6qbT.YD4nNNbUlKPW0y3upyrYpDh DVEVYay3NdJoYvSvK9Cb6PVgnWSZiVMYKEtFqln7ER4DpN3XpFUNxZj0Kefd nhkevVYBN9nZaENghjXHci_vwN7z5CIwp41grH7rmwkb4o.uczx4Gdr4- X-Yahoo-SMTP: EtaTb4uswBBSx2FARGS8Y34d19mAO_hWIqN6lfRu55otbg-- Received: from BERNICE (midgems@71.135.36.210 with login) by smtp112.sbc.mail.bf1.yahoo.com with SMTP; 08 Jan 2013 10:25:53 -0800 PST Message-ID: From: "Midge Brown" To: , References: <50E4AAB1.9040902@optionshouse.com> Subject: Re: Two Necessary Kernel Tweaks for Linux Systems Date: Tue, 8 Jan 2013 10:25:52 -0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_005E_01CDED8A.89169240" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Pg-Spam-Score: -1.9 (-) 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. ------=_NextPart_000_005E_01CDED8A.89169240 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The kernel on our Linux system doesn't appear to have these two settings = according to the list provided by sysctl -a. Please pardon my ignorance, = but should I add them?=20 We have Postgresql 9.0 on Linux 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 = EDT 2009 x86_64 x86_64 x86_64 GNU/Linux Thanks, Midge ----- Original Message -----=20 From: Shaun Thomas=20 To: pgsql-performance@postgresql.org=20 Sent: Wednesday, January 02, 2013 1:46 PM Subject: [PERFORM] Two Necessary Kernel Tweaks for Linux Systems Hey everyone! After much testing and hair-pulling, we've confirmed two kernel = settings=20 that should always be modified in production Linux systems. Especially = new ones with the completely fair scheduler (CFS) as opposed to the = O(1)=20 scheduler. If you want to follow along, these are: /proc/sys/kernel/sched_migration_cost /proc/sys/kernel/sched_autogroup_enabled Which correspond to sysctl settings: kernel.sched_migration_cost kernel.sched_autogroup_enabled What do these settings do? -------------------------- * sched_migration_cost The migration cost is the total time the scheduler will consider a=20 migrated process "cache hot" and thus less likely to be re-migrated. = By=20 default, this is 0.5ms (500000 ns), and as the size of the process = table=20 increases, eventually causes the scheduler to break down. On our=20 systems, after a smooth degradation with increasing connection count,=20 system CPU spiked from 20 to 70% sustained and TPS was cut by 5-10x = once=20 we crossed some invisible connection count threshold. For us, that was = a=20 pgbench with 900 or more clients. The migration cost should be increased, almost universally on server=20 systems with many processes. This means systems like PostgreSQL or=20 Apache would benefit from having higher migration costs. We've had = good=20 luck with a setting of 5ms (5000000 ns) instead. When the breakdown occurs, system CPU (as obtained from sar) increases = from 20% on a heavy pgbench (scale 3500 on a 72GB system) to over 70%, = and %nice/%user is cut by half or more. A higher migration cost=20 essentially eliminates this artificial throttle. * sched_autogroup_enabled This is a relatively new patch which Linus lauded back in late 2010. = It=20 basically groups tasks by TTY so perceived responsiveness is improved. = But on server systems, large daemons like PostgreSQL are going to be=20 launched from the same pseudo-TTY, and be effectively choked out of = CPU=20 cycles in favor of less important tasks. The default setting is 1 (enabled) on some platforms. By setting this = to=20 0 (disabled), we saw an outright 30% performance boost on the same=20 pgbench test. A fully cached scale 3500 database on a 72GB system went = from 67k TPS to 82k TPS with 900 client connections. Total Benefit ------------- At higher connections counts, such as systems that can't use pooling = or=20 make extensive use of prepared queries, these can massively affect=20 performance. At 900 connections, our test systems were at 17k TPS=20 unaltered, but 85k TPS after these two modifications. Even with this=20 performance boost, we still had 40% CPU free instead of 0%. In effect, = the logarithmic performance of the new scheduler is returned to normal = under large process tables. Some systems will have a higher "cracking" point than others. The = effect=20 is amplified when a system is under high memory pressure, hence a lot = of=20 expensive queries on a high number of concurrent connections is the=20 easiest way to replicate these results. Admins migrating from older systems (RHEL 5.x) may find this = especially=20 shocking, because the old O(1) scheduler was too "stupid" to have = these=20 advanced features, hence it was impossible to cause this kind of = behavior. There's probably still a little room for improvement here, since = 30-40%=20 CPU is still unclaimed in our larger tests. I'd like to see the total=20 performance drop (175k ideal TPS at 24-connections) decreased. But = these=20 kernel tweaks are rarely discussed anywhere, it seems. There doesn't=20 seem to be any consensus on how these (and other) scheduler settings=20 should be modified under different usage scenarios. I just figured I'd share, since we found this info so beneficial. --=20 Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604 312-444-8534 sthomas@optionshouse.com ______________________________________________ See http://www.peak6.com/email_disclaimer/ for terms and conditions = related to this email --=20 Sent via pgsql-performance mailing list = (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance ------=_NextPart_000_005E_01CDED8A.89169240 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
The kernel on our Linux system = doesn't appear to=20 have these two settings according to the list provided by sysctl -a. = Please=20 pardon my ignorance, but should I add them?
 
We have Postgresql 9.0 on Linux = 2.6.18-164.el5 #1=20 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 = GNU/Linux
 
Thanks,
Midge
 
----- Original Message -----
From:=20 Shaun=20 Thomas
To: pgsql-performance@postgr= esql.org=20
Sent: Wednesday, January 02, = 2013 1:46=20 PM
Subject: [PERFORM] Two = Necessary Kernel=20 Tweaks for Linux Systems

Hey everyone!

After much testing and = hair-pulling, we've=20 confirmed two kernel settings
that should always be modified in = production=20 Linux systems. Especially
new ones with the completely fair = scheduler=20 (CFS) as opposed to the O(1)
scheduler.

If you want to = follow=20 along, these=20 = are:

/proc/sys/kernel/sched_migration_cost
/proc/sys/kernel/sch= ed_autogroup_enabled

Which=20 correspond to sysctl=20 = settings:

kernel.sched_migration_cost
kernel.sched_autogroup_en= abled

What=20 do these settings do?
--------------------------

*=20 sched_migration_cost

The migration cost is the total time the = scheduler=20 will consider a
migrated process "cache hot" and thus less likely = to be=20 re-migrated. By
default, this is 0.5ms (500000 ns), and as the = size of the=20 process table
increases, eventually causes the scheduler to break = down. On=20 our
systems, after a smooth degradation with increasing connection = count,=20
system CPU spiked from 20 to 70% sustained and TPS was cut by = 5-10x once=20
we crossed some invisible connection count threshold. For us, that = was a=20
pgbench with 900 or more clients.

The migration cost should = be=20 increased, almost universally on server
systems with many = processes. This=20 means systems like PostgreSQL or
Apache would benefit from having = higher=20 migration costs. We've had good
luck with a setting of 5ms = (5000000 ns)=20 instead.

When the breakdown occurs, system CPU (as obtained = from sar)=20 increases
from 20% on a heavy pgbench (scale 3500 on a 72GB = system) to=20 over 70%,
and %nice/%user is cut by half or more. A higher = migration cost=20
essentially eliminates this artificial throttle.

*=20 sched_autogroup_enabled

This is a relatively new patch which = Linus=20 lauded back in late 2010. It
basically groups tasks by TTY so = perceived=20 responsiveness is improved.
But on server systems, large daemons = like=20 PostgreSQL are going to be
launched from the same pseudo-TTY, and = be=20 effectively choked out of CPU
cycles in favor of less important=20 tasks.

The default setting is 1 (enabled) on some platforms. By = setting=20 this to
0 (disabled), we saw an outright 30% performance boost on = the same=20
pgbench test. A fully cached scale 3500 database on a 72GB system = went=20
from 67k TPS to 82k TPS with 900 client connections.

Total=20 Benefit
-------------

At higher connections counts, such as = systems=20 that can't use pooling or
make extensive use of prepared queries, = these=20 can massively affect
performance. At 900 connections, our test = systems=20 were at 17k TPS
unaltered, but 85k TPS after these two = modifications. Even=20 with this
performance boost, we still had 40% CPU free instead of = 0%. In=20 effect,
the logarithmic performance of the new scheduler is = returned to=20 normal
under large process tables.

Some systems will have a = higher=20 "cracking" point than others. The effect
is amplified when a = system is=20 under high memory pressure, hence a lot of
expensive queries on a = high=20 number of concurrent connections is the
easiest way to replicate = these=20 results.

Admins migrating from older systems (RHEL 5.x) may = find this=20 especially
shocking, because the old O(1) scheduler was too = "stupid" to=20 have these
advanced features, hence it was impossible to cause = this kind=20 of behavior.

There's probably still a little room for = improvement here,=20 since 30-40%
CPU is still unclaimed in our larger tests. I'd like = to see=20 the total
performance drop (175k ideal TPS at 24-connections) = decreased.=20 But these
kernel tweaks are rarely discussed anywhere, it seems. = There=20 doesn't
seem to be any consensus on how these (and other) = scheduler=20 settings
should be modified under different usage = scenarios.

I just=20 figured I'd share, since we found this info so beneficial.

-- =
Shaun=20 Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago = IL,=20 60604
312-444-8534
sthomas@optionshouse.com
=
______________________________________________

See=20 http://www.peak6.com/emai= l_disclaimer/=20 for terms and conditions related to this email


--
Sent = via=20 pgsql-performance mailing list (pgsql-performance@postgr= esql.org)
To=20 make changes to your subscription:
http://www.= postgresql.org/mailpref/pgsql-performance ------=_NextPart_000_005E_01CDED8A.89169240--