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 1maF2U-0006H3-Of for pgsql-performance@arkaria.postgresql.org; Tue, 12 Oct 2021 10:29:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1maF2R-0006P4-SL for pgsql-performance@arkaria.postgresql.org; Tue, 12 Oct 2021 10:29:39 +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 1maF2R-0006Ow-FK for pgsql-performance@lists.postgresql.org; Tue, 12 Oct 2021 10:29:39 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1maF2P-0001VN-8G for pgsql-performance@lists.postgresql.org; Tue, 12 Oct 2021 10:29:38 +0000 Received: by mail-lf1-x133.google.com with SMTP id r19so83155312lfe.10 for ; Tue, 12 Oct 2021 03:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=phystech-edu.20210112.gappssmtp.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=k8ZqtT1MTWevEdEM6pt07HH7myFzt4YYcBY2FDx/6SI=; b=skybIpNSGywgynLkwQxbxUd7dV3DsqqC9uFRh1gRV8tZaRSQscCIP7HoqM2Z0Jjx4O ckeJ9MK+Q/i1u0GBQ3lBpAk6TgJjnvJViPZQSaGb3q9eWmFGKINshWWCDxrqQltTmtEU Gyn5s4oOC2t71azjAQD3B8RQu9zJodZOlPbwaWvnz8kJAfGr8DgVU3X+HEPagEHF8o1S L8tOuYeQcZ35mx28wd8GffRoaWCcvyuUenuVnMuuriyJO1yCYFC3RJQ84rAuQGiFpAvL ApxKmZYSy7eTvb+jg26kmaYkcw+nuXz4Cd1JtrMmrvv3uCT9FCavWGHxwahSCJ40pmq+ e/kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=k8ZqtT1MTWevEdEM6pt07HH7myFzt4YYcBY2FDx/6SI=; b=k1PVhr5AfHcfgUoSUfbRURo0J/LUEProjjogTuIIUuTnjXDMgQxGOnAuE2G5Ek1Kpi tUjP6QROVJLXVFDmOh5VH7DXHOGXKeOS5lP4cVkz+UWspuIiZZdGM4jahQWpc4QLMiYo E/IFyVU+liKlXLK8o3qcMIFJWkbEq9zkJcMXF5cVHqSnXTr1aQyP5PHnNzdVbPSffLoJ hiX22erJ0CNj7W/FAlM5ilLECz0T+fVmifElwPwSukC1NgkdyJBQlaNkcMiB16cBuzVF qDE4/jOTTlTBWb10FqO4Pl3ZxJGfVh3nPzPDEbvZMVyEbEszsgkLA3V7hrA1GLY5VbbM qutQ== X-Gm-Message-State: AOAM532sEVF8LH1y4aPqfAigD1JgaHFeiUBZfux1XmRrqpNscdldlq5r vypaWrN278URM6AiUmIKRFKVBqF6poT6/w== X-Google-Smtp-Source: ABdhPJyikbLO+k6kMDvAezxJWNrgSFxYFt6XUZya7zGmh5pipIZUXVmGzUacR3V8jSP0gszzU9gHgA== X-Received: by 2002:ac2:5210:: with SMTP id a16mr10688114lfl.279.1634034575933; Tue, 12 Oct 2021 03:29:35 -0700 (PDT) Received: from tamagawa.unclebear.ru ([212.46.18.49]) by smtp.gmail.com with ESMTPSA id x22sm988365lfd.198.2021.10.12.03.29.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Oct 2021 03:29:35 -0700 (PDT) Subject: Re: Lock contention high To: Ashkil Dighin , pgsql-performance@lists.postgresql.org References: From: Mikhail Zhilin Message-ID: <4da46846-5835-8da7-b3c0-29c7b08e8b09@phystech.edu> Date: Tue, 12 Oct 2021 13:29:33 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------F53D081C89D9626388981D6D" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------F53D081C89D9626388981D6D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, How many sockets are on motherboard? What is CPU model and interconnect type (UPI?)? Can you share output of "lscpu"? If you have more than 1 NUMA node it may be worth to run PostgreSQL in single NUMA node via taskset. It will eliminate access to remote memory and speed up processing. Thanks,  Michael. On 10/12/21 10:35 AM, Ashkil Dighin wrote: > > Hi, > Lock contention observed high in PostgreSQLv13.3 > The source code compiled with GNC(GCCv11.x) > PostgreSQL version: 13.3 > Operating system:   RHEL8.3 > Kernel name:4.18.0-305.10.2.el8_4.x86_64 > RAM Size:512GB > SSD: 1TB > The environment used IBM metal and test benchmark environment HammerDbv4.2 > Test case :TPC-C > > Perf data for 24vu(TPC-C) > -------------------------------- > >       18.99%  postgres  postgres            [.] LWLockAcquire >      7.09%  postgres  postgres            [.] _bt_compare >      8.66%  postgres  postgres            [.] LWLockRelease >      2.28%  postgres  postgres            [.] GetSnapshotData >      2.25%  postgres  postgres            [.] hash_search_with_hash_value >      2.11%  postgres  postgres            [.] XLogInsertRecord >      1.98%  postgres  postgres            [.] PinBuffer > > 1.Is there a way to tune the lock contention ? > 2.Is any recommendations to tune/reduce the lock contention via > postgres.conf > > Postgres.conf used  in Baremetal > ======================== > shared_buffers = 128GB(1/4 th RAM size) > effective_cachesize=392 GB(1/3 or 75% of RAM size) > huge_pages = on > temp_buffers = 4000MB > work_mem = 4000MB > maintenance_work_mem = 512MB > autovacuum_work_mem = -1 > max_stack_depth = 7MB > dynamic_shared_memory_type = posix > max_files_per_process = 4000 > effective_io_concurrency = 32 > wal_level = minimal > synchronous_commit = off > wal_buffers = 512MB > checkpoint_timeout = 1h > checkpoint_completion_target = 1 > checkpoint_warning = 0 > log_min_messages = error > log_min_error_statement = error > log_timezone = 'GB' > autovacuum = off > datestyle = 'iso, dmy' > timezone = 'GB' > lc_messages = 'en_GB.UTF-8' > lc_monetary = 'en_GB.UTF-8' > lc_numeric = 'en_GB.UTF-8' > lc_time = 'en_GB.UTF-8' > default_text_search_config = 'pg_catalog.english' > max_locks_per_transaction = 64 > max_pred_locks_per_transaction = 64 > > Best Regards > Anil > --------------F53D081C89D9626388981D6D Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hi,

