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.94.2) (envelope-from ) id 1qZVVR-005efO-3H for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Aug 2023 12:01:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qZVVP-002fxf-TT for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Aug 2023 12:01:35 +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.94.2) (envelope-from ) id 1qZVVP-002fxO-I7 for pgsql-hackers@lists.postgresql.org; Fri, 25 Aug 2023 12:01:35 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qZVVI-000t2D-4h; Fri, 25 Aug 2023 12:01:34 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-52683da3f5cso1246919a12.3; Fri, 25 Aug 2023 05:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692964887; x=1693569687; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6RyoBQxmHz9cqprPaEFWpaltYM1JiMW3oLlb0MIR5OE=; b=nuWzKr8msh7TXd69EtT7QXCFUoDicwywboAE1uO7+NkSRk8fnLbgAyBskbXmijvKpp XrlNJARBUUtMAIQKsHxNTdwMEkvIARUS7H8Y3S5vdvrK0Ucm4xSs4pYL4I7ZZKRDZVCF pIey9tlC5XYgB06xIH+CEjpLrbfdNSu1o/Isc/9YBoP8kIdU9H1wR92WpVXVOfwLgeKz evMnhQHns+6KgknYPlYkrqwejlvK+fy8qcbdjImLOW1isa58pmEwvjTDW3X+FNUL1qUP ZA25AY7CMBmY0T7weHgF1+dhzM+AVqFJqQRHUAxnUvyFjp6kuqJWy2RL6aX1eDEE2Fkn f9fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692964887; x=1693569687; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6RyoBQxmHz9cqprPaEFWpaltYM1JiMW3oLlb0MIR5OE=; b=WaRgM3eYFN0bOBfjjfNV3sOb3cvU8081KJWv2FOeJNjGRnVPZzE8YMQto+8/KYEUTD wEfFGgdPE2Vd2KWWir0W6F2bBjTya3PLjK9YobnrE4CxAXRCRuq9FBWlWHFlgstzU3M5 l0Uw1JK+yA1NCyCnp5K8mm2oAnEwUcybuQIL0S535wqXeJpzcM4XC3TwCBhPyYJyv5TT tjVRvuJObhxakZcA1LvGu8Fj9gwb68n085A9ldQr6or/y/OiwHrTN18gy3xg1UoO3n+F LLxN61MjfluSJKJnxcixlJ9GhvQYNp5xd1IwMjzzzSraEJPKxVXNArh2+wao/mXidVp2 zTww== X-Gm-Message-State: AOJu0Yzv/02sJBPYLSiC+wtXhmOhm12OtY+TxiNXZH43udXV0xnjDhE0 Qo7S0wSrSJS87+e7aaoLdkg= X-Google-Smtp-Source: AGHT+IG6JGZYgL5jKYz8OLrexzjR5HxKh5bPcByIeB8hYWVTq1JxqORCemOW8UhrGq5c5HOlTiSz/w== X-Received: by 2002:a17:906:209c:b0:9a1:beb2:1cb8 with SMTP id 28-20020a170906209c00b009a1beb21cb8mr7439587ejq.39.1692964886345; Fri, 25 Aug 2023 05:01:26 -0700 (PDT) Received: from [172.16.105.128] ([147.161.228.251]) by smtp.gmail.com with ESMTPSA id pg23-20020a170907205700b0098e34446464sm899645ejb.25.2023.08.25.05.01.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Aug 2023 05:01:25 -0700 (PDT) Message-ID: Date: Fri, 25 Aug 2023 14:01:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: Let's make PostgreSQL multi-threaded To: Merlin Moncure Cc: Andres Freund , "Jonathan S. Katz" , Heikki Linnakangas , Tom Lane , pgsql-hackers References: <31cc6df9-53fe-3cd9-af5b-ac0d801163f4@iki.fi> <4178104.1685978307@sss.pgh.pa.us> <4ce6c0f8-e8a4-1672-93fd-49d3fa975ee5@iki.fi> <20230607213721.al3etgcgtija3ytz@awork3.anarazel.de> <2ce25d83-39ea-569d-b73f-d4e9a3eb9cc1@gmail.com> Content-Language: en-US From: David Geier In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 8/11/23 14:05, Merlin Moncure wrote: > On Thu, Jul 27, 2023 at 8:28 AM David Geier wrote: > > Hi, > > On 6/7/23 23:37, Andres Freund wrote: > > I think we're starting to hit quite a few limits related to the > process model, > > particularly on bigger machines. The overhead of cross-process > context > > switches is inherently higher than switching between threads in > the same > > process - and my suspicion is that that overhead will continue to > > increase. Once you have a significant number of connections we > end up spending > > a *lot* of time in TLB misses, and that's inherent to the > process model, > > because you can't share the TLB across processes. > > Another problem I haven't seen mentioned yet is the excessive kernel > memory usage because every process has its own set of page table > entries > (PTEs). Without huge pages the amount of wasted memory can be huge if > shared buffers are big. > > > Hm, noted this upthread, but asking again, does this > help/benefit interactions with the operating system make oom kill > situations less likely?   These things are the bane of my existence, > and I'm having a hard time finding a solution that prevents them other > than running pgbouncer and lowering max_connections, which adds > complexity.  I suspect I'm not the only one dealing with this.  >  What's really scary about these situations is they come without > warning.  Here's a pretty typical example per sar -r. > > The conjecture here is that lots of idle connections make the server > appear to have less memory available than it looks, and sudden > transient demands can cause it to destabilize. It does in the sense that your server will have more memory available in case you have many long living connections around. Every connection has less kernel memory overhead if you will. Of course even then a runaway query will be able to invoke the OOM killer. The unfortunate thing with the OOM killer is that, in my experience, it often kills the checkpointer. That's because the checkpointer will touch all of shared buffers over time which makes it likely to get selected by the OOM killer. Have you tried disabling memory overcommit? -- David Geier (ServiceNow)