From f32a4097c7e0b22f241a86cf0f8754f7f0659228 Mon Sep 17 00:00:00 2001 From: Alexandre Felipe Date: Sun, 15 Nov 2026 05:24:12 +0000 Subject: [v3.0 PATCH 2/5] pg_regress: report group effective concurrency A concurrent group having 20 concurrent tests won't necessarily be 20 times faster than running the tests sequentially, specially if the tests durations are very different, e.g. if one test takes 10x longer than the second longest test most of the time the concurrency is 1, because each test is executed isolated from the rest. This commit measures the effective concurrency of the tests and provide a hint of how much there is to gain from improving test concurrency. --- src/test/regress/pg_regress.c | 40 ++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 3a46d42eea8..034e2ed9be1 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -1882,7 +1882,34 @@ schedule_read_group(_sched *s, char **tests, int *num_tests) } /* - * Run all the tests specified in one schedule file. + * During the test execution the concurrency level varies + * this computes the average concurrency from the moment the + * first test starts to the moment the last test stops. + */ +static void +log_group_concurrency(instr_time *test_start, instr_time *test_stop, + double *grand_total, int num_tests) +{ + double group_start = INSTR_TIME_GET_NANOSEC(test_start[0]); + double group_stop = INSTR_TIME_GET_NANOSEC(test_stop[0]); + double total = (group_stop - group_start); + for(int i = 1; i < num_tests; i++) + { + double t0 = INSTR_TIME_GET_NANOSEC(test_start[i]); + double tf = INSTR_TIME_GET_NANOSEC(test_stop[i]); + if (i == 0 || (t0 < group_start)) + group_start = t0; + if (i == 0 || (tf > group_stop)) + group_stop = tf; + total += tf - t0; + } + *grand_total += total; + if (num_tests > 1) + note("effective concurrency %.2f / %d", total / (group_stop - group_start), num_tests); +} + +/* + * Run all the tests specified in one schedule file */ static void run_schedule(const char *schedule, test_start_function startfunc, @@ -1897,6 +1924,9 @@ run_schedule(const char *schedule, test_start_function startfunc, instr_time stoptimes[MAX_PARALLEL_TESTS]; int statuses[MAX_PARALLEL_TESTS]; _sched rd; + double total_test_time = 0; + instr_time schedule_start_time; + instr_time schedule_stop_time; int num_tests; memset(tests, 0, sizeof(tests)); @@ -1911,6 +1941,7 @@ run_schedule(const char *schedule, test_start_function startfunc, if (!rd.file) bail("could not open file \"%s\" for reading: %m", schedule); + INSTR_TIME_SET_CURRENT(schedule_start_time); while (schedule_read_group(&rd, tests, &num_tests)) { int i; @@ -1957,6 +1988,8 @@ run_schedule(const char *schedule, test_start_function startfunc, note_end(); } + log_group_concurrency(starttimes, stoptimes, &total_test_time, num_tests); + /* Check results for all tests */ for (i = 0; i < num_tests; i++) { @@ -2018,6 +2051,11 @@ run_schedule(const char *schedule, test_start_function startfunc, free_stringlist(&tags[i]); } } + INSTR_TIME_SET_CURRENT(schedule_stop_time); + + note("schedule effective concurrency %.2f", + total_test_time / (INSTR_TIME_GET_NANOSEC(schedule_stop_time) - INSTR_TIME_GET_NANOSEC(schedule_start_time)) + ); fclose(rd.file); } -- 2.53.0