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 1pZZcT-0004NT-47 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Mar 2023 15:52:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZZcR-0008Uc-IC for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Mar 2023 15:52:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZZcR-0008US-8e for pgsql-hackers@lists.postgresql.org; Tue, 07 Mar 2023 15:52:51 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pZZcG-000682-R7 for pgsql-hackers@postgresql.org; Tue, 07 Mar 2023 15:52:46 +0000 Received: by mail-wr1-x429.google.com with SMTP id r18so12619026wrx.1 for ; Tue, 07 Mar 2023 07:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678204359; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=UT2boHFPmf17w2vznM9mZuJo+rdvSKNy2m6fs298eYo=; b=Osvdq2nVQH/UOQDdvounG2/axNEd9VONM7uIqysga1Af7RmncaU50+dV/2hf9cV2fX GWmmc4z8ObBHKbjmWtHOEeuyVSxPUTl2wlEP5xfkcEeov4QIrunuRXGpMlJaaZiF4SPb uSaA8+xuh4CVEa1E0YM7eFncXuwgeHA2LSfdumdQa4/8VSOsQpHgFJi3TNBpHBvNO63n m3iMyBBbsu8QDpjwWFgX59UNNEhFhbCgxVgqTqcZDr9xRQmUJq0ZuiPxL+jhohWs38J6 Av0H8i0nen6B02xKwN/fR7H/52jiplG5GzLSTtTCxlBlH1MdHIClvmi/y2hfJCvxlXhF TrMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678204359; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UT2boHFPmf17w2vznM9mZuJo+rdvSKNy2m6fs298eYo=; b=v2pDKDOe7NUroa7uQGTKlWK2Fu9tU2ZpRkeS5z7DyaBHC9pNXyZvFL1kvBJCmwH1nS QGPaWjQgbSciwMZiKE61XPRhFBWgH4K+7cKy1vhk+3B40njrLA5nESE62vCqX55FGTS1 /0r+5HLM/o/VPqaFbG0959+QVQs/H6IKW1YDuJ1X011HPDI1o3oboRP/oeqKu+h8k2fg jc4BJ4VXXDkyWyKqBLC5WBa4MJ3UZoD7Z6vAnnLoixH4vJ0ap49uY8epdJGR2NnVKhZ3 RkUSUXIFZGm8pWaELvX9X9Ekwx7RQOj8V/7/H80ujS8Kaum7MYISa+4N4te0t4aMctai Djng== X-Gm-Message-State: AO0yUKXLHR/aSruUqGOsX47qmTb9RMXfRu//5myJ1DPJdIvENXzcXvDJ E+y3WynJVFjY6vozHbSnjIE= X-Google-Smtp-Source: AK7set/3wy4TvwD4Vx9dPH6U4ElYnpv+UPASqky6DBe1MrYBnddkFKgu4PUIAhjIEue9AQLSmOxTGw== X-Received: by 2002:adf:ff92:0:b0:2c9:6562:232b with SMTP id j18-20020adfff92000000b002c96562232bmr8822837wrr.2.1678204359390; Tue, 07 Mar 2023 07:52:39 -0800 (PST) Received: from [192.168.15.209] ([54.239.6.185]) by smtp.gmail.com with ESMTPSA id o14-20020a5d408e000000b002bfd524255esm12883668wrp.43.2023.03.07.07.52.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Mar 2023 07:52:38 -0800 (PST) Message-ID: Date: Tue, 7 Mar 2023 16:52:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: Track IO times in pg_stat_io Content-Language: en-US To: Melanie Plageman Cc: Pg Hackers , Maciek Sakrejda , Justin Pryzby , smilingsamay@gmail.com, Kyotaro Horiguchi , Lukas Fittl , Magnus Hagander , Andres Freund , Alvaro Herrera References: From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 3/6/23 5:30 PM, Melanie Plageman wrote: > Thanks for the review! > > On Tue, Feb 28, 2023 at 4:49 AM Drouvot, Bertrand > wrote: >> On 2/26/23 5:03 PM, Melanie Plageman wrote: >>> The timings will only be non-zero when track_io_timing is on >> >> That could lead to incorrect interpretation if one wants to divide the timing per operations, say: >> >> - track_io_timing is set to on while there is already operations >> - or set to off while it was on (and the number of operations keeps growing) >> >> Might be worth to warn/highlight in the "track_io_timing" doc? > > This is a good point. I've added a note to the docs for pg_stat_io. Thanks! Now I've a second thought: what do you think about resetting the related number of operations and *_time fields when enabling/disabling track_io_timing? (And mention it in the doc). That way it'd prevent bad interpretation (at least as far the time per operation metrics are concerned). Thinking that way as we'd loose some (most?) benefits of the new *_time columns if one can't "trust" their related operations and/or one is not sampling pg_stat_io frequently enough (to discard the samples where the track_io_timing changes occur). But well, resetting the operations could also lead to bad interpretation about the operations... Not sure about which approach I like the most yet, what do you think? >> That leads to pgstat_count_io_time() to be called before pgstat_count_io_op() (for the IOOP_EXTEND case) and >> after pgstat_count_io_op() (for the IOOP_READ case). >> >> What about calling them in the same order and so that pgstat_count_io_time() is called before pgstat_count_io_op()? >> >> If so, the ordering would also need to be changed in: >> >> - FlushRelationBuffers() >> - register_dirty_segment() > > Yes, good point. I've updated the code to use this suggested ordering in > attached v3. > Thanks, this looks good to me. >> As pgstat_bktype_io_stats_valid() is called only in Assert(), I think that would be a good idea >> to also check that if counts are not Zero then times are not Zero. > > Yes, I think adding some validation around the relationship between > counts and timing should help prevent developers from forgetting to call > pg_stat_count_io_op() when calling pgstat_count_io_time() (as relevant). > > However, I think that we cannot check that if IO counts are non-zero > that IO times are non-zero, because the user may not have > track_io_timing enabled. Yeah, right. > We can check that if IO times are not zero, IO > counts are not zero. I've done this in the attached v3. > Thanks, looks good to me. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com