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 1sGh4j-00G2Bv-67 for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jun 2024 15:36:49 +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 1sGh4h-00DZFm-Lf for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jun 2024 15:36:48 +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 1sGh4h-00DZFX-BR for pgsql-hackers@lists.postgresql.org; Mon, 10 Jun 2024 15:36:48 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGh4f-000eSd-Of for pgsql-hackers@lists.postgresql.org; Mon, 10 Jun 2024 15:36:47 +0000 Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7eb77b1d2fcso76605539f.0 for ; Mon, 10 Jun 2024 08:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718033805; x=1718638605; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=nYysFtzneKxZ+wrMhJ2XWcYNw8BFUs/arLIHxzBMGXg=; b=WE1sRDOTIeu5Ml9QGr0pF56hTq/oOdU5qvIq0vDGpOPRHbQi2VKfZLobKuq2NfxTsP Q8UYO9ViCpZusnmYD+6M72IgQT5t5meeq83FCo/TadQnthS/1lV4W7iNnRtb1HQpHaCq m4Ccy9TB70WTroLsMRK6zSpyBeWgQaMnGhWJW908fSLIeUSOw/xhU3wT0M27V9fNpw59 uktq5Ek1eROPtZdu89vFlM1I0cHCa65qT+J6BCH+hB0l8jgofXrC8DJz6BXugxL1inYY jLPPpuQvo6/mv7lQz/RDdQMvrSEoLSSI7jIYGfqzkEK6ReDsV+zcoMHVD8wcK7eHDiDA m/HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718033805; x=1718638605; h=in-reply-to:content-transfer-encoding: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=nYysFtzneKxZ+wrMhJ2XWcYNw8BFUs/arLIHxzBMGXg=; b=rHy5Kxm+Hzy1ApIjhFbLOb0o2bQaI8/86BDHBP6AiJ+wVDeahuC1ZT+h3H/dgHp1br FJVd946NAk30Mq6qeq9OwrBKAKvJhCFOMQL+H6r/CB5BZ2ODyxFzCJUcxiPEK99aSDKw QCmH4KpIY+XrWq6BZQKIoXxm1fwmvqCgOe/1nv6mGyskaj3omW74NJhGIERGecO8oab9 0mYaAwLhsSsDzvPZTu/6HGyVFwxeE95fVqn0X28kopk1A2kTfMAZvLjpmXqTzRc+jFX6 Yplt+kW9q+MEAvgQ87W64p07VzqseRR4CPccB7+PDqLTR3cGykLTnXO0oAX+1vgNWUDI NNog== X-Gm-Message-State: AOJu0Ywq0CdUlehfyG9F8GAdMBa2opZqOlFm+JbHg6rNa6Bnh+eH2rCe GXNIi//XVIZA0DqMVmZIzzEYkemAT9tLlZrzdGWwX1ygj3SVfpY0lRSGAQ== X-Google-Smtp-Source: AGHT+IGleEFCmzV5S2crZj8d8HA5S5NOBY/Rz1cctQiNFGN2Iv9u8qGzR3+rULSkPArihlppRsi2GQ== X-Received: by 2002:a05:6602:2dd0:b0:7eb:6a37:89ce with SMTP id ca18e2360f4ac-7eb6a378cf0mr880341939f.14.1718033804804; Mon, 10 Jun 2024 08:36:44 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4b9180af36asm689371173.119.2024.06.10.08.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:36:44 -0700 (PDT) Date: Mon, 10 Jun 2024 10:36:42 -0500 From: Nathan Bossart To: Bertrand Drouvot Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Track the amount of time waiting due to cost_delay Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jun 10, 2024 at 06:05:13AM +0000, Bertrand Drouvot wrote: > During the last pgconf.dev I attended Robertīs presentation about autovacuum and > it made me remember of an idea I had some time ago: $SUBJECT This sounds like useful information to me. I wonder if we should also surface the effective cost limit for each autovacuum worker. > Currently one can change [autovacuum_]vacuum_cost_delay and > [auto vacuum]vacuum_cost_limit but has no reliable way to measure the impact of > the changes on the vacuum duration: one could observe the vacuum duration > variation but the correlation to the changes is not accurate (as many others > factors could impact the vacuum duration (load on the system, i/o latency,...)). IIUC you'd need to get information from both pg_stat_progress_vacuum and pg_stat_activity in order to know what percentage of time was being spent in cost delay. Is that how you'd expect for this to be used in practice? > pgstat_report_wait_start(WAIT_EVENT_VACUUM_DELAY); > pg_usleep(msec * 1000); > pgstat_report_wait_end(); > + /* Report the amount of time we slept */ > + if (VacuumSharedCostBalance != NULL) > + pgstat_progress_parallel_incr_param(PROGRESS_VACUUM_TIME_DELAYED, msec); > + else > + pgstat_progress_incr_param(PROGRESS_VACUUM_TIME_DELAYED, msec); Hm. Should we measure the actual time spent sleeping, or is a rough estimate good enough? I believe pg_usleep() might return early (e.g., if the process is signaled) or late, so this field could end up being inaccurate, although probably not by much. If we're okay with millisecond granularity, my first instinct is that what you've proposed is fine, but I figured I'd bring it up anyway. -- nathan