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 1tL12E-00C95e-No for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Dec 2024 14:16:22 +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 1tL12C-005G7v-5L for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Dec 2024 14:16:21 +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 1tL12B-005G7n-Rw for pgsql-hackers@lists.postgresql.org; Tue, 10 Dec 2024 14:16:21 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tL12A-0025rJ-8q for pgsql-hackers@lists.postgresql.org; Tue, 10 Dec 2024 14:16:19 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso3015830f8f.2 for ; Tue, 10 Dec 2024 06:16:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733840177; x=1734444977; darn=lists.postgresql.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=6YZr9bCnLAcvFfsQntgPNncDo/1cqRnoh8MYNRotl9Q=; b=AQIn4qaajWVQGKJmq9Nm5Hc1IJHvs+T4/tbgR2REDa040OET8JVVwlq7QFEdu8eUY+ Msp3m+9OJArQV8yh8a1WFZBjgrl2BABWRqqj5tt5S68gaHSzreYlfkoTrMWbACw2bNKP nTfBcY7WHdwJZuudgeQ0RGIhCYUEzydLSSZTuppEAr044nAJEcBNMQeWGtjq6GqIV5yg ZUgarY7Vb/qSBQTO14IlZFK8fixmGoIBacCLZRTrOmkdAXg5fWaHIXurwJR2rPr09bMc dGk40tBq/+zJ12nzTztj0YJzphsoJbnYXfbS5pkH2qbgAoU3lrzXk0gHb829FmmVbTjv 80fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733840177; x=1734444977; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6YZr9bCnLAcvFfsQntgPNncDo/1cqRnoh8MYNRotl9Q=; b=wCMOfzCE9lCnAAReq4JPWg3g1a6dBfNXq2ZsK/7aQ3uGUELw9VDHnyXT8GQJDrOWM5 PC2lsczW3SKsZFYDQ9WZ2mbwNSZ+9m59NBSZM7/gbqusX4XbTtr3xFehdPSRsCOdL5XR p8Dvvo3DNKYLqRs/GgBp7cPJk0yXCpLnPxj7/CGJApXIVDbRbwRjnRWdpZkPcnIDix8m Lfm6czAtw4Rotqt9Qng9jUXHLQLZJQDxXyj2cYNWT64Xrc+tiDEJLOSTBlernj70lcPb Khj6Lv/THiIifzi8SkSdYmd4xOSpDBghEkUMsoqgGhwhZhQ4fkrvYjD7HV5Dq6zrtFSy zk4A== X-Gm-Message-State: AOJu0YxHjdzW9PK3hCTl3zqisL+gAiqkKXBIJ4jDIhJsmUt5Cz3KTI6M 8JZmkg/O0G0UEpnqU6McndhNMa1MMgmXkcSzZ+WlrQweMVjlEBRstbst3A== X-Gm-Gg: ASbGncv9+3/YH1Fxdq8IUPhiCYxP2mFX34lpQyZQ0KCnCNTLeygPzOnzLOrYqd0znM6 vZqkFD04nkUGIDxhliGBbZadykFQDuI1i9Sd7vcxAE7G4UARzbBplvJfgfiXbqI1pFSD/6QjmEE O6I0fWVfy/nu4ZYZNWXHQGIuDQ/w26yB4ucMVDeqBie6zPBH/ec+IScBTFpZQK+hHL8h4zG1nGf xIJXzMgcdSZ4cB+nsZVVByuYvEYVHTp0CmdH/LauDiOeduqujFgqZKJLvPssrs1wup1xRfgxwjn CY1f0XHxWc43l5kkgAccktT4sww3IvTK6eUOMJ0Kg0K3gP51768OahgbuxP544lBa7UHqGl6Tcu Q67q3 X-Google-Smtp-Source: AGHT+IEBr35lD2uwSNyZ9Pnzfu62d/NJm3BOz0r00hwtch/unI2mWH3wS9p9Dm8jThH/7dRhM/TjOA== X-Received: by 2002:a5d:5f53:0:b0:385:ee3f:5cbf with SMTP id ffacd0b85a97d-386453da317mr4178193f8f.20.1733840176404; Tue, 10 Dec 2024 06:16:16 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861fd46f1bsm15931059f8f.61.2024.12.10.06.16.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 06:16:15 -0800 (PST) Date: Tue, 10 Dec 2024 14:16:14 +0000 From: Bertrand Drouvot To: pgsql-hackers@lists.postgresql.org Subject: Fix comments related to pending statistics Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HrBDImPwWgLa2wMJ" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --HrBDImPwWgLa2wMJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi hackers, while working on [1], I came across 2 comments in pgstat.h that I think are not correct. 1. One linked to PgStat_TableCounts pending stats, mentioning the use of memcmp() against zeroes to detect whether there are any stats updates to apply. This is not true anymore as of 07e9e28b56. 2. One linked to PgStat_FunctionCounts pending stats, mentioning the use of memcmp() against zeroes to detect whether there are any pending stats: I think it has never been the case. Please find attached a patch to fix those comments. [1]: https://www.postgresql.org/message-id/flat/ZlGYokUIlERemvpB%40ip-10-97-1-34.eu-west-3.compute.internal Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com --HrBDImPwWgLa2wMJ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-Fix-comments-related-to-pending-statistics.patch" From a7a026fa0f183bf4d66d85ea05463b69422d20a8 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot Date: Tue, 10 Dec 2024 12:11:35 +0000 Subject: [PATCH v1] Fix comments related to pending statistics The comment linked to the PgStat_TableCounts pending stats mentioning the use of memcmp() against zeroes to detect whether there are any stats updates to apply is not true anymore as of 07e9e28b56. The one linked to memcmp() usage for the PgStat_FunctionCounts pending stats has probably never been correct. --- src/include/pgstat.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 100.0% src/include/ diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 59c28b4aca..795e45653e 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -128,8 +128,8 @@ typedef int64 PgStat_Counter; /* ---------- * PgStat_FunctionCounts The actual per-function counts kept by a backend * - * This struct should contain only actual event counters, because we memcmp - * it against zeroes to detect whether there are any pending stats. + * This struct should contain only actual event counters, because pending stats + * always has non-zero content. * * Note that the time counters are in instr_time format here. We convert to * microseconds in PgStat_Counter format when flushing out pending statistics. @@ -172,8 +172,9 @@ typedef struct PgStat_BackendSubEntry /* ---------- * PgStat_TableCounts The actual per-table counts kept by a backend * - * This struct should contain only actual event counters, because we memcmp - * it against zeroes to detect whether there are any stats updates to apply. + * This struct should contain only actual event counters, because we make use + * of pg_memory_is_all_zeros() to detect whether there are any stats updates to + * apply. * It is a component of PgStat_TableStatus (within-backend state). * * Note: for a table, tuples_returned is the number of tuples successfully -- 2.34.1 --HrBDImPwWgLa2wMJ--