public inbox for [email protected]help / color / mirror / Atom feed
[PATCH] Clean up pg_checksums.sgml 13+ messages / 4 participants [nested] [flat]
* [PATCH] Clean up pg_checksums.sgml @ 2019-03-29 00:20 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Justin Pryzby @ 2019-03-29 00:20 UTC (permalink / raw) --- doc/src/sgml/ref/pg_checksums.sgml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml index 47d4a62..01c65fe 100644 --- a/doc/src/sgml/ref/pg_checksums.sgml +++ b/doc/src/sgml/ref/pg_checksums.sgml @@ -39,15 +39,16 @@ PostgreSQL documentation <application>pg_checksums</application> checks, enables or disables data checksums in a <productname>PostgreSQL</productname> cluster. The server must be shut down cleanly before running - <application>pg_checksums</application>. The exit status is zero if there - are no checksum errors when checking them, and nonzero if at least one - checksum failure is detected. If enabling or disabling checksums, the + <application>pg_checksums</application>. When verifying checksums, the exit + status is zero if there are no checksum errors, and nonzero if at least one + checksum failure is detected. When enabling or disabling checksums, the exit status is nonzero if the operation failed. </para> <para> - While checking or enabling checksums needs to scan or write every file in - the cluster, disabling checksums will only update the file + When verifying checksums, every file in the cluster is scanned; + When enabling checksums, every file in the cluster is also rewritten. + Disabling checksums only updates the file <filename>pg_control</filename>. </para> </refsect1> @@ -218,10 +219,9 @@ PostgreSQL documentation </para> <para> If <application>pg_checksums</application> is aborted or killed while - enabling or disabling checksums, the cluster will keep the same - configuration for data checksums as before the operation attempted. - <application>pg_checksums</application> can be restarted to - attempt again the same operation. + enabling or disabling checksums, the cluster's checksum state will be + unchanged, and <application>pg_checksums</application> would need to be + rerun and start its operation from scratch. </para> </refsect1> </refentry> -- 2.1.4 --WYTEVAkct0FjGQmd-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH] Clean up pg_checksums.sgml @ 2019-03-29 00:20 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Justin Pryzby @ 2019-03-29 00:20 UTC (permalink / raw) --- doc/src/sgml/ref/pg_checksums.sgml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_checksums.sgml b/doc/src/sgml/ref/pg_checksums.sgml index c60695d..9433782 100644 --- a/doc/src/sgml/ref/pg_checksums.sgml +++ b/doc/src/sgml/ref/pg_checksums.sgml @@ -39,15 +39,16 @@ PostgreSQL documentation <application>pg_checksums</application> verifies, enables or disables data checksums in a <productname>PostgreSQL</productname> cluster. The server must be shut down cleanly before running - <application>pg_checksums</application>. The exit status is zero if there - are no checksum errors when checking them, and nonzero if at least one - checksum failure is detected. If enabling or disabling checksums, the + <application>pg_checksums</application>. When verifying checksums, the exit + status is zero if there are no checksum errors, and nonzero if at least one + checksum failure is detected. When enabling or disabling checksums, the exit status is nonzero if the operation failed. </para> <para> - While verifying or enabling checksums needs to scan or write every file in - the cluster, disabling checksums will only update the file + When verifying checksums, every file in the cluster is scanned; + When enabling checksums, every file in the cluster is also rewritten. + Disabling checksums only updates the file <filename>pg_control</filename>. </para> </refsect1> @@ -195,11 +196,10 @@ PostgreSQL documentation safe. </para> <para> - If <application>pg_checksums</application> is aborted or killed while - enabling or disabling checksums, the cluster will keep the same - configuration for data checksums as before the operation attempted. - <application>pg_checksums</application> can be restarted to - attempt again the same operation. + If <application>pg_checksums</application> is aborted or killed + while enabling or disabling checksums, the cluster's checksum state + will be unchanged, and <application>pg_checksums</application> would need to + be rerun and start its operation from scratch. </para> </refsect1> </refentry> -- 2.1.4 --wq9mPyueHGvFACwf-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* Add documentation for coverage reports with meson @ 2023-02-28 08:49 Michael Paquier <[email protected]> 0 siblings, 1 reply; 13+ messages in thread From: Michael Paquier @ 2023-02-28 08:49 UTC (permalink / raw) To: Postgres hackers <[email protected]> Hi all, I have mentioned on a different thread of -docs that we have no documentation to achieve $subject, so attached is a patch to add something. This can be done with the following steps: meson setup -Db_coverage=true .. blah ninja meson test ninja coverage-html As far as I can see, there is no option to generate anything else than a HTML report? This portion is telling the contrary, still it does not seem to work here and ninja does the job with coverage-html or coverage as only available targets: https://mesonbuild.com/howtox.html#producing-a-coverage-report Side issue: the current code generates no reports for the files that are automatically generated in src/backend/nodes/, which are actually part of src/include/ for a meson build. I have not looked into that yet. Thoughts? -- Michael Attachments: [text/x-diff] meson-coverage-docs.patch (3.8K, ../../Y%2F3AI+%2FMqKcjLk%[email protected]/2-meson-coverage-docs.patch) download | inline diff: diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index a08c7a78af..dd9a004a6d 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -825,53 +825,76 @@ PG_TEST_NOCLEAN=1 make -C src/bin/pg_dump check instrumentation, so that it becomes possible to examine which parts of the code are covered by the regression tests or any other test suite that is run with the code. This is currently supported - when compiling with GCC, and it requires the <command>gcov</command> - and <command>lcov</command> programs. + when compiling with GCC, and it requires the <command>gcov</command>, + <command>lcov</command> and <command>genhtml</command> programs. </para> - <para> - A typical workflow looks like this: + <sect2 id="regress-coverage-configure"> + <title>Coverage with <filename>configure</filename></title> + <para> + A typical workflow looks like this: <screen> ./configure --enable-coverage ... OTHER OPTIONS ... make make check # or other test suite make coverage-html </screen> - Then point your HTML browser - to <filename>coverage/index.html</filename>. - </para> + Then point your HTML browser + to <filename>coverage/index.html</filename>. + </para> - <para> - If you don't have <command>lcov</command> or prefer text output over an - HTML report, you can run + <para> + If you don't have <command>lcov</command> or prefer text output over an + HTML report, you can run <screen> make coverage </screen> - instead of <literal>make coverage-html</literal>, which will - produce <filename>.gcov</filename> output files for each source file - relevant to the test. (<literal>make coverage</literal> and <literal>make - coverage-html</literal> will overwrite each other's files, so mixing them - might be confusing.) - </para> + instead of <literal>make coverage-html</literal>, which will + produce <filename>.gcov</filename> output files for each source file + relevant to the test. (<literal>make coverage</literal> and <literal>make + coverage-html</literal> will overwrite each other's files, so mixing them + might be confusing.) + </para> - <para> - You can run several different tests before making the coverage report; - the execution counts will accumulate. If you want - to reset the execution counts between test runs, run: + <para> + You can run several different tests before making the coverage report; + the execution counts will accumulate. If you want + to reset the execution counts between test runs, run: <screen> make coverage-clean </screen> - </para> + </para> - <para> - You can run the <literal>make coverage-html</literal> or <literal>make - coverage</literal> command in a subdirectory if you want a coverage - report for only a portion of the code tree. - </para> + <para> + You can run the <literal>make coverage-html</literal> or <literal>make + coverage</literal> command in a subdirectory if you want a coverage + report for only a portion of the code tree. + </para> - <para> - Use <literal>make distclean</literal> to clean up when done. - </para> + <para> + Use <literal>make distclean</literal> to clean up when done. + </para> + </sect2> + + <sect2 id="regress-coverage-meson"> + <title>Coverage with <filename>meson</filename></title> + <para> + A typical workflow looks like this: +<screen> +meson setup -Db_coverage=true ... OTHER OPTIONS ... +ninja +meson test +ninja coverage-html +</screen> + Then point your HTML browser + to <filename>./meson-logs/coveragereport/index.html</filename>. + </para> + + <para> + You can run several different tests before making the coverage report; + the execution counts will accumulate. + </para> + </sect2> </sect1> </chapter> [application/pgp-signature] signature.asc (833B, ../../Y%2F3AI+%2FMqKcjLk%[email protected]/3-signature.asc) download ^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: Add documentation for coverage reports with meson @ 2023-03-03 09:10 Peter Eisentraut <[email protected]> parent: Michael Paquier <[email protected]> 0 siblings, 1 reply; 13+ messages in thread From: Peter Eisentraut @ 2023-03-03 09:10 UTC (permalink / raw) To: Michael Paquier <[email protected]>; Postgres hackers <[email protected]> On 28.02.23 09:49, Michael Paquier wrote: > - when compiling with GCC, and it requires the <command>gcov</command> > - and <command>lcov</command> programs. > + when compiling with GCC, and it requires the <command>gcov</command>, > + <command>lcov</command> and <command>genhtml</command> programs. genhtml is part of the lcov package. I think it would be confusing to mention it explicitly, since you won't be able to find it as something to install. Maybe leave the original list and change "programs" to "packages"? > - <para> > - A typical workflow looks like this: > + <sect2 id="regress-coverage-configure"> > + <title>Coverage with <filename>configure</filename></title> > + <para> > + A typical workflow looks like this: In the installation chapter we use titles like "Building and Installation with Autoconf and Make" and "Building and Installation with Meson". We should use analogous wordings here. > + <para> > + A typical workflow looks like this: > +<screen> > +meson setup -Db_coverage=true ... OTHER OPTIONS ... > +ninja > +meson test > +ninja coverage-html > +</screen> > + Then point your HTML browser > + to <filename>./meson-logs/coveragereport/index.html</filename>. > + </para> This ignores which directory you have to be in. The meson calls have to be at the top level, the ninja calls have to be in the build directory. We should be more precise here, otherwise someone trying this will find that it doesn't work. Personally I use "meson compile" instead of "ninja"; I'm not sure what the best recommendation is, but that least that way all the initial commands are "meson something" instead of going back and forth. ^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: Add documentation for coverage reports with meson @ 2023-03-03 11:12 Michael Paquier <[email protected]> parent: Peter Eisentraut <[email protected]> 0 siblings, 1 reply; 13+ messages in thread From: Michael Paquier @ 2023-03-03 11:12 UTC (permalink / raw) To: Peter Eisentraut <[email protected]>; +Cc: Postgres hackers <[email protected]> On Fri, Mar 03, 2023 at 10:10:15AM +0100, Peter Eisentraut wrote: > genhtml is part of the lcov package. I think it would be confusing to > mention it explicitly, since you won't be able to find it as something to > install. Maybe leave the original list and change "programs" to "packages"? Makes sense. > In the installation chapter we use titles like "Building and Installation > with Autoconf and Make" and "Building and Installation with Meson". We > should use analogous wordings here. OK, changed to something like that. > This ignores which directory you have to be in. The meson calls have to be > at the top level, the ninja calls have to be in the build directory. We > should be more precise here, otherwise someone trying this will find that it > doesn't work. Hmm. I can see that it is possible to pass the repository to move to with -C, still it is simpler to move into the build repository. > Personally I use "meson compile" instead of "ninja"; I'm not sure what the > best recommendation is, but that least that way all the initial commands are > "meson something" instead of going back and forth. Using meson compile is fine by me for the docs. Note that I cannot see an option with meson to do coverage reports, and my environment uses 1.0.1. Only ninja handles that. Updated version attached. -- Michael Attachments: [text/x-diff] meson-coverage-docs-v2.patch (3.8K, ../../[email protected]/2-meson-coverage-docs-v2.patch) download | inline diff: diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index a08c7a78af..344c834280 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -825,53 +825,77 @@ PG_TEST_NOCLEAN=1 make -C src/bin/pg_dump check instrumentation, so that it becomes possible to examine which parts of the code are covered by the regression tests or any other test suite that is run with the code. This is currently supported - when compiling with GCC, and it requires the <command>gcov</command> - and <command>lcov</command> programs. + when compiling with GCC, and it requires the <literal>gcov</literal> + and <literal>lcov</literal> packages. </para> - <para> - A typical workflow looks like this: + <sect2 id="regress-coverage-configure"> + <title>Coverage with Autoconf and Make</title> + <para> + A typical workflow looks like this: <screen> ./configure --enable-coverage ... OTHER OPTIONS ... make make check # or other test suite make coverage-html </screen> - Then point your HTML browser - to <filename>coverage/index.html</filename>. - </para> + Then point your HTML browser + to <filename>coverage/index.html</filename>. + </para> - <para> - If you don't have <command>lcov</command> or prefer text output over an - HTML report, you can run + <para> + If you don't have <command>lcov</command> or prefer text output over an + HTML report, you can run <screen> make coverage </screen> - instead of <literal>make coverage-html</literal>, which will - produce <filename>.gcov</filename> output files for each source file - relevant to the test. (<literal>make coverage</literal> and <literal>make - coverage-html</literal> will overwrite each other's files, so mixing them - might be confusing.) - </para> + instead of <literal>make coverage-html</literal>, which will + produce <filename>.gcov</filename> output files for each source file + relevant to the test. (<literal>make coverage</literal> and <literal>make + coverage-html</literal> will overwrite each other's files, so mixing them + might be confusing.) + </para> - <para> - You can run several different tests before making the coverage report; - the execution counts will accumulate. If you want - to reset the execution counts between test runs, run: + <para> + You can run several different tests before making the coverage report; + the execution counts will accumulate. If you want + to reset the execution counts between test runs, run: <screen> make coverage-clean </screen> - </para> + </para> - <para> - You can run the <literal>make coverage-html</literal> or <literal>make - coverage</literal> command in a subdirectory if you want a coverage - report for only a portion of the code tree. - </para> + <para> + You can run the <literal>make coverage-html</literal> or <literal>make + coverage</literal> command in a subdirectory if you want a coverage + report for only a portion of the code tree. + </para> - <para> - Use <literal>make distclean</literal> to clean up when done. - </para> + <para> + Use <literal>make distclean</literal> to clean up when done. + </para> + </sect2> + + <sect2 id="regress-coverage-meson"> + <title>Coverage with Meson</title> + <para> + A typical workflow looks like this: +<screen> +meson setup -Db_coverage=true ... OTHER OPTIONS ... builddir/ +cd builddir/ +meson compile +meson test +ninja coverage-html +</screen> + Then point your HTML browser + to <filename>./meson-logs/coveragereport/index.html</filename>. + </para> + + <para> + You can run several different tests before making the coverage report; + the execution counts will accumulate. + </para> + </sect2> </sect1> </chapter> [application/pgp-signature] signature.asc (833B, ../../[email protected]/3-signature.asc) download ^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: Add documentation for coverage reports with meson @ 2023-03-08 16:23 Peter Eisentraut <[email protected]> parent: Michael Paquier <[email protected]> 0 siblings, 1 reply; 13+ messages in thread From: Peter Eisentraut @ 2023-03-08 16:23 UTC (permalink / raw) To: Michael Paquier <[email protected]>; +Cc: Postgres hackers <[email protected]> On 03.03.23 12:12, Michael Paquier wrote: > +<screen> > +meson setup -Db_coverage=true ... OTHER OPTIONS ... builddir/ > +cd builddir/ > +meson compile > +meson test > +ninja coverage-html > +</screen> The "cd" command needs to be moved after the meson commands, and the meson commands need to have a -C builddir option. So it should be like <screen> meson setup -Db_coverage=true ... OTHER OPTIONS ... builddir/ meson compile -C builddir meson test -C builddir cd builddir/ ninja coverage-html </screen> Otherwise, this looks good to me. ^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: Add documentation for coverage reports with meson @ 2023-03-09 00:25 Michael Paquier <[email protected]> parent: Peter Eisentraut <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Michael Paquier @ 2023-03-09 00:25 UTC (permalink / raw) To: Peter Eisentraut <[email protected]>; +Cc: Postgres hackers <[email protected]> On Wed, Mar 08, 2023 at 05:23:48PM +0100, Peter Eisentraut wrote: > The "cd" command needs to be moved after the meson commands, and the meson > commands need to have a -C builddir option. Still that's not mandatory, is it? The compile and test commands of meson work as well if you are located at the root of the build directory, AFAIK. > So it should be like > > <screen> > meson setup -Db_coverage=true ... OTHER OPTIONS ... builddir/ > meson compile -C builddir > meson test -C builddir > cd builddir/ > ninja coverage-html > </screen> > > Otherwise, this looks good to me. Anyway, this works as well and I don't have any arguments against that. So I have used your flow, and applied the patch. I have actually switched my own scripts to rely more on -C, removing direct calls to ninja ;p Thanks for the feedback. -- Michael Attachments: [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc) download ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH v3 2/2] add timing information to pg_upgrade @ 2023-07-27 23:16 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Nathan Bossart @ 2023-07-27 23:16 UTC (permalink / raw) --- src/bin/pg_upgrade/util.c | 55 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index 21ba4c8f12..23fd5f87af 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -9,14 +9,19 @@ #include "postgres_fe.h" +#include <math.h> #include <signal.h> #include "common/username.h" #include "pg_upgrade.h" +#include "portability/instr_time.h" LogOpts log_opts; +static instr_time step_start; + static void pg_log_v(eLogType type, const char *fmt, va_list ap) pg_attribute_printf(2, 0); +static char *get_time_str(double time_ms); /* @@ -137,6 +142,8 @@ prep_status(const char *fmt,...) /* trim strings */ pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message); + + INSTR_TIME_SET_CURRENT(step_start); } /* @@ -170,6 +177,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); + + INSTR_TIME_SET_CURRENT(step_start); } static void @@ -280,11 +289,55 @@ pg_fatal(const char *fmt,...) } +static char * +get_time_str(double time_ms) +{ + double seconds; + double minutes; + double hours; + double days; + + if (time_ms < 1000.0) + return psprintf(_("%.3f ms"), time_ms); + + seconds = time_ms / 1000.0; + minutes = floor(seconds / 60.0); + seconds -= 60.0 * minutes; + if (minutes < 60.0) + return psprintf(_("%.3f ms (%02d:%06.3f)"), + time_ms, (int) minutes, seconds); + + hours = floor(minutes / 60.0); + minutes -= 60.0 * hours; + if (hours < 24.0) + return psprintf(_("%.3f ms (%02d:%02d:%06.3f)"), + time_ms, (int) hours, (int) minutes, seconds); + + days = floor(hours / 24.0); + hours -= 24.0 * days; + return psprintf(_("%.3f ms (%.0f d %02d:%02d:%06.3f)"), + time_ms, days, (int) hours, (int) minutes, seconds); +} + + void check_ok(void) { + instr_time step_end; + char *step_time; + + Assert(!INSTR_TIME_IS_ZERO(step_start)); + + INSTR_TIME_SET_CURRENT(step_end); + INSTR_TIME_SUBTRACT(step_end, step_start); + step_time = get_time_str(INSTR_TIME_GET_MILLISEC(step_end)); + + /* reset start time */ + INSTR_TIME_SET_ZERO(step_start); + /* all seems well */ - report_status(PG_REPORT, "ok"); + report_status(PG_REPORT, "ok\t%s", step_time); + pfree(step_time); } -- 2.25.1 --AhhlLboLdkugWU4S-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH v1 1/1] add timing information to pg_upgrade @ 2023-07-27 23:16 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Nathan Bossart @ 2023-07-27 23:16 UTC (permalink / raw) --- 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-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH v2 1/1] add timing information to pg_upgrade @ 2023-07-27 23:16 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Nathan Bossart @ 2023-07-27 23:16 UTC (permalink / raw) --- src/bin/pg_upgrade/util.c | 55 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index 21ba4c8f12..25e43a593a 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -9,14 +9,19 @@ #include "postgres_fe.h" +#include <math.h> #include <signal.h> #include "common/username.h" #include "pg_upgrade.h" +#include "portability/instr_time.h" LogOpts log_opts; +static instr_time step_start; + static void pg_log_v(eLogType type, const char *fmt, va_list ap) pg_attribute_printf(2, 0); +static char *get_time_str(double time_ms); /* @@ -137,6 +142,8 @@ prep_status(const char *fmt,...) /* trim strings */ pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message); + + INSTR_TIME_SET_CURRENT(step_start); } /* @@ -170,6 +177,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); + + INSTR_TIME_SET_CURRENT(step_start); } static void @@ -280,11 +289,55 @@ pg_fatal(const char *fmt,...) } +static char * +get_time_str(double time_ms) +{ + double seconds; + double minutes; + double hours; + double days; + + if (time_ms < 1000.0) + return psprintf("%.3f ms", time_ms); + + seconds = time_ms / 1000.0; + minutes = floor(seconds / 60.0); + seconds -= 60.0 * minutes; + if (minutes < 60.0) + return psprintf("%.3f ms (%02d:%06.3f)", + time_ms, (int) minutes, seconds); + + hours = floor(minutes / 60.0); + minutes -= 60.0 * hours; + if (hours < 24.0) + return psprintf("%.3f ms (%02d:%02d:%06.3f)", + time_ms, (int) hours, (int) minutes, seconds); + + days = floor(hours / 24.0); + hours -= 24.0 * days; + return psprintf("%.3f ms (%.0f d %02d:%02d:%06.3f)", + time_ms, days, (int) hours, (int) minutes, seconds); +} + + void check_ok(void) { + instr_time step_end; + char *step_time; + + Assert(!INSTR_TIME_IS_ZERO(step_start)); + + INSTR_TIME_SET_CURRENT(step_end); + INSTR_TIME_SUBTRACT(step_end, step_start); + step_time = get_time_str(INSTR_TIME_GET_MILLISEC(step_end)); + + /* reset start time */ + INSTR_TIME_SET_ZERO(step_start); + /* all seems well */ - report_status(PG_REPORT, "ok"); + report_status(PG_REPORT, "ok\t%s", step_time); + pfree(step_time); } -- 2.25.1 --vtzGhvizbBRQ85DL-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH v3 2/2] add timing information to pg_upgrade @ 2023-07-27 23:16 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Nathan Bossart @ 2023-07-27 23:16 UTC (permalink / raw) --- src/bin/pg_upgrade/util.c | 55 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index 21ba4c8f12..23fd5f87af 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -9,14 +9,19 @@ #include "postgres_fe.h" +#include <math.h> #include <signal.h> #include "common/username.h" #include "pg_upgrade.h" +#include "portability/instr_time.h" LogOpts log_opts; +static instr_time step_start; + static void pg_log_v(eLogType type, const char *fmt, va_list ap) pg_attribute_printf(2, 0); +static char *get_time_str(double time_ms); /* @@ -137,6 +142,8 @@ prep_status(const char *fmt,...) /* trim strings */ pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message); + + INSTR_TIME_SET_CURRENT(step_start); } /* @@ -170,6 +177,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); + + INSTR_TIME_SET_CURRENT(step_start); } static void @@ -280,11 +289,55 @@ pg_fatal(const char *fmt,...) } +static char * +get_time_str(double time_ms) +{ + double seconds; + double minutes; + double hours; + double days; + + if (time_ms < 1000.0) + return psprintf(_("%.3f ms"), time_ms); + + seconds = time_ms / 1000.0; + minutes = floor(seconds / 60.0); + seconds -= 60.0 * minutes; + if (minutes < 60.0) + return psprintf(_("%.3f ms (%02d:%06.3f)"), + time_ms, (int) minutes, seconds); + + hours = floor(minutes / 60.0); + minutes -= 60.0 * hours; + if (hours < 24.0) + return psprintf(_("%.3f ms (%02d:%02d:%06.3f)"), + time_ms, (int) hours, (int) minutes, seconds); + + days = floor(hours / 24.0); + hours -= 24.0 * days; + return psprintf(_("%.3f ms (%.0f d %02d:%02d:%06.3f)"), + time_ms, days, (int) hours, (int) minutes, seconds); +} + + void check_ok(void) { + instr_time step_end; + char *step_time; + + Assert(!INSTR_TIME_IS_ZERO(step_start)); + + INSTR_TIME_SET_CURRENT(step_end); + INSTR_TIME_SUBTRACT(step_end, step_start); + step_time = get_time_str(INSTR_TIME_GET_MILLISEC(step_end)); + + /* reset start time */ + INSTR_TIME_SET_ZERO(step_start); + /* all seems well */ - report_status(PG_REPORT, "ok"); + report_status(PG_REPORT, "ok\t%s", step_time); + pfree(step_time); } -- 2.25.1 --AhhlLboLdkugWU4S-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH v1 1/1] add timing information to pg_upgrade @ 2023-07-27 23:16 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Nathan Bossart @ 2023-07-27 23:16 UTC (permalink / raw) --- 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-- ^ permalink raw reply [nested|flat] 13+ messages in thread
* [PATCH v2 1/1] add timing information to pg_upgrade @ 2023-07-27 23:16 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 13+ messages in thread From: Nathan Bossart @ 2023-07-27 23:16 UTC (permalink / raw) --- src/bin/pg_upgrade/util.c | 55 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index 21ba4c8f12..25e43a593a 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -9,14 +9,19 @@ #include "postgres_fe.h" +#include <math.h> #include <signal.h> #include "common/username.h" #include "pg_upgrade.h" +#include "portability/instr_time.h" LogOpts log_opts; +static instr_time step_start; + static void pg_log_v(eLogType type, const char *fmt, va_list ap) pg_attribute_printf(2, 0); +static char *get_time_str(double time_ms); /* @@ -137,6 +142,8 @@ prep_status(const char *fmt,...) /* trim strings */ pg_log(PG_REPORT_NONL, "%-*s", MESSAGE_WIDTH, message); + + INSTR_TIME_SET_CURRENT(step_start); } /* @@ -170,6 +177,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); + + INSTR_TIME_SET_CURRENT(step_start); } static void @@ -280,11 +289,55 @@ pg_fatal(const char *fmt,...) } +static char * +get_time_str(double time_ms) +{ + double seconds; + double minutes; + double hours; + double days; + + if (time_ms < 1000.0) + return psprintf("%.3f ms", time_ms); + + seconds = time_ms / 1000.0; + minutes = floor(seconds / 60.0); + seconds -= 60.0 * minutes; + if (minutes < 60.0) + return psprintf("%.3f ms (%02d:%06.3f)", + time_ms, (int) minutes, seconds); + + hours = floor(minutes / 60.0); + minutes -= 60.0 * hours; + if (hours < 24.0) + return psprintf("%.3f ms (%02d:%02d:%06.3f)", + time_ms, (int) hours, (int) minutes, seconds); + + days = floor(hours / 24.0); + hours -= 24.0 * days; + return psprintf("%.3f ms (%.0f d %02d:%02d:%06.3f)", + time_ms, days, (int) hours, (int) minutes, seconds); +} + + void check_ok(void) { + instr_time step_end; + char *step_time; + + Assert(!INSTR_TIME_IS_ZERO(step_start)); + + INSTR_TIME_SET_CURRENT(step_end); + INSTR_TIME_SUBTRACT(step_end, step_start); + step_time = get_time_str(INSTR_TIME_GET_MILLISEC(step_end)); + + /* reset start time */ + INSTR_TIME_SET_ZERO(step_start); + /* all seems well */ - report_status(PG_REPORT, "ok"); + report_status(PG_REPORT, "ok\t%s", step_time); + pfree(step_time); } -- 2.25.1 --vtzGhvizbBRQ85DL-- ^ permalink raw reply [nested|flat] 13+ messages in thread
end of thread, other threads:[~2023-07-27 23:16 UTC | newest] Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-03-29 00:20 [PATCH] Clean up pg_checksums.sgml Justin Pryzby <[email protected]> 2019-03-29 00:20 [PATCH] Clean up pg_checksums.sgml Justin Pryzby <[email protected]> 2023-02-28 08:49 Add documentation for coverage reports with meson Michael Paquier <[email protected]> 2023-03-03 09:10 ` Re: Add documentation for coverage reports with meson Peter Eisentraut <[email protected]> 2023-03-03 11:12 ` Re: Add documentation for coverage reports with meson Michael Paquier <[email protected]> 2023-03-08 16:23 ` Re: Add documentation for coverage reports with meson Peter Eisentraut <[email protected]> 2023-03-09 00:25 ` Re: Add documentation for coverage reports with meson Michael Paquier <[email protected]> 2023-07-27 23:16 [PATCH v3 2/2] add timing information to pg_upgrade Nathan Bossart <[email protected]> 2023-07-27 23:16 [PATCH v1 1/1] add timing information to pg_upgrade Nathan Bossart <[email protected]> 2023-07-27 23:16 [PATCH v2 1/1] add timing information to pg_upgrade Nathan Bossart <[email protected]> 2023-07-27 23:16 [PATCH v3 2/2] add timing information to pg_upgrade Nathan Bossart <[email protected]> 2023-07-27 23:16 [PATCH v1 1/1] add timing information to pg_upgrade Nathan Bossart <[email protected]> 2023-07-27 23:16 [PATCH v2 1/1] add timing information to pg_upgrade Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox