Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGrFJ-0000hg-9Z for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Sep 2020 22:10:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kGrFH-0004wI-N1 for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Sep 2020 22:10:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGrFH-0004w0-AC for pgsql-hackers@lists.postgresql.org; Fri, 11 Sep 2020 22:10:15 +0000 Received: from mail-qv1-xf42.google.com ([2607:f8b0:4864:20::f42]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kGrFB-0000kS-Vk for pgsql-hackers@postgresql.org; Fri, 11 Sep 2020 22:10:12 +0000 Received: by mail-qv1-xf42.google.com with SMTP id di5so5984379qvb.13 for ; Fri, 11 Sep 2020 15:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=IV0KFhTCI52o8/tKPiV3GJcuXyhicVMiKcfWm+2lOIA=; b=0pkzDvjexXd/ck5WVd+Rm+5oG3FkKQvt1+zCQHTKBQ9uAEoZyGia8EAk5jyiBwloXP SzgNe8tcwX5bNJlNSenS2wqgHHtFg1XmVqI/HYjRFsOEBF55m28haPCHIHMC/1TtqLE5 Ptv/z7/6E1yPrVZmvAZ/PABF65bMvdRER5ZeZYB78eFImhVCAPKJjN2oRosBoNgP5CuA joHX3zZk+O1Cipgcu+ww0YMHajENU9AHVmlNzveAMnayH50tDmvL13RgTffuoqB8WRK2 lXrnq1vffRqHtKPBZKdrnuJjB+K1k7Ycs0m6d3G8SEFAZvEn9efjKuG+Gui/ieQ45+ii 60og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=IV0KFhTCI52o8/tKPiV3GJcuXyhicVMiKcfWm+2lOIA=; b=a8z7RUq3T99C3zKAzFv768adBkomO5+gXV1/U+SpuQSMD6K89IpP8AP3CB0p7Wm8Kq fEQ7R/e6Ojpdt7JAPmh1xOxfswfbHS3LcH/PvlhgeKcJ5otutq6S6PE7eQUrutxoKCu+ GagaArD5Jdgq+pYhtuE4k3wOhkkrlUueb3NMRHyPGbbi7irBX06Vs9rkpTmXe8pw/359 HV6TG9H80ZW6WdBaD88YlR4Hmx2Jay6DtephUtrADatvgpcesX3pu666EHphLBIdK3xy Wf6u3S97llLOhX1hhWqZkt6/qzjMfdkWs6/BIdcPq1DJwdgzWT8axG+hW9+c2fH248Ic mrMw== X-Gm-Message-State: AOAM531imDteWNWahn5DqwKHwl3pve/dJh6Nsw5tyCPcQj6OAFIBiVeK WxKE/PCAnxpjIivoFV0QMlA6mw== X-Google-Smtp-Source: ABdhPJyfGqhlS8EnGKJPN7IP9s04DYfeYui6NibVEuMAbaImPcS5QETEgz03E2iHx3CCwmXsVTkKXQ== X-Received: by 2002:a0c:c492:: with SMTP id u18mr4001949qvi.18.1599862207287; Fri, 11 Sep 2020 15:10:07 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id e13sm4111809qtr.85.2020.09.11.15.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 15:10:06 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 391D92A1506; Fri, 11 Sep 2020 19:10:05 -0300 (-03) Date: Fri, 11 Sep 2020 19:10:05 -0300 From: Alvaro Herrera To: Fujii Masao Cc: bttanakahbk , Hamid Akhtar , Pavel Stehule , Peter Geoghegan , Julien Rouhaud , "Tharakan, Robins" , pgsql-hackers@postgresql.org Subject: Re: track_planning causing performance regression Message-ID: <20200911221005.GA6740@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-11, Fujii Masao wrote: > Ok, so my proposed patch degrated the performance in this case :( > This means that replacing spinlock with lwlock in pgss is not proper > approach for the lock contention issue on pgss... > > I proposed to split the spinlock for each pgss entry into two > to reduce the lock contention, upthread. One is for planner stats, > and the other is for executor stats. Is it worth working on > this approach as an alternative idea? Or does anyone have any better idea? It does seem that the excl-locked section in pgss_store is rather large. (I admit I don't understand why would a LWLock decrease performance.) Andres suggested in [1] to use atomics for the counters together with a single lwlock to be used in shared mode only. I didn't quite understand what the lwlock is *for*, but maybe you do. [1] https://postgr.es/m/20200629231015.qlej5b3qpfe4uijo@alap3.anarazel.de -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services