Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TseuJ-0007Ib-Lt for pgsql-performance@arkaria.postgresql.org; Tue, 08 Jan 2013 19:32:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TseuJ-0001jw-2f for pgsql-performance@arkaria.postgresql.org; Tue, 08 Jan 2013 19:32:19 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TseuH-0001it-Kq for pgsql-performance@postgresql.org; Tue, 08 Jan 2013 19:32:17 +0000 Received: from smtp.optionshouse.com ([38.98.137.6] helo=smtp.peak6.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TseuF-0004y6-Vz for pgsql-performance@postgresql.org; Tue, 08 Jan 2013 19:32:16 +0000 X-AuditID: 0a64cb20-b7f466d0000073cd-e8-50ec743e4b1b Message-ID: <50EC743E.1040209@optionshouse.com> Date: Tue, 8 Jan 2013 13:32:14 -0600 From: Shaun Thomas Reply-To: Organization: Peak6 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Scott Marlowe CC: Midge Brown , Subject: Re: Two Necessary Kernel Tweaks for Linux Systems References: <50E4AAB1.9040902@optionshouse.com> <50EC6549.3090503@optionshouse.com> <50EC6742.4090303@optionshouse.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.201.64] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsXClcIroWtX8ibAYOFaa4tlv6wsrs88x2yx 7NN5Rgdmj52z7rJ7XNg3jd1j/f/FrAHMUQ2MNol5efkliSWpCimpxcm2Sv4FJZn5ecUe+aXF qQoumcXJOYmZualFSgqZKbZKxkoKBTmJyam5qXkltkqJBQWpeSlKdlwKGMAGqCwzTyE1Lzk/ JTMv3VbJM9hf18LC1FLXUMkuHhkkdLJk/Dq6kLFgnWTF529XmRsYF4p0MXJwSAiYSFw+YdbF yAlkiklcuLeeDcTmFdCXeHHhBBOIzSKgIvH+7xewOJuArsSk/hVgthBQvO/sDbAafgFhiX0f mphBbFGBAInFS86xQ8wRlDg58wkLiC0ioC3x6M11RhCbWcBbYtaEA2C9wgIuEteaVgHN5AKa uYZJYsqLDWBFnAKBEi1T+9kgGmwlLsy5zgJhy0tsfzuHGeIIVYkVzRPZIB5QkPh/5R3TBEah WUh2z0LSPgtJ+wJG5lWM4sVlickZmaYFxbklBUZ6BamJ2WZ6eaklmxjBsXxaYQfj906rQ4wC HIxKPLwNia8DhFgTy4orcw8xSnAwK4nw3vV+EyDEm5JYWZValB9fVJqTWnyI0QcYaBOZpUST 84FpJq8k3tDY1MDU0tTQ1NzU0AiHsJI4b2joogAhgXRgKslOTS1ILYIZx8TBKdXAKNh2ofLR 9pRPsoFH/rl3mQbxNf92XSf+juE0z+m8t17ZPHMt5lsnz9b4bbo3TrrtUZ5y8oHpsS+XHcjh WGi0U4Jx3o9qvsDezTvEUk4dKfz97HaibKVLfez89zZWN7U+M+267nPC6MPZYydepy+67xrd 5140q3zvvalT59yoYWOV/W378VYZvxJLcUaioRZzUXEiAA3a9mkSAwAA 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 On 01/08/2013 01:04 PM, Scott Marlowe wrote: > Assembly language on the brain. of course I meant NOOP. Ok, in that case, these are completely separate things. For IO scheduling, there's the Completely Fair Queue (CFQ), NOOP, Deadline, and so on. For process scheduling, at least recently, there's Completely Fair Scheduler or nothing. So far as I can tell, there is no alternative process scheduler. Just as I can't find an alternative memory manager that I can tell to stop flushing my freaking active file cache due to phantom memory pressure. ;) The tweaks I was discussing in this thread effectively do two things: 1. Stop process grouping by TTY. On servers, this really is a net performance loss. Especially on heavily forked apps like PG. System % is about 5% lower since the scheduler is doing less work, but at the cost of less spreading across available CPUs. Our systems see a 30% performance hit with grouping enabled, others may see more or less. 2. Less aggressive process scheduling. The O(log N) scheduler heuristics collapse at high process counts for some reason, causing the scheduler to spend more and more time planning CPU assignments until it spirals completely out of control. I've seen this behavior on 3.0 kernels straight to 3.5, so it looks like an inherent weakness of CFS. By increasing migration cost, we make the scheduler do less work less often, so that weird 70+% system CPU spike vanishes. My guess is the increased migration cost basically offsets the point at which the scheduler would freak out. I've tested up to 2000 connections, and it responds fine, whereas before we were seeing flaky results as early as 700 connections. My guess as to why this is? I think it's due to VSZ as perceived by the scheduler. To swap processes, it also has to preload L2 and L3 cache for the assigned process. As the number of PG connections increase, all with their own VSZ/RSS allocations, the scheduler has more thinking to do. At a point when the sum of VSZ/RSS eclipses the amount of available RAM, the scheduler loses nearly all decision-making ability and craps its pants. This would also explain why I'm seeing something similar with memory. At high connection counts, even though %used is fine, and we have over 40GB free for caching. VSZ/RSS are both way bigger than available cache, so memory pressure causes kswapd to continuously purge the active cache pool into inactive, and inactive into free, all while the device attempts to fill the active pool. It's an IO feedback loop, and around the same number of connections that used to make the process scheduler die. Too much of a coincidence, in my opinion. But unlike the process scheduler, there are no good knobs to turn that will fix the memory manager's behavior. At least, not in 3.0, 3.2, or 3.4 kernels. But I freely admit I'm just speculating based on observed behavior. I know neither jack, nor squat about internal kernel mechanics. Anyone who actually *isn't* talking out of his ass is free to interject. :) -- 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance