From ef9d52942d753864eb75919819faeb8929df6571 Mon Sep 17 00:00:00 2001 From: Alexandre Felipe Date: Thu, 27 Aug 2026 06:50:32 +0100 Subject: [PATCH 3/9] buffmap multi processing benchmark This should be in the previous patch... --- src/test/modules/microbench/microbench--1.0.sql | 10 ++++++++++ src/test/modules/microbench/randomize.h | 3 +++ src/test/modules/microbench/scripts/run-test.sh | 10 ++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/test/modules/microbench/microbench--1.0.sql b/src/test/modules/microbench/microbench--1.0.sql index 7058f2dfa03..5ab46100669 100644 --- a/src/test/modules/microbench/microbench--1.0.sql +++ b/src/test/modules/microbench/microbench--1.0.sql @@ -81,6 +81,16 @@ AS $$ GROUP BY s.op, s."group" ORDER BY min(s.id), s."group" NULLS FIRST; $$; +CREATE FUNCTION bench_bufmap( + IN n_parallel int4 DEFAULT 1, + IN rounds int8 DEFAULT 1, + IN iterations int8 DEFAULT 128 +) +RETURNS SETOF microbench_sample +AS 'MODULE_PATHNAME', 'bench_bufmap' +LANGUAGE C; + +REVOKE ALL ON FUNCTION bench_bufmap(int4, int8, int8) FROM PUBLIC; CREATE FUNCTION bench_lwlock( IN n_parallel int4 DEFAULT 1, IN rounds int8 DEFAULT 1, diff --git a/src/test/modules/microbench/randomize.h b/src/test/modules/microbench/randomize.h index e6eb3e32542..f497015a79a 100644 --- a/src/test/modules/microbench/randomize.h +++ b/src/test/modules/microbench/randomize.h @@ -6,6 +6,9 @@ /* * Fisher-Yates shuffle of a pointer array. * https://en.wikipedia.org/wiki/Fisher-Yates_shuffle + * + * Integer indexes (e.g. BlockNumber) can be stored in the array as intptr_t + * and shuffled with the same function. */ static inline void shuffle_pointers(pg_prng_state *rng, void **ptrs, int count) diff --git a/src/test/modules/microbench/scripts/run-test.sh b/src/test/modules/microbench/scripts/run-test.sh index 24dc72e648d..f846a17e23c 100755 --- a/src/test/modules/microbench/scripts/run-test.sh +++ b/src/test/modules/microbench/scripts/run-test.sh @@ -4,8 +4,7 @@ # # Usage: run-test.sh TEST # Env: TOP_BUILDDIR, PG_CONFIG, MICROBENCH_PORT (default 55432), -# MICROBENCH_ROUNDS (default 1000), -# MICROBENCH_ITERATIONS or MICROBENCH_N (default 128) +# MICROBENCH_PARAMS # set -euo pipefail @@ -18,8 +17,7 @@ PORT=${MICROBENCH_PORT:-55432} LOGDIR="$MODULE_DIR/.tmp_check/log" DATADIR="$MODULE_DIR/.tmp_check/data" ROUNDS=${MICROBENCH_ROUNDS:-1000} -ITERATIONS=${MICROBENCH_ITERATIONS:-${MICROBENCH_N:-128}} - +MICROBENCH_PARAMS=${MIBROBENCH_PARAMS:""} log() { printf '%s\n' "$*" >&2; } test -f "$MODULE_DIR/$TEST/query.sql" || { @@ -130,7 +128,7 @@ log "==> CREATE EXTENSION microbench" -c "DROP EXTENSION IF EXISTS microbench CASCADE; CREATE EXTENSION microbench;" \ >>"$LOGDIR/psql.log" 2>&1 -log "==> running $TEST/query.sql (rounds=$ROUNDS iterations=$ITERATIONS)" +log "==> running $TEST/query.sql" "$BINDIR/psql" -v ON_ERROR_STOP=1 -p "$PORT" -d postgres \ - -v rounds="$ROUNDS" -v iterations="$ITERATIONS" \ + $MICROBENCH_PARAMS \ -f "$MODULE_DIR/$TEST/query.sql" -- 2.53.0