Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T2KOh-0003Rq-To for pgsql-bugs@postgresql.org; Fri, 17 Aug 2012 11:07:23 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T2KOd-0002M3-KH for pgsql-bugs@postgresql.org; Fri, 17 Aug 2012 11:07:23 +0000 Received: from awork2.localnet (p5DDC4F47.dip.t-dialin.net [93.220.79.71]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MJWCh-1SzrYb0F7T-00327W; Fri, 17 Aug 2012 13:07:18 +0200 From: Andres Freund Organization: 2ndquadrant.com To: Valentine Gogichashvili Subject: Re: BUG #7494: WAL replay speed depends heavily on the shared_buffers size Date: Fri, 17 Aug 2012 13:07:16 +0200 User-Agent: KMail/1.13.7 (Linux/3.5.0-rc6-andres-00196-gfdb1335; KDE/4.8.4; x86_64; ; ) Cc: pgsql-bugs@postgresql.org References: <201208170931.43034.andres@2ndquadrant.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201208171307.16342.andres@2ndquadrant.com> X-Provags-ID: V02:K0:9e6h0pI2QrYP24JKqAT0QpUGADz+SIc5T2jfvA8UCC9 gwS+1pMg8D18ygM0qJOWsYGSZRJ3fMNqzH+J1bLQsDKqmPL/9U poVWieAX6VMoeaKsUqmbsxQG1GMRMWLWJ8sZoxuNNk3qeVZtt4 f+7fTZzeU39q7tItVzzX6SagEwsLQR0o8q9az8UjUNpJl+MC8h q6IKOEeQWjjjA5z6tIHZayJ0TudDzH+l8mu2G/F30UnSbFFDj4 RvWIvKA0k692NNeeO8x+ib5FqdMRdD+lxcyTNFSW3HdygnXq5N 3Zaz1r5a6dtRhri5LYn4cziA1pEW3hPbkKjA91kDXROMNO2eXH nahLpnSdkYD/TBhEr0rKICNC63dQaIv2Mloa63Buj X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/138 X-Sequence-Number: 33862 On Friday, August 17, 2012 12:51:44 PM Valentine Gogichashvili wrote: > Hello Andreas, > > here are the results of perf profiling: > https://gist.github.com/3b8cb0c15661da439632 > Also attached the files to that mail. > > For a problematic case of big shared_buffers: > > # Events: 320K cycles > # > # Overhead Command Shared Object Symbol > # ........ ........ ................. .................................. > # > 98.70% postgres postgres [.] DropRelFileNodeBuffers > 0.18% postgres postgres [.] RecordIsValid > 0.11% postgres [kernel.kallsyms] [k] native_write_msr_safe > 0.07% postgres [kernel.kallsyms] [k] dyntick_save_progress_counter > 0.06% postgres [kernel.kallsyms] [k] scheduler_tick > 0.03% postgres [kernel.kallsyms] [k] _spin_lock > 0.03% postgres [kernel.kallsyms] [k] __do_softirq > 0.03% postgres [kernel.kallsyms] [k] rcu_process_callbacks > 0.03% postgres postgres [.] hash_search_with_hash_value > 0.03% postgres [kernel.kallsyms] [k] native_read_msr_safe > 0.02% postgres libc-2.12.so [.] memcpy > 0.02% postgres [kernel.kallsyms] [k] rcu_process_gp_end > 0.02% postgres [kernel.kallsyms] [k] apic_timer_interrupt > 0.02% postgres [kernel.kallsyms] [k] run_timer_softirq > 0.02% postgres [kernel.kallsyms] [k] system_call Ok, that explains it. Youre frequently dropping/truncating tables? That currently requires walking through shared buffers and loosing all buffered pages related to that table. That obviously scales linearly with shared buffers and is particularly expensive on multi socket machines. Unless youre running 9.3 that will even lock each single page which is a relatively expensive and slow operation. Depending on how adventurous you are you could try backporting e8d029a30b5a5fb74b848a8697b1dfa3f66d9697 and see how big the benefits are for you. Greetings, Andres