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 1phOrj-0005fk-1t for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Mar 2023 06:00:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1phOrg-0006as-TE for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Mar 2023 06:00:56 +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 1phOrg-0006aj-HL for pgsql-hackers@lists.postgresql.org; Wed, 29 Mar 2023 06:00:56 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1phOrd-0008Fk-QL for pgsql-hackers@postgresql.org; Wed, 29 Mar 2023 06:00:55 +0000 Received: by mail-pj1-x1032.google.com with SMTP id x15so13101034pjk.2 for ; Tue, 28 Mar 2023 23:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680069651; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=Jch+IYb9haIEJxMeRI041lK5g55lpH1ZK0UBhQTw6C4=; b=iLmXy8cb+kE7CKIL4piq2KuuPqQJ8WOym4tyTCad7792F1AzNLsi4p9xfwpByo2O89 NMFvQKu3Pd0OH+ZeOyBpR6ALDbOgmBuv69yzXhgmnOx9O1HnYRWNc1v5hJMR68hKvfQT 19/ZKI0qfwtvtL5f0kEU9eF9ZSaEcX/0HhzB2ZLr8N3VBml8Onr5SMtAM4cZobdws/Zw JnZ/TAXKDC4F1JUGmzm17bqzzzSMzlXcs0lSC2BUaLGXXxVoFbDR6p4WCVHbfTY3HPCt 2S9ZSWd9MfONdXOMkpxp6ulWRKDeB6xb8pgE+c9wSmsleP0KOR3rbLMTzpR7hkYhrQWl LZXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680069651; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Jch+IYb9haIEJxMeRI041lK5g55lpH1ZK0UBhQTw6C4=; b=e1EAFqf7fL/rXJd1OGrJdEmY/DkTjmqpH2rcxuwaqZwTUu4QZt5yJqt/vPcvLBolL1 pMRsaoKBbZwdlHmbDpIPanyQtW7X8qB1ZKfqvUbXFbLfgDBnbr10tiefiCFvN4bntd9h SVuMlhntGDckLvTJkHJVsujQbrEyxtnSmSiT+tTj0qLMe1xixSAkmLfpX8VxqVfiGWfe LjffzoFCM//fB8PL3K8GUivcVwF5alpvG0MQ/H4TU0QvMqq/betS6nCvhjnO+AjjqMa8 HviBnvLP0OyJWxnfgOh+741YgAG+0f2qpPDIDrCd+nEiiXca/TH/ypPVWqDqWUllszIi iyxw== X-Gm-Message-State: AAQBX9f4q5bYz6evgdn/F2+8TnE+9e7bUaOURlxUGXONOMIPt/WfjK8A Hq4WRDCVuqjbbp6gbdcG6Kw= X-Google-Smtp-Source: AKy350ZfuI+eOCxxT1Ho1T5tMB0waScdnFX9lOXOvNAUVqbUFFc+qNcN44v3EDtNtqh/yHjO5avpcQ== X-Received: by 2002:a17:903:41cf:b0:1a1:a800:96a7 with SMTP id u15-20020a17090341cf00b001a1a80096a7mr21143633ple.8.1680069650979; Tue, 28 Mar 2023 23:00:50 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id h12-20020a170902b94c00b001a1ed2fce9asm13409453pls.235.2023.03.28.23.00.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Mar 2023 23:00:50 -0700 (PDT) Date: Wed, 29 Mar 2023 15:00:47 +0900 (JST) Message-Id: <20230329.150047.1496807418504041265.horikyota.ntt@gmail.com> To: melanieplageman@gmail.com Cc: sawada.mshk@gmail.com, daniel@yesql.se, pgsql-hackers@postgresql.org, andres@anarazel.de, amit.kapila16@gmail.com Subject: Re: Should vacuum process config file reload more often From: Kyotaro Horiguchi In-Reply-To: <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> References: <20230329.120908.350115307125624430.horikyota.ntt@gmail.com> <20230329.132155.629765142788133576.horikyota.ntt@gmail.com> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Wed, 29 Mar 2023 13:21:55 +0900 (JST), Kyotaro Horiguchi wrote in > autovacuum.c:2893 > /* > * If any of the cost delay parameters has been set individually for > * this table, disable the balancing algorithm. > */ > tab->at_dobalance = > !(avopts && (avopts->vacuum_cost_limit > 0 || > avopts->vacuum_cost_delay > 0)); > > So, sorry for the noise. I'll review it while this into cnosideration. Then I found that the code is quite confusing as it is. For the tables that don't have cost_delay and cost_limit specified indificually, at_vacuum_cost_limit and _delay store the system global values detemined by GUCs. wi_cost_delay, _limit and _limit_base stores the same values with them. As the result I concluded tha autovac_balance_cost() does exactly what Melanie's patch does, except that nworkers_for_balance is not stored in shared memory. I discovered that commit 1021bd6a89 brought in do_balance. > Since the mechanism is already complicated, just disable it for those > cases rather than trying to make it cope. There are undesirable After reading this, I get why the code is so complex. It is a remnant of when balancing was done with tables that had individually specified cost parameters. And I found the following description in the doc. https://www.postgresql.org/docs/devel/routine-vacuuming.html > When multiple workers are running, the autovacuum cost delay > parameters (see Section 20.4.4) are “balanced” among all the running > workers, so that the total I/O impact on the system is the same > regardless of the number of workers actually running. However, any > workers processing tables whose per-table > autovacuum_vacuum_cost_delay or autovacuum_vacuum_cost_limit storage > parameters have been set are not considered in the balancing > algorithm. The initial balancing mechanism was brought in by e2a186b03c back in 2007. The balancing code has had that unnecessarily complexity ever since. Since I can't think of a better idea than Melanie's proposal for handling this code, I'll keep reviewing it with that approach in mind. regards. -- Kyotaro Horiguchi NTT Open Source Software Center