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 1q6KXh-0001vm-63 for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jun 2023 00:27:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q6KXf-0006ee-KA for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jun 2023 00:27:19 +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 1q6KXf-0006eC-6D for pgsql-hackers@lists.postgresql.org; Tue, 06 Jun 2023 00:27:19 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q6KXb-000TVW-UE for pgsql-hackers@postgresql.org; Tue, 06 Jun 2023 00:27:18 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1b04706c85fso51498175ad.0 for ; Mon, 05 Jun 2023 17:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20221208.gappssmtp.com; s=20221208; t=1686011233; x=1688603233; 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=6p37X11dy1saqxvKSV1HJdM9ZPUmXhIPnlXRB2iPtrc=; b=Jr04W83VYt3Esy9vKdL5Sq93TUjz9RM+XeFsaZCvbKgs7qx3luY+AcbKRLXwvvTzrI Hx67LvzlSujH/j29uEnvoqtUGBqm/60ChBsq7wtx5COsaPsJSFndcuG95xrYXcXLr4/+ 4QFvzCIEmq7mkpzFQPo2s7kaEXUY35nOeb46o1ov17sd7+6qpsDQ2qI9z5aqqWMVDd9H iJZod9NKlGjpeuWcKJOKRZYcnIQWu+Vdk+oHOnySsXYXp0Grd00ojIZce+08VPiTpUeb 6d8JcsgeMcI0FIRQjcpICWuz7PAZ2GdM7987N+Ge361KctwQBdqVT0J76B55uT+fcl28 pEWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686011233; x=1688603233; 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=6p37X11dy1saqxvKSV1HJdM9ZPUmXhIPnlXRB2iPtrc=; b=X+2uEjns33/gK8Iln2ykrj4MJb5h4zY2ju0QDqPu1Rx0RvGg9Ltjtnxl9GPxsR7HVk ryHoWkudRScOP36wyvdn+CA1WrjmlWF0s1ol6UVMfD0mSgqI3Xbr2w2oXo0gWTu33SVI SGc2/JbqCBmGznYTxPTK9Tx5EACgBAB4/gm3beaXQ+H8bQKfWKbFAMs94Pbns09u5KXU pi33s/OKnTOR8t24uhRyq3CuO72Jr2X/LsN1s4fY7IFkC7DAKKp2o1MPFt5LP7IWmOoN Yf5+aBad88lqWlUUmAcR/d5Q2nX+0ZmQSq50DTCyvxGgfOOZC0z4kz6Lmx2TNWHKD6Tm gFmA== X-Gm-Message-State: AC+VfDwMKYMzuB/yS9wrxMJa3wdtmUG7ZedKUh4PD/rc5Fq2ffIPHfYk k1ngln3bgTNjwY2Tpc+mGS3P/g== X-Google-Smtp-Source: ACHHUZ7Nb0+j6lDWoh5dzhi0d6OwiKRK103A4LO9ELn4w+5Ig8fDdtkJqivRkZF9X0m9jKXIS0c+cg== X-Received: by 2002:a17:903:124d:b0:1b0:25d2:6f11 with SMTP id u13-20020a170903124d00b001b025d26f11mr730048plh.17.1686011233466; Mon, 05 Jun 2023 17:27:13 -0700 (PDT) Received: from [10.94.77.175] (54-240-196-170.amazon.com. [54.240.196.170]) by smtp.gmail.com with ESMTPSA id 13-20020a170902c14d00b001a6d4ffc760sm7148634plj.244.2023.06.05.17.27.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 17:27:12 -0700 (PDT) Message-ID: <87feba4c-537c-9778-9175-289b76971aac@ardentperf.com> Date: Mon, 5 Jun 2023 17:27:11 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: Let's make PostgreSQL multi-threaded To: "Jonah H. Harris" , Tom Lane Cc: Heikki Linnakangas , pgsql-hackers References: <31cc6df9-53fe-3cd9-af5b-ac0d801163f4@iki.fi> <4178104.1685978307@sss.pgh.pa.us> Content-Language: en-US From: Jeremy Schneider In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/5/23 2:07 PM, Jonah H. Harris wrote: > On Mon, Jun 5, 2023 at 8:18 AM Tom Lane > wrote: > > For the record, I think this will be a disaster.  There is far too much > code that will get broken, largely silently, and much of it is not > under our control. > > > While I've long been in favor of a multi-threaded implementation, now in > my old age, I tend to agree with Tom. I'd be interested in Konstantin's > thoughts (and PostgresPro's experience) of multi-threaded vs. internal > pooling with the current process-based model. I recall looking at and > playing with Konstantin's implementations of both, which were > impressive. Yes, the latter doesn't solve the same issues, but many > real-world ones where multi-threaded is argued. Personally, I think > there would be not only a significant amount of time spent dealing with > in-the-field stability regressions before a multi-threaded > implementation matures, but it would also increase the learning curve > for anyone trying to start with internals development. To me, processes feel just a little easier to observe and inspect, a little easier to debug, and a little easier to reason about. Tooling does exist for threads - but operating systems track more things at a process level and I like having the full arsenal of unix process-based tooling at my disposal. Even simple things, like being able to see at a glance from "ps" or "top" output which process is the bgwriter or the checkpointer, and being able to attach gdb only on that process without pausing the whole system. Or to a single backend. A thread model certainly has advantages but I do feel that some useful things might be lost here. And for the record, just within the past few weeks I saw a small mistake in some C code which smashed the stack of another thread in the same process space. It manifested as unpredictable periodic random SIGSEGV and SIGBUS with core dumps that were useless gibberish, and it was rather difficult to root cause. But one interesting outcome of that incident was learning from my colleague Josh that apparently SUSv2 and C99 contradict each other: when snprintf() is called with size=0 then SUSv2 stipulates an unspecified return value less than 1, while C99 allows str to be NULL in this case, and gives the return value (as always) as the number of characters that would have been written in case the output string has been large enough. So long story short... I think the robustness angle on the process model shouldn't be underestimated either. -Jeremy -- http://about.me/jeremy_schneider