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 1qPAlm-00ABxp-Pz for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jul 2023 23:51:46 +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 1qPAlj-00CQo3-EF for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jul 2023 23:51:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qPAlj-00CQnv-4p for pgsql-hackers@lists.postgresql.org; Thu, 27 Jul 2023 23:51:43 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qPAlg-000mRY-Ak for pgsql-hackers@postgresql.org; Thu, 27 Jul 2023 23:51:42 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-55ba5bb0bf3so962609a12.1 for ; Thu, 27 Jul 2023 16:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690501898; x=1691106698; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=cA9UAEa+rqjhIuVuTgCH6TELkq7RJwyd+2LjPvoNzAk=; b=M57T8N5CSoEoh+4NWgyMG/vRP5e53SLo64InAjOCqfd2ma7ZiOvGryqx8dsMaRxKam Ngv6b0tBjCIDFmIn/FetbuvV0r+5aADKx1eRIwQR0sVLe+A/7h9M4hleTPaArP6R0xi0 pk1Na5lOHCvrrC6CAYCH8zpbNCWjAeYSa3IRilm1Gq+iGM1OO6NoI25/emdCKQfnojSf sJMSkmXaBwrg0TkqfGNhnT47/RwqwFGopnAFFXdeN+q61s9IZvJD8IPcyDRt0qn4uKKB uSsVXlkTDkeHouFnnI0hgMeMkk9gYMAQhB+2LC7k/aWv6oGuoPbIpCmBUIfC/EkZWQ+K tX6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690501898; x=1691106698; 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=cA9UAEa+rqjhIuVuTgCH6TELkq7RJwyd+2LjPvoNzAk=; b=OrryQ7rwZ7OH98o7HEwoTtc5UpuTmwIk3vxaonkAbHBP/dniokqRdPHVcwK3wGnloM gkNKv0B/EhizrUDuvfEjoplijx7kk7wJvD56dTCpY2uoQbos9ZMTL2RMxw1b4HM4EZiO sXSpAk8isuGMCNMTl0dTkHWUlmu7z3s6iVX5xTNm3Jyp9q8B1TlX2Vn2lRgQjk+jcLck g3u5E223sutMLU4cyWXDUHHjk6HhnGUEK0K+iZqi1xqFalPBg+b6KIabJmUzipcuTnu6 A6F8TpYokrCzYblDDob4t2YjVe+wCkZVoQIiBKJjUkp9EAfbSqcP0IXhU+p8/+H88Sh/ HyCA== X-Gm-Message-State: ABy/qLYSuurEa2D2SjShhTaXJLe1gbOgragPIaSwMR6OpgBUto6cTFdh oi3cesMlt0Ks1K7wMGt78Rye+Vm6OsU= X-Google-Smtp-Source: APBJJlGaBuQMJ15Q/o2eAJbqn63oYJxuHSFXCAoEi1fUnMu/uvR48EisTa42eT58pGfDRNszQ7IxbQ== X-Received: by 2002:a17:90b:2387:b0:268:2862:7414 with SMTP id mr7-20020a17090b238700b0026828627414mr220184pjb.0.1690501897718; Thu, 27 Jul 2023 16:51:37 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id d32-20020a17090a6f2300b00267b38f5e13sm1782594pjk.2.2023.07.27.16.51.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 16:51:36 -0700 (PDT) Date: Thu, 27 Jul 2023 16:51:34 -0700 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: add timing information to pg_upgrade Message-ID: <20230727235134.GA3658499@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I've been looking into some options for reducing the amount of downtime required for pg_upgrade, and $SUBJECT seemed like something that would be worthwhile independent of that effort. The attached work-in-progress patch adds the elapsed time spent in each step, which looks like this: Performing Consistency Checks ----------------------------- Checking cluster versions ok (took 0 ms) Checking database user is the install user ok (took 3 ms) Checking database connection settings ok (took 4 ms) Checking for prepared transactions ok (took 2 ms) Checking for system-defined composite types in user tables ok (took 82 ms) Checking for reg* data types in user tables ok (took 55 ms) ... This information can be used to better understand where the time is going and to validate future improvements. I'm open to suggestions on formatting the timing information, assuming folks are interested in this idea. Thoughts? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --gBBFr7Ir9EOA20Yy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-add-timing-information-to-pg_upgrade.patch" From bd3fa72e58d7e9de5a4a0248895531b955ae99b4 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Thu, 27 Jul 2023 16:16:45 -0700 Subject: [PATCH v1 1/1] add timing information to pg_upgrade --- src/bin/pg_upgrade/util.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index 21ba4c8f12..d1b506a741 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -16,6 +16,8 @@ LogOpts log_opts; +static struct timeval step_start; + static void pg_log_v(eLogType type, const char *fmt, va_list ap) pg_attribute_printf(2, 0); @@ -137,6 +139,8 @@ prep_status(const char *fmt,...) /* trim strings */ pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message); + + gettimeofday(&step_start, NULL); } /* @@ -170,6 +174,8 @@ prep_status_progress(const char *fmt,...) pg_log(PG_REPORT, "%-*s", MESSAGE_WIDTH, message); else pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message); + + gettimeofday(&step_start, NULL); } static void @@ -283,8 +289,19 @@ pg_fatal(const char *fmt,...) void check_ok(void) { + struct timeval step_end; + int64 elapsed_ms; + int64 start_ms; + int64 end_ms; + + gettimeofday(&step_end, NULL); + + start_ms = (step_start.tv_sec * 1000L) + (step_start.tv_usec / 1000L); + end_ms = (step_end.tv_sec * 1000L) + (step_end.tv_usec / 1000L); + elapsed_ms = end_ms - start_ms; + /* all seems well */ - report_status(PG_REPORT, "ok"); + report_status(PG_REPORT, "ok (took %ld ms)", elapsed_ms); } -- 2.25.1 --gBBFr7Ir9EOA20Yy--