How many sockets are on motherboard?
What is CPU model and interconnect type (UPI?)?
Can you share output of "lscpu"?

If you have more than 1 NUMA node it may be worth to run PostgreSQL in single NUMA node via taskset. It will eliminate access to remote memory and speed up processing.

Thanks,
 Michael.

On 10/12/21 10:35 AM, Ashkil Dighin wrote:

Hi,
Lock contention observed high in PostgreSQLv13.3
The source code compiled with GNC(GCCv11.x)
PostgreSQL version: 13.3
Operating system:   RHEL8.3
Kernel name:4.18.0-305.10.2.el8_4.x86_64
RAM Size:512GB
SSD: 1TB
The environment used IBM metal and test benchmark environment HammerDbv4.2
Test case :TPC-C

Perf data for 24vu(TPC-C)
--------------------------------

      18.99%  postgres  postgres            [.] LWLockAcquire
     7.09%  postgres  postgres            [.] _bt_compare
     8.66%  postgres  postgres            [.] LWLockRelease
     2.28%  postgres  postgres            [.] GetSnapshotData
     2.25%  postgres  postgres            [.] hash_search_with_hash_value
     2.11%  postgres  postgres            [.] XLogInsertRecord
     1.98%  postgres  postgres            [.] PinBuffer

1.Is there a way to tune the lock contention ?
2.Is any recommendations to tune/reduce the lock contention via postgres.conf

Postgres.conf used  in Baremetal
========================
shared_buffers = 128GB(1/4 th RAM size)
effective_cachesize=392 GB(1/3 or 75% of RAM size)                        
huge_pages = on               
temp_buffers = 4000MB                 
work_mem = 4000MB                     
maintenance_work_mem = 512MB           
autovacuum_work_mem = -1               
max_stack_depth = 7MB                 
dynamic_shared_memory_type = posix     
max_files_per_process = 4000           
effective_io_concurrency = 32         
wal_level = minimal                   
synchronous_commit = off               
wal_buffers = 512MB                            
checkpoint_timeout = 1h         
checkpoint_completion_target = 1       
checkpoint_warning = 0         
log_min_messages = error               
log_min_error_statement = error
log_timezone = 'GB'
autovacuum = off                       
datestyle = 'iso, dmy'
timezone = 'GB'
lc_messages = 'en_GB.UTF-8'           
lc_monetary = 'en_GB.UTF-8'           
lc_numeric = 'en_GB.UTF-8'             
lc_time = 'en_GB.UTF-8'               
default_text_search_config = 'pg_catalog.english'

max_locks_per_transaction = 64         
max_pred_locks_per_transaction = 64


Best Regards
Anil


--------------F53D081C89D9626388981D6D--