v8-Add-benchmark-tweaks-to-stress-jumbling-code.txt
text/plain
Filename: v8-Add-benchmark-tweaks-to-stress-jumbling-code.txt
Type: text/plain
Part: 0
From ee47c4e1137adc857184d76ab62232e9c3c95451 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Fri, 27 Jan 2023 10:58:34 +0900
Subject: [PATCH 1/1] Add benchmark tweaks to stress jumbling code
---
src/backend/nodes/queryjumblefuncs.c | 36 +++++++++++++++++++++-------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/backend/nodes/queryjumblefuncs.c b/src/backend/nodes/queryjumblefuncs.c
index d55adf5020..9c134cc5ae 100644
--- a/src/backend/nodes/queryjumblefuncs.c
+++ b/src/backend/nodes/queryjumblefuncs.c
@@ -101,32 +101,48 @@ CleanQuerytext(const char *query, int *location, int *len)
JumbleState *
JumbleQuery(Query *query, const char *querytext)
{
+#define MAX_QUERY_COMPUTE 5000000
+
JumbleState *jstate = NULL;
Assert(IsQueryIdEnabled());
+ elog(WARNING, "start JumbleQuery");
+
if (query->utilityStmt &&
utility_query_id == UTILITY_QUERY_ID_STRING)
{
- query->queryId = compute_utility_query_id(querytext,
- query->stmt_location,
- query->stmt_len);
+ for (int i = 0; i < MAX_QUERY_COMPUTE ; i++)
+ {
+ query->queryId = compute_utility_query_id(querytext,
+ query->stmt_location,
+ query->stmt_len);
+ }
}
else
{
jstate = (JumbleState *) palloc(sizeof(JumbleState));
- /* Set up workspace for query jumbling */
jstate->jumble = (unsigned char *) palloc(JUMBLE_SIZE);
- jstate->jumble_len = 0;
jstate->clocations_buf_size = 32;
jstate->clocations = (LocationLen *)
palloc(jstate->clocations_buf_size * sizeof(LocationLen));
- jstate->clocations_count = 0;
- jstate->highest_extern_param_id = 0;
- /* Compute query ID and mark the Query node with it */
- _jumbleNode(jstate, (Node *) query);
+ for (int i = 0; i < MAX_QUERY_COMPUTE ; i++)
+ {
+ memset(jstate->jumble, 0, sizeof(JUMBLE_SIZE));
+ /* Set up workspace for query jumbling */
+ jstate->jumble_len = 0;
+ jstate->clocations_buf_size = 32;
+ memset(jstate->clocations, 0,
+ jstate->clocations_buf_size * sizeof(LocationLen));
+ jstate->clocations_count = 0;
+ jstate->highest_extern_param_id = 0;
+
+ /* Compute query ID and mark the Query node with it */
+ _jumbleNode(jstate, (Node *) query);
+ }
+
query->queryId = DatumGetUInt64(hash_any_extended(jstate->jumble,
jstate->jumble_len,
0));
@@ -139,6 +155,8 @@ JumbleQuery(Query *query, const char *querytext)
query->queryId = UINT64CONST(1);
}
+ elog(WARNING, "end JumbleQuery");
+
return jstate;
}
--
2.39.0