Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcj3g-003Ziz-1Q for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2026 12:19:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wcj3f-005aEb-1C for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2026 12:19:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wcj3e-005aET-37 for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2026 12:19:51 +0000 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wcj3c-00000000BQz-49m5 for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2026 12:19:50 +0000 Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-8dd74f90e3eso22855016d6.2 for ; Thu, 25 Jun 2026 05:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782389988; cv=none; d=google.com; s=arc-20260327; b=mZDChFJQgnSLlOJOEF1plsF6bgTpLf+xEve/tyBG9R9/DCmW40ldxY/PzuUivrc4r6 19XyEEBjihAVERNDc0lW6V+6j9eoIsVebeD1VdIYHTMFssgXpayoRTr3GYnDLcRQg9Km 9l91y2o1g6zqHSVVaoJu9mG+4iNyRwyAKDr4oNwuAvGKMc4pbDD4AhSzq+KY1yybAnEC qT9GLIjSPjmT3HmXDDBZWmKAnVO5lDLm2gLJtq42kIIPjEXm6Q4WcqTPsiQFmXNVcIdC GZYn6ApBMQbEv9fb1hlRghWrb4vjs0R4wt68wm0quEzaTyq1rNz+OYXC6RLfRvomYIKD O0NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PhRAtCvuP5czGSVMytacxWQbswSEEdCtQ8JQ72N8zf8=; fh=dXt15z/tZpFiegdOfutAr2lA02HhuIWGi7Fuz/APZhI=; b=EcdKXnD3aCiJdm1qZ2ApJRrA17XwiU+r1u46AlQAkudLw92Qqbg1VVz5IR74AJ7Xzz 7wyboFOyT1p8aq7cdM8kHozI72DE1+Xwt46sPfZaeexYsXmKDxMg5mYuTSMeMwFIkC2H 6KiJStWpJRk3cB6i1XFTUwBwO6frN6aMQUlY5u5w2bkqmpxaJeu2cFkGgI1EyNbC/7Mk O2y1CsFlWCXyBjAT6dJuGL2/k+hlpB7eEa/gHW2aww1mriZP2rYA1M2FHP7vEh/nSzqI Cl2HLRmnI3W1Q5ASWSz2edaWpVRRF1RyiEDKuKlXpAwBYP92/KvfmYl3eTfBUANqKHUw aJsQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1782389988; x=1782994788; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PhRAtCvuP5czGSVMytacxWQbswSEEdCtQ8JQ72N8zf8=; b=d/Q5QG7Vbo0VuOg1LOhRiA3JggIaDMFopARLOlbSrnNeAzYnNxSnwTO2b4KuA+tH8I XO0g9hzxTIH0ki672BJyLjHt/cTNAtugA4hZ9lAQsC+xpuNSaMqUvHYMDlU54HLy49Bs LOn6khOqDKi6gvjaIQux2RkbOtCDSDHXVoOVVuyw3k17PHUgdi+oKhS+hrxNC+tHqkRP KD6YLOGeQhXOPtsLK5fq6PL7QrfOe6kwrYL9dpyW0bK74GW/wvfqMtfc1tklJML9oUqf VC5x9BTEBrCebVpsyd/3wJmzQ1dv5yNsOUt3ow19oU+Rr+V9qnsgGm0FBTd6AgleOs46 i3uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782389988; x=1782994788; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PhRAtCvuP5czGSVMytacxWQbswSEEdCtQ8JQ72N8zf8=; b=oj//+cLvkhphXCOm2dg8ZJT7nQhTt/Wlu04cunNIMfw/3NAkhsx0pH8QfbHY7U8Z73 TZYmQXGmpjgkUfRh7sg/PDV/UDn92POtP4QgkXiir8rC9Pb2txW3uZc0WiR556y4QJzN lZcJdzpmecmAevssbpiFNi7HKFiUiy3gm33CvuxZKKupUxryGrL6d/7Zt8SNgc3EB4su /s7NYxwuvRO/+rI+wIA/P24/+XhCqaqbWX2+a6Bk1AZMNWd0vTrLCus+XLdR30XxoSK9 kspsttKCmN9sM853dOseKHu8ZEDssFlYYawLYSjZ3WyJJeyp755FP0aop9d5Ma0P3j8Y Txhg== X-Forwarded-Encrypted: i=1; AHgh+Rr0WqaOB2mcKTtveCf1bVPEGI8/o5nuaYAiB1wteAJppLZZlhXqZLFU5GcqwyxJYb1y+HKxlIpzqYDdwoam@lists.postgresql.org X-Gm-Message-State: AOJu0Yx3dH/lBRCyyUW1+5fRS5mnvnCGjLl4K66MHq+ZvpjnceZT1Roa JagntsY83j1ef1WksIdSSkNUDdqnhEanIp7yrKY4PTsxc4oeASqw/zXEjCAiW+uvHJ8WJdHWTkE HgUKVrASitujT8lEURkrkmd082cBjz7JDA2MGL3Hl X-Gm-Gg: AfdE7cns+ECnTZ0fqGZaFzhgLzBTtPl4sf13i8HVrvN0mnijDkROEEPIx/xktU2yw3B QTrza3bqvXy9Ba4Rar+HZ5sghRseRmxz010BnmOwnp61jRXSlqznVP1S9XZHjtG7ez4rQhV43wp zmM9dM3p/mEk7P8mWzcetrXp6GCNXtm2d1TXZi0+l2aLPt/AKjhOoyqbU9OPCU+4g6CUVq5mk7F DfHFj3dYTKNFLvRbqqqrlVH+VBubFg6105EWqFrqWSHMpNGoj+WF2Y4ZDIlcikCiR6405wAMrVU LFZHNTHDbhu0i4Um0bifNzVhRmo7q93UfIMgZnjt23/dHXkci1IS8xt0QA== X-Received: by 2002:a05:6214:2604:b0:8df:1814:3a19 with SMTP id 6a1803df08f44-8e6d50e7ee0mr43131216d6.29.1782389987892; Thu, 25 Jun 2026 05:19:47 -0700 (PDT) MIME-Version: 1.0 References: <5bc6d309-61fe-4d8b-9e1f-a2961564a559@vondra.me> <05df16f8-025a-43cd-9636-3194464012ed@vondra.me> <403c813e-7d63-4ee8-a95f-4e5c1e310f4d@vondra.me> <0e1b997d-99c8-40f4-bc32-6c044bc7ed9a@vondra.me> <2db78610-b480-4aa0-a1b6-57f1c2dcb708@vondra.me> <2e1be441-5608-4bc8-9ac4-6fad9a060db4@vondra.me> <334f7644-6716-4e63-a7c4-13c5cbcdd210@vondra.me> <86e7e218-9013-4cdb-9ed2-dfda49640b4d@vondra.me> In-Reply-To: From: Jakub Wartak Date: Thu, 25 Jun 2026 14:19:36 +0200 X-Gm-Features: AVVi8CesjVOwSPvMcndXks6xTOETduhQnVSorGhsqIvS3vQ0rdAOWolBpCzRtXk Message-ID: Subject: Re: Adding basic NUMA awareness To: Tomas Vondra Cc: Andres Freund , Alexey Makhmutov , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 24, 2026 at 10:29=E2=80=AFPM Tomas Vondra wro= te: Hi, > Here's an updated patch series, with only minor changes to fix the mbind > issues: [..] > I've also included Jakub's "goodies" patch with the additional GUCs. > Those seem potentially useful to development. Cool! > I have some results from a new round of benchmarks, and it's a bit > disappointing. Or rather, there seem to be some issues that I can't > figure out, causing regressions. [..] > This chart is for median latency (in milliseconds): > > clients master 0003 0004 0003/on 0004/on > ------------------------------------------------------------- > 1 12767 12582 14509 12807 15307 > 8 14383 14355 14149 14069 16165 > 32 14756 15198 14836 14984 17128 > -------------------------------------------------------- > 1 103% 114% 100% 120% > 8 101% 98% 98% 112% > 32 102% 101% 102% 116% > I haven't tried it yet, however I can spot some things: No crystal clear idea why, but in the script I can see that you have io_method =3D io_uring and are not dropping_caches, so IMHO it is too compl= ex interaction at this stage. One hint: such setup is going to be problematic for proving numbers. On the meeting I've tried to describe that I've been using io_method =3D sy= nc instead of 'worker' to get more predicitable results (together with echo 3 > drop_caches), because then it is that backend's CPU/$NODE doing that pread()/pwrite() -- or any other operating performing the load -- it is going to put that file onto that_specific_$NODE -- so even if you have sequence like: pgbench -i pg_ctl restart pgbench -c XX then pgbench -i even with shared_buffers_numa=3Don will spread into many nodes the Buffers, yet after the restart the VFS cache portion of the data will still reside on single specific $NODE that wrote it to the filesystem (due to local-first-tocuh-affinity even for VFS cache), so any further read= ing: VFS cache --pread()--> s_b will take the hit of remote interconnect with some probablity depending on where the new backends are running. Also with worker it is even worse as we have those memory queue in between. I think we even can have this: file in VFS cache @ node0 --because of first touch policy (pgbench -i/pre= warm) io worker @ node1 --hits latency from node0 and node2 shm io worker queue @ node2 --well client backend @ node 3 --puts into shm io worker on node2 Therefore I'm sticking to 'sync' to ease the pain... but with uring, I susp= ect the situation is kind of similiar as we call io_uring_submit(), and we may endup using io-wq kernel threads, and we have those submission/receive (memory) queues that are located somewhere (that is on some node) too. I think, we simply lack affinity for IO/NUMA for all io modes except sync, = but it's too early I suspect and way outside of scope for this $thread. I've started thinking about it just last week, so... (but hopefully I'll be able to ship helper fscachenuma.c to show layout of file across VFS caches on no= des next week I hope) Maybe some other suggestions: Q1) Maybe some crosschecks first? # balance should be equal between nodes even for baseline # linux kernel has tendency to fit shm into one if it fits find /sys/devices/system/node*/ -name 'free_hugepages' -exec grep -H . {} \; # check N0 and N1 even for default policy, might also reveal imbalan= ce # lots of RAM and too big huge_pages allows fitting whole shm into just N0 # see point 4 from [1] grep /anon_h /proc/$SOMEREALBACKENDPID/numa_maps # then during pgbench -c run maybe those: mpstat -N ALL 1 perf stat -a -e uncore_imc/cas_count_read/,uncore_imc/cas_count_writ= e/ \ --per-socket -I 1000 # or -M memory_bandwidth_read,memory_bandwidth_write (it might reveal that problem I've described above about io_method: even with pgbench -c 1 you might be reading from all sockets/wrong sock= ets instead of the correct one with affinity) I like to pin CPUs to just one node for pgbench -c [to saturate one node only] and start server also with CPU pining [or use this debug_numa_node to force] to that one node and cross-check what's being read (using perf) and usually I have to disarm clock balan= cing and override weights using pg_buffercache_set_partition() to also force weight to stay local only - only then I'm able to outrun master. That's how this idea was born that if we are only working on node $N with some relations then let's use only node $N's Buffers. But I have 90us:~280us local vs remote latency, so it's probably way easier for me to see results even without disabling CPU-idle-states/turboboost/etc. Q2) Dunno, but 0007 is not changing anything in runtime and you get huge discrepeancy results when going 0006 -> 0007 for clients=3D1 (see 128% -> 112%). Literally, as the same code but different rebuild (ELF image) would be having vastly different layout enough to cause perf issues? Hopefully next week I'll try to repro those numbers to see if I can help more. -J. [1] - https://www.postgresql.org/message-id/CAKZiRmzo9xnJSgO4b26DTZqPuObcQ-= 6ncay%2BmOEKs9rzCkegUA%40mail.gmail.com