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 1s7n9S-007RQC-J9 for pgsql-hackers@arkaria.postgresql.org; Fri, 17 May 2024 02:16:55 +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 1s7n9S-002y9V-Gg for pgsql-hackers@arkaria.postgresql.org; Fri, 17 May 2024 02:16:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s7n9S-002y5l-5u for pgsql-hackers@lists.postgresql.org; Fri, 17 May 2024 02:16:54 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s7n9O-000dTn-4n for pgsql-hackers@postgresql.org; Fri, 17 May 2024 02:16:53 +0000 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7e1cd52db2eso5322939f.0 for ; Thu, 16 May 2024 19:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715912209; x=1716517009; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=iENmlhbHEbPIxNT2OKj6aFzns0FztsTpxXOM53jTlbY=; b=DCJ7mKwMnoVNJvUrf8YihGmuxgmcP2IBtDicr8ItMskF7Ogo+D+/uNrLf1NPmE5h+j ZNd5paedoDMySLU4KdaP9mMkKL4ojau9uHb2ULjCvGZrZFp51rjTNj5zqfRQccU+bTFy JFRNAwa31IJy0PAA3SLFmRY1om4eeO8XhLFApV38evBoIhsV4f0uDh0b2aZrzcGdANXY mSKLuaz7nhgiStmN+BSP5y59FWTvmf6FQ2aifZFark4vDOmtXVTqObAEt73V6nhKg3rM OjhEnbt5JrWjqIb+Xb4yWDsz96LkikzBpLsECturUxqhYZwy/02tbX3pAvgETEy5yrUo 7umQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715912209; x=1716517009; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iENmlhbHEbPIxNT2OKj6aFzns0FztsTpxXOM53jTlbY=; b=rUhENrORYAEX2Depj0jun0GZ6Yhx20xccA4mhR8eUz+jsu8FIj2ZLumM9Tp2OzI4jn uU9EQTFftFscmfKEV99Dcqzrz991CdLb8CvjTX8hryJIOW++tDP3oWurPggicUZ6WvQ6 MzZGpv5Sdd0VxeT5uMktWMkeiAOb4C5yatjXhgUFjq0Ptyf1lsaBD6Xj+oxU9oCaXKtr gzM81x+yxOUHrPf8pM5UFz0IppuhDp9Q7BWTeD+NpBXLio5v2TOe4L/skF6H2kScke3i bjIYV7RnwUXY8/R847kTX5BFQ5tOEpmZv3WiWEeJjhDtjuKSviqHti1b/Mz8if/Sb5B3 gwXg== X-Forwarded-Encrypted: i=1; AJvYcCV2Auq2TOTIgxA7w2Q0+U3688eZrtACvo3KjXGYO+KQfz+kh4cy0yiumWV7kjYcEDPZUbqx83B9QhsDzhcGDP2USXjEjs2WA/VX7ITh X-Gm-Message-State: AOJu0Ywe1BkIRW3bh1NKptiSOYTiIjWk0/hnYQLZvyA+D5jjLCf2SRri akehVdPy4G2IwOw6ktjDNJK6WZPX+CWs+S8Uu8bpBQZaZMU/dDKy X-Google-Smtp-Source: AGHT+IGdk2TSdw+3I/MVXA4V/GdG2UnZKG4gopQhmGXobZyUzXSWr7nTgryLhlZjUzAnWy6sXkRn1Q== X-Received: by 2002:a6b:4a05:0:b0:7e1:b4f7:f438 with SMTP id ca18e2360f4ac-7e1b5220252mr2254317239f.18.1715912209395; Thu, 16 May 2024 19:16:49 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-489375c1afesm4385315173.103.2024.05.16.19.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 19:16:48 -0700 (PDT) Date: Thu, 16 May 2024 21:16:46 -0500 From: Nathan Bossart To: "Imseih (AWS), Sami" Cc: Justin Pryzby , "pgsql-hackers@postgresql.org" Subject: Re: allow changing autovacuum_max_workers without restarting Message-ID: <20240517021646.GA1745636@nathanxps13> References: <20240410212344.GA1824549@nathanxps13> <20240415162833.GA2857238@nathanxps13> <20240415163749.GA2858464@nathanxps13> <96B4FC7B-A919-4F93-80A3-BA3EA4F8479A@amazon.com> <20240503010415.GA1008894@nathanxps13> <2780DB08-DCA6-4E57-B823-303A0E7E17D7@amazon.com> <20240507160605.GA2523153@nathanxps13> <011CA929-4933-40EA-B1D3-29131FEFBCF0@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <011CA929-4933-40EA-B1D3-29131FEFBCF0@amazon.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, May 16, 2024 at 04:37:10PM +0000, Imseih (AWS), Sami wrote: > I thought 256 was a good enough limit. In practice, I doubt anyone will > benefit from more than a few dozen autovacuum workers. > I think 1024 is way too high to even allow. WFM > I don't think combining 1024 + 5 = 1029 is a good idea in docs. > Breaking down the allotment and using the name of the constant > is much more clear. > > I suggest > " max_connections + max_wal_senders + max_worker_processes + AUTOVAC_MAX_WORKER_SLOTS + 5" > > and in other places in the docs, we should mention the actual > value of AUTOVAC_MAX_WORKER_SLOTS. Maybe in the > below section? > > Instead of: > - () and allowed background > + (1024) and allowed background > > do something like: > - () and allowed background > + AUTOVAC_MAX_WORKER_SLOTS (1024) and allowed background > > Also, replace the 1024 here with AUTOVAC_MAX_WORKER_SLOTS. > > + max_wal_senders, > + plus max_worker_processes, plus 1024 for autovacuum > + worker processes, plus one extra for each 16 Part of me wonders whether documenting the exact formula is worthwhile. This portion of the docs is rather complicated, and I can't recall ever having to do the arithmetic is describes. Plus, see below... > Also, Not sure if I am mistaken here, but the "+ 5" in the existing docs > seems wrong. > > If it refers to NUM_AUXILIARY_PROCS defined in > include/storage/proc.h, it should a "6" > > #define NUM_AUXILIARY_PROCS 6 > > This is not a consequence of this patch, and can be dealt with > In a separate thread if my understanding is correct. Ha, I think it should actually be "+ 7"! The value is calculated as MaxConnections + autovacuum_max_workers + 1 + max_worker_processes + max_wal_senders + 6 Looking at the history, this documentation tends to be wrong quite often. In v9.2, the checkpointer was introduced, and these formulas were not updated. In v9.3, background worker processes were introduced, and the formulas were still not updated. Finally, in v9.6, it was fixed in commit 597f7e3. Then, in v14, the archiver process was made an auxiliary process (commit d75288f), making the formulas out-of-date again. And in v17, the WAL summarizer was added. On top of this, IIUC you actually need even more semaphores if your system doesn't support atomics, and from a quick skim this doesn't seem to be covered in this documentation. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com