v28-0008-Measure-iteration-of-tidstore.patch
text/x-patch
Filename: v28-0008-Measure-iteration-of-tidstore.patch
Type: text/x-patch
Part: 8
Patch
Format: format-patch
Series: patch v28-0008
Subject: Measure iteration of tidstore
| File | + | − |
|---|---|---|
| contrib/bench_radix_tree/bench_radix_tree--1.0.sql | 2 | 1 |
| contrib/bench_radix_tree/bench_radix_tree.c | 35 | 5 |
| contrib/meson.build | 1 | 1 |
From 72bb462b1dab005cbc2aff265baedbaaee62cb2b Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Tue, 14 Feb 2023 17:02:53 +0700
Subject: [PATCH v28 08/10] Measure iteration of tidstore
---
.../bench_radix_tree--1.0.sql | 3 +-
contrib/bench_radix_tree/bench_radix_tree.c | 40 ++++++++++++++++---
contrib/meson.build | 2 +-
3 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/contrib/bench_radix_tree/bench_radix_tree--1.0.sql b/contrib/bench_radix_tree/bench_radix_tree--1.0.sql
index fbf51c1086..ad66265e23 100644
--- a/contrib/bench_radix_tree/bench_radix_tree--1.0.sql
+++ b/contrib/bench_radix_tree/bench_radix_tree--1.0.sql
@@ -80,7 +80,8 @@ create function bench_tidstore_load(
minblk int4,
maxblk int4,
OUT mem_allocated int8,
-OUT load_ms int8
+OUT load_ms int8,
+OUT iter_ms int8
)
returns record
as 'MODULE_PATHNAME'
diff --git a/contrib/bench_radix_tree/bench_radix_tree.c b/contrib/bench_radix_tree/bench_radix_tree.c
index b5ad75364c..6e5149e2c4 100644
--- a/contrib/bench_radix_tree/bench_radix_tree.c
+++ b/contrib/bench_radix_tree/bench_radix_tree.c
@@ -176,15 +176,18 @@ bench_tidstore_load(PG_FUNCTION_ARGS)
BlockNumber minblk = PG_GETARG_INT32(0);
BlockNumber maxblk = PG_GETARG_INT32(1);
TidStore *ts;
+ TidStoreIter *iter;
+ TidStoreIterResult *result;
OffsetNumber *offs;
TimestampTz start_time,
end_time;
long secs;
int usecs;
int64 load_ms;
+ int64 iter_ms;
TupleDesc tupdesc;
- Datum values[2];
- bool nulls[2] = {false};
+ Datum values[3];
+ bool nulls[3] = {false};
/* Build a tuple descriptor for our result type */
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
@@ -196,9 +199,6 @@ bench_tidstore_load(PG_FUNCTION_ARGS)
ts = tidstore_create(1 * 1024L * 1024L * 1024L, MaxHeapTuplesPerPage, NULL);
- elog(NOTICE, "sleeping for 2 seconds...");
- pg_usleep(2 * 1000000L);
-
/* load tids */
start_time = GetCurrentTimestamp();
for (BlockNumber blkno = minblk; blkno < maxblk; blkno++)
@@ -207,8 +207,22 @@ bench_tidstore_load(PG_FUNCTION_ARGS)
TimestampDifference(start_time, end_time, &secs, &usecs);
load_ms = secs * 1000 + usecs / 1000;
+ elog(NOTICE, "sleeping for 2 seconds...");
+ pg_usleep(2 * 1000000L);
+
+ /* iterate through tids */
+ iter = tidstore_begin_iterate(ts);
+ start_time = GetCurrentTimestamp();
+ while ((result = tidstore_iterate_next(iter)) != NULL)
+ ;
+ tidstore_end_iterate(iter);
+ end_time = GetCurrentTimestamp();
+ TimestampDifference(start_time, end_time, &secs, &usecs);
+ iter_ms = secs * 1000 + usecs / 1000;
+
values[0] = Int64GetDatum(tidstore_memory_usage(ts));
values[1] = Int64GetDatum(load_ms);
+ values[2] = Int64GetDatum(iter_ms);
tidstore_destroy(ts);
PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls)));
@@ -715,3 +729,19 @@ bench_node128_load(PG_FUNCTION_ARGS)
rt_free(rt);
PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls)));
}
+
+/* to silence warnings about unused iter functions */
+static void pg_attribute_unused()
+stub_iter()
+{
+ rt_radix_tree *rt;
+ rt_iter *iter;
+ uint64 key = 1;
+ uint64 value = 1;
+
+ rt = rt_create(CurrentMemoryContext);
+
+ iter = rt_begin_iterate(rt);
+ rt_iterate_next(iter, &key, &value);
+ rt_end_iterate(iter);
+}
\ No newline at end of file
diff --git a/contrib/meson.build b/contrib/meson.build
index 52253de793..421d469f8c 100644
--- a/contrib/meson.build
+++ b/contrib/meson.build
@@ -12,7 +12,7 @@ subdir('amcheck')
subdir('auth_delay')
subdir('auto_explain')
subdir('basic_archive')
-#subdir('bench_radix_tree')
+subdir('bench_radix_tree')
subdir('bloom')
subdir('basebackup_to_shell')
subdir('bool_plperl')
--
2.39.1