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 1q71ml-0005iQ-Ht for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jun 2023 22:37:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q71mk-0006Ka-3A for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jun 2023 22:37:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q71mj-0006KJ-FA for pgsql-hackers@lists.postgresql.org; Wed, 07 Jun 2023 22:37:45 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q71mc-000moi-40 for pgsql-hackers@lists.postgresql.org; Wed, 07 Jun 2023 22:37:43 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f7368126a6so37282795e9.0 for ; Wed, 07 Jun 2023 15:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20221208.gappssmtp.com; s=20221208; t=1686177456; x=1688769456; h=content-transfer-encoding:in-reply-to:cc:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=LkW96A98UffjqTEabblSqhyq/Khh1AgZeCBFKS1eL5Y=; b=U7g7ZaC2MNA9u6Z6fmLRvRZhx/c0njasry0AXbhC1jrIWj2rpqSLAP+wdfhUoBcImp QX1OfJA6kK2N/Gs3nZ323rNKLjBxfgt7dS9r3bCZOk1z6alrepF0VVCCmvLIWeT1erAU 12wKxUtEWu763ZggJZJWYtWclLIjVhKSNNSTtB0v9E1IyZtSzrJ7trIwzw9Vtwco2n5t hcx8FAl0QtgisLABd5dszIShSa+1qpITlNFDZbwLvn464B69iGJ0jdrx5ZXwGaDOzhKU WroPnLcAs1Q+PvtlXI2CPDFJpaNYb2bqWdcWZEeLp1j+jlT27zPUl3SG4HSiEX6nq+l0 bhaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686177456; x=1688769456; h=content-transfer-encoding:in-reply-to:cc:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LkW96A98UffjqTEabblSqhyq/Khh1AgZeCBFKS1eL5Y=; b=jcCBgUSZumM2bEBCYr378cCggwxnsBzYZdzYNnULGBKigaR1rcLWK/6v5O5mazDkmT pjfBJjNQtZIyohVaUi9mKDTWLXVxVMKkzl7E0fAzWgwNqzLv5CWYsXvpWsS/up/MHJsV s+i916xmutWWjd14E9RYdihng8mNKaciCagEuNaa7yuOnv8NDS9o22AaN8RKfvYsa9hU o4ibJNjK2sz7zoqkEu783piMcDPn0YwLcCIu5nVYUDOGjRy7wjei1ZF9NuTHs+Q12Ur6 tog2sFvwc2aovDqVIORGMwB/U3sKmtQc0aR+nm8t2JAZ5Zs6F0ZWYOZ5EOFkd8Wxonzh pI8w== X-Gm-Message-State: AC+VfDxzWsTyePBplPXGwxc6uzSejxbVqqNwD4y4pbZPiaMcE4mD2nXw L2uwNToNDe+yPhFSVcD+yeBhW4t2/aqOPzQafDXpGFyS X-Google-Smtp-Source: ACHHUZ7hpNf1AKDzRtPI9VfLIczi+qVjzCi+rFjLHlkUn0SCSz1Gr1DoCqvVo95Z9zUryr+9KRqkCA== X-Received: by 2002:a05:600c:22c3:b0:3f4:27ff:7d48 with SMTP id 3-20020a05600c22c300b003f427ff7d48mr5761997wmg.19.1686177455718; Wed, 07 Jun 2023 15:37:35 -0700 (PDT) Received: from [192.168.27.166] ([54.239.6.187]) by smtp.gmail.com with ESMTPSA id k14-20020a7bc30e000000b003f4266965fbsm3475047wmj.5.2023.06.07.15.37.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jun 2023 15:37:35 -0700 (PDT) Message-ID: Date: Wed, 7 Jun 2023 15:37:31 -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 Content-Language: en-US To: pgsql-hackers@lists.postgresql.org References: <31cc6df9-53fe-3cd9-af5b-ac0d801163f4@iki.fi> <4178104.1685978307@sss.pgh.pa.us> <4ce6c0f8-e8a4-1672-93fd-49d3fa975ee5@iki.fi> <29fe5f48-a6ed-d896-45ed-16b5904353a9@enterprisedb.com> <41c1e20d-f179-f87e-5929-80ca9ee0c105@gmx.net> From: Jeremy Schneider Cc: Thomas Kellerer , Tomas Vondra , Heikki Linnakangas , Tom Lane In-Reply-To: <41c1e20d-f179-f87e-5929-80ca9ee0c105@gmx.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/7/23 2:39 PM, Thomas Kellerer wrote: > Tomas Vondra schrieb am 07.06.2023 um 21:20: >> Also, which other projects did this transition? Is there something we >> could learn from them? Were they restricted to much smaller list of >> platforms? > > Not open source, but Oracle was historically multi-threaded on Windows > and multi-process on all other platforms. > I _think_ starting with 19c you can optionally run it multi-threaded on > Linux as well. Looks like it actually became publicly available in 12c. AFAICT Oracle supports both modes today, with a config parameter to switch between them. This is a very interesting case study. Concepts Manual: https://docs.oracle.com/en/database/oracle/oracle-database/23/cncpt/process-architecture.html#GUID-4B460E97-18A0-4F5A-A62F-9608FFD43664 Reference: https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/THREADED_EXECUTION.html#GUID-7A668A49-9FC5-4245-AD27-10D90E5AE8A8 List of Oracle process types, which ones can run as threads and which ones always run as processes: https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/background-processes.html#GUID-86184690-5531-405F-AA05-BB935F57B76D Looks like they have four processes that will never run in threads: * dbwriter (writes dirty blocks in background) * process monitor (cleanup after process crash to avoid full server restarts) * process spawner (like postmaster) * time keeper process Per Tim Hall's oracle-base, it seems that plenty of people are sticking with the process model, and that one use case for threads was: "consolidating lots of instances onto a single server without using the multitennant option. Without the multithreaded model, the number of OS processes could get very high." https://oracle-base.com/articles/12c/multithreaded-model-using-threaded_execution_12cr1 I did google search for "oracle threaded_execution" and browsed a bit; didn't see anything that seems earth shattering so far. Ludovico Caldara and Martin Bach published blogs when it was first released, which just introduced but didn't test or hammer on it. The feature has existed for 10 years now and I don't see any blog posts saying that "everyone should use this because it doubles your performance" or anything like that. I think if there were really significant performance gains then there would be many interesting blog posts on the internet by now from the independent Oracle professional community - I know many of these people. In fact, there's an interesting blog by Kamil Stawiarski from 2015 where he actually observed one case of /slower/ performance with threads. That blog post ends with: "So I raise the question: why and when use threaded execution? If ever?" https://blog.ora-600.pl/2015/12/17/oracle-12c-internals-of-threaded-execution/ I'm not sure if he ever got an answer -Jeremy -- http://about.me/jeremy_schneider