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 1uXhIg-00DJMt-Dg for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jul 2025 14:22:02 +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 1uXhId-0012tJ-DA for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jul 2025 14:22:00 +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 1uXhIc-0012t3-Vi for pgsql-hackers@lists.postgresql.org; Fri, 04 Jul 2025 14:21:59 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uXhIb-005YLL-33 for pgsql-hackers@lists.postgresql.org; Fri, 04 Jul 2025 14:21:58 +0000 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-4a43972dcd7so11696831cf.3 for ; Fri, 04 Jul 2025 07:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751638916; x=1752243716; darn=lists.postgresql.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RwvL03mXjqLVxJafarDdNW2yhsKLeGZKsr35NVrp1pI=; b=DjWO0ixR2WlYd0O3ouhFUZ+KX13Tr2O9gv5H9P4KRjt9yYz2tO3VsqdWjY+eFVJC9w IHvd95jttfddtL5J1+Qw01wmahkgv4tDeT1LObkIM4alH3ZkvtqtDl2c+bIfsEe90hdi VbO23ggsHcAVTzifcQ21hdyvqzTXiRZr7moPWIcfCdGlgo9McGqrikKbkJRI46XfFe1n mn9AeI3ukhtiKJir1Ia53azVhyBd+8S5kenzCkKSW3VJM8UdZHh7b88S1r2vG+QiZdmS NQdpQWdNzfYXhS5wMv7KoQEqL9FjHyi7nV1gXKkpKETAGdLjlJShS3fG03BPJ41wk0qg Xcxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751638916; x=1752243716; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=RwvL03mXjqLVxJafarDdNW2yhsKLeGZKsr35NVrp1pI=; b=kMl8Ps7j5mfnBeSrz2G1bMhd3Dg5PgdWHfjdKjIbMQlPDnLAupipyL5vXtxhb6dNT2 pzP8auhh+CJGK0KvY6GiVPW+MLK7ncCvup8lxw5UiLsNt+R4M1X2A85xjCT0uBkvtKQO 1l+9qy8ZL553G5tM35dff7NipNeIGr9x46ov05es+qjq8307yYKq/yk43ft6kPXMdJLU HZWTwRUSZPl+a8+mIHn3GZ6rWcH3zp8+GH0VoG3hRXCagRJw2RqRfUWZvPScx2Vv2KIY I/yej3EwIGJS9wwX8rQ8grM/Gmd4aG6DOCMCKjNwr1+jnWQiy/cigSMoBT+y8yigFirg wbpQ== X-Forwarded-Encrypted: i=1; AJvYcCXsZZiiSMansOouhraB1rjQ0H6QPzmMUwYQcUQvC0NQzwMqBXOCPTqbryVBoK32RmV1a65o42GB2i24ULoF@lists.postgresql.org X-Gm-Message-State: AOJu0YyhrVrVUbUztLWrqF7N76HwLPKL3vvWTz+wXCFsyNyJ0Zv5aOcP 6Gr44rjFt1Q/+5XUb09qprzbExIxOkW7KYziDSEq/2IGO7Hgm80aVSeL X-Gm-Gg: ASbGnctEN07IXMaBrd60ayjE0NRKO2209Q19LmdYf19RUwC70O91bZdJY5skb8rCCjN QDwUANzW7tXuKSYEOJW0kx6/L4OiVeq6klVgSyU+XqKYJPm9m6id+mlbCTPUa3e0wF+y0ipTxi5 VCaqw9A+QcnULf4bIw3AncNQ32D89GWmqvTIwi3gvVE+Y712Mjea8JoYdtQg7y5dbr3ZYNIJeHo Bv3FczPNn34Yet/p+u46ty0OYBa4mS8ayID+8JIAMgl0tyDxVcebxz6Mg/xzUFb+tVqMKeqj/Ko kBKDfl35VcnrxkZblkKnTzDmpJ5gyt7LbThXK9b1yu6booXBDLK3fXQL0ld9XWEBN5zDoFG6lin V2e98/hA8Pg== X-Google-Smtp-Source: AGHT+IG4NwEhtF2W2wUM5sNf7+ggM0j0U2yvIsKAEUJrN1OcHxgGOA6Cw9lfPpScWNIm1IvP36zXLw== X-Received: by 2002:ac8:5896:0:b0:4a4:30e7:776 with SMTP id d75a77b69052e-4a99868c950mr34752611cf.14.1751638915726; Fri, 04 Jul 2025 07:21:55 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:19e2:978e:4808:b6f1]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4a994a78ca8sm15000621cf.48.2025.07.04.07.21.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 07:21:55 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 04 Jul 2025 11:21:52 -0300 Message-Id: Cc: "Sami Imseih" , "Maxim Orlov" , "Postgres hackers" Subject: Re: POC: Parallel processing of indexes in autovacuum From: "Matheus Alcantara" To: "Daniil Davydov" <3danissimo@gmail.com>, "Masahiko Sawada" X-Mailer: aerc 0.20.1 References: In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed Jun 18, 2025 at 5:03 AM -03, Daniil Davydov wrote: > > Thanks for the review! Please, see v5 patch : > 1) GUC variable and field in autovacuum shmem are renamed > 2) ParallelAutoVacuumReleaseWorkers call moved from parallel.c to > vacuumparallel.c > 3) max_parallel_autovacuum_workers is now PGC_SIGHUP parameter > 4) Fix little bug (ParallelAutoVacuumReleaseWorkers in autovacuum.c:735) > Thanks for the new version! The "autovacuum_max_parallel_workers" declared on guc_tables.c mention that is capped by "max_worker_process": + { + {"autovacuum_max_parallel_workers", PGC_SIGHUP, VACUUM_AUTOVACUUM, + gettext_noop("Maximum number of parallel autovacuum workers, that can b= e taken from bgworkers pool."), + gettext_noop("This parameter is capped by \"max_worker_processes\" (not= by \"autovacuum_max_workers\"!)."), + }, + &autovacuum_max_parallel_workers, + 0, 0, MAX_BACKENDS, + check_autovacuum_max_parallel_workers, NULL, NULL + }, But the postgresql.conf.sample say that it is limited by max_parallel_workers: +#autovacuum_max_parallel_workers =3D 0 # disabled by default and limited b= y max_parallel_workers IIUC the code, it cap by "max_worker_process", but Masahiko has mention on [1] that it should be capped by max_parallel_workers. --- We actually capping the autovacuum_max_parallel_workers by max_worker_process-1, so we can't have 10 max_worker_process and 10 autovacuum_max_parallel_workers. Is that correct? +bool +check_autovacuum_max_parallel_workers(int *newval, void **extra, + GucSource source) +{ + if (*newval >=3D max_worker_processes) + return false; + return true; +} --- Locking unnecessary the AutovacuumLock if none if the if's is true can cause some performance issue here? I don't think that this would be a serious problem because this code will only be called if the configuration file is changed during the autovacuum execution right? But I could be wrong, so just sharing my thoughts on this (still learning about [auto]vacuum code). + +/* + * Make sure that number of available parallel workers corresponds to the + * autovacuum_max_parallel_workers parameter (after it was changed). + */ +static void +check_parallel_av_gucs(int prev_max_parallel_workers) +{ + LWLockAcquire(AutovacuumLock, LW_EXCLUSIVE); + + if (AutoVacuumShmem->av_available_parallel_workers > + autovacuum_max_parallel_workers) + { + Assert(prev_max_parallel_workers > autovacuum_max_parallel_workers); + Typo on "exeed" + /* + * Number of available workers must not exeed limit. + * + * Note, that if some parallel autovacuum workers are running at this + * moment, available workers number will not exeed limit after releasing + * them (see ParallelAutoVacuumReleaseWorkers). + */ --- I'm not seeing an usage of this macro? +/* + * RelationGetParallelAutovacuumWorkers + * Returns the relation's parallel_autovacuum_workers reloption setting. + * Note multiple eval of argument! + */ +#define RelationGetParallelAutovacuumWorkers(relation, defaultpw) \ + ((relation)->rd_options ? \ + ((StdRdOptions *) (relation)->rd_options)->autovacuum.parallel_autovacuu= m_workers : \ + (defaultpw)) + --- Also pgindent is needed on some files. --- I've made some tests and I can confirm that is working correctly for what I can see. I think that would be to start include the documentation changes, what do you think? [1] https://www.postgresql.org/message-id/CAD21AoAxTkpkLtJDgrH9dXg_h%2ByzOZ= pOZj3B-4FjW1Mr4qEdbQ%40mail.gmail.com -- Matheus Alcantara