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 1q9iuG-0002g6-8r for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 09:04:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9iuC-0001bG-ET for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 09:04:36 +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 1q9iuC-0001b4-4v for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 09:04:36 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q9iu9-002V0Q-Jx for pgsql-hackers@postgresql.org; Thu, 15 Jun 2023 09:04:35 +0000 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-3f9d619103dso151871cf.1 for ; Thu, 15 Jun 2023 02:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686819872; x=1689411872; 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=Tz+2F2NVTCZJ6RfEW9UzyI5aSqZSsYiHOuvgIFPVOLc=; b=sDInllC2Ad/4iyCutbVz872Uw+T8Qn8NHA1coWkB+UTtaAjPJsfh0mVqwtDokY1lR2 XwibqU1t85xtZTbl0m6zrBDaxpEq06H6qCE+Ds9ioDaoCfTN5+ekRPy1i1Ai19cjZeSG I+0/u9ka/NmPhoqGVl08bHIWopb+k20BNsd02YQd9N+ltGm6ZyPeGYi6hbFB9FTmyTX2 Ekn+9obWS4R9fB+jKP5hh4uqRlUVXUT9i2Mh3ZAS90YQVSC9Av2slRtsuOioo4DVKWY7 2lpWRS+Tj00jiqowJrhjeOJgUtkxMRybcF4bvkYUinP4s5fit8qnFr0k9BrNzzg19Gzl 0Mbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686819872; x=1689411872; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tz+2F2NVTCZJ6RfEW9UzyI5aSqZSsYiHOuvgIFPVOLc=; b=cXMXA49tXTsGyaIKWwLxTMhOyuuiiWaEAoyH6GJ4pBMLqp8WSf0jwlJZ1ZO/3zvHx8 EG5PKIbT/ZAUOcw+BEUdM+Yjvu+74S1rHhDPn3Dy4OIREQ3pnt+tIvJR+6po1VmlVUEL BWrSCqS22HNCMVSc+KFdJ4u13EMin/YOxGiMRTQOl+rfPtoV6XT+wP7axVeYFIHCUjjD uYhIcJWbruWDpYw9BmzHcTh3niNuPV7ND49fGdP+T3HGs6CpX8xONbQngzUWxHo5LD5P H5xGPFsjfNJSJVBvHe2cKbP+txPWmKfmlVhau6ENT327n1HdOU1CdXJzCCOrj8GlESm2 1DXQ== X-Gm-Message-State: AC+VfDzIDoteh5mI2oS3nNHHgOMnUVaLGsvv+z8CunwkLaIHL3MDn/m2 fjgADs6EjFUkIR49Y7TXCmGosTagBvmDgpQCY/sTaQ== X-Google-Smtp-Source: ACHHUZ6o+1CE9TtYSiowzQZNzr66XmoFiwrtLfMGZydzDAhVFTWvqIeqeyTA0TRofNQAOm6q2Dwai+Z8d8xyHTy4zZk= X-Received: by 2002:a05:622a:180a:b0:3ed:86f6:6eab with SMTP id t10-20020a05622a180a00b003ed86f66eabmr191863qtc.14.1686819872239; Thu, 15 Jun 2023 02:04:32 -0700 (PDT) MIME-Version: 1.0 References: <31cc6df9-53fe-3cd9-af5b-ac0d801163f4@iki.fi> <2c2665d2-c513-c12e-9097-9b1805bc2471@garret.ru> <36f61a71-3bbb-b7b0-0d99-db5e69715af7@garret.ru> In-Reply-To: From: Hannu Krosing Date: Thu, 15 Jun 2023 11:04:20 +0200 Message-ID: Subject: Re: Let's make PostgreSQL multi-threaded To: James Addison Cc: Konstantin Knizhnik , Pavel Borisov , Dilip Kumar , Heikki Linnakangas , pgsql-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 Thu, Jun 15, 2023 at 10:41=E2=80=AFAM James Addison = wrote: > > This is making me wonder about other performance/scalability areas > that might not have been considered due to focus on the details of the > existing codebase, but I'll save that for another thread and will try > to learn more first. A gradual move to more shared structures seems to be a way forward It should get us all the benefits of threading minus the need for TLB reloading and (in some cases) reduction of per-process virtual memory mapping tables. In any case we would need to implement all the locking and parallelism management of these shared structures that are not there in the current process architecture. So a fair bit of work but also a clearly defined benefits of 1) reduced memory usage 2) no need to rebuild caches for each new connection 3) no need to track PREPARE statements inside connection poolers. There can be extra complexity when different connections use the same prepared statement name (say "PREP001") for different queries. For this wel likely will need a good cooperation with connection pooler where it passes some kind of client connection id along at the transaction start