public inbox for [email protected]
help / color / mirror / Atom feed[PATCH] Add RetrieveInstrumentation hook for CustomScan providers
2+ messages / 1 participants
[nested] [flat]
* [PATCH] Add RetrieveInstrumentation hook for CustomScan providers
@ 2026-02-18 09:39 Siddharth Kothari <[email protected]>
2026-04-08 05:27 ` Re: [PATCH] Add RetrieveInstrumentation hook for CustomScan providers Siddharth Kothari <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Siddharth Kothari @ 2026-02-18 09:39 UTC (permalink / raw)
To: [email protected]; +Cc: Vaibhav Jain <[email protected]>; Madhukar <[email protected]>
Dear PostgreSQL Hackers,
This email proposes a patch to enhance the CustomScan provider interface.
The patch file,
0001-Add-RetrieveInstrumentationCustomScan-hook-for-Custo.patch, is
attached.
*Problem:*
CustomScan providers currently lack a standard method to aggregate
instrumentation data from parallel workers back to the leader process
before the Dynamic Shared Memory (DSM) segment is unlinked. This makes it
difficult to gather comprehensive performance metrics from parallelized
custom scans.
*Solution:*
This patch introduces a new optional hook, RetrieveInstrumentationCustomScan,
to the CustomExecMethods struct. This hook allows custom scan providers to
implement logic to collect and consolidate instrumentation from shared
memory or worker states during the parallel query cleanup phase. This hook
is invoked via the new ExecCustomScanRetrieveInstrumentation function,
called from ExecParallelRetrieveInstrumentation for T_CustomScanState nodes.
Since the hook is optional (checked for NULL before calling), it maintains
full backward compatibility.
*Testing & Compatibility:*
- The patch compiles and passes all core regression tests (make
check-world) on my x86_64 instance.
- The changes are not platform-specific.
- Regression Tests: This patch provides a new *capability* for custom
scan providers. Since the hook's functionality is only realized when
implemented by an extension, specific tests would naturally reside within
that extension rather than in the core regression suite.
This patch does not directly address a specific item on the official TODO
list but enhances the extensibility framework.
I believe this patch is complete and ready for review. I look forward to
any feedback and am happy to make revisions. I will also add this patch to
the next CommitFest.
Thank you,
Siddharth Kothari
Attachments:
[application/x-patch] 0001-Add-RetrieveInstrumentationCustomScan-hook-for-Custo.patch (3.3K, 3-0001-Add-RetrieveInstrumentationCustomScan-hook-for-Custo.patch)
download | inline diff:
From ac6049e8b0af21666314edb73018fd99940d0731 Mon Sep 17 00:00:00 2001
From: Siddharth Kothari <[email protected]>
Date: Tue, 17 Feb 2026 12:23:56 +0000
Subject: [PATCH] Add RetrieveInstrumentationCustomScan hook for CustomScan
providers
CustomScan providers currently lack a standard method to aggregate
instrumentation data from parallel workers back to the leader process
before the Dynamic Shared Memory segment is destroyed.
This patch introduces an optional RetrieveInstrumentationCustomScan
callback to the CustomExecMethods struct. This allows custom scan
providers to implement logic to collect and consolidate instrumentation
from shared memory.
The new hook is called in ExecRetrieveInstrumentation for CustomScanState
nodes during the parallel query cleanup phase.
---
src/backend/executor/execParallel.c | 3 +++
src/backend/executor/nodeCustom.c | 9 +++++++++
src/include/executor/nodeCustom.h | 1 +
src/include/nodes/extensible.h | 3 +++
4 files changed, 16 insertions(+)
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index f87978c137e..c2416a98170 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -1118,6 +1118,9 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
case T_BitmapHeapScanState:
ExecBitmapHeapRetrieveInstrumentation((BitmapHeapScanState *) planstate);
break;
+ case T_CustomScanState:
+ ExecCustomScanRetrieveInstrumentation((CustomScanState *) planstate);
+ break;
default:
break;
}
diff --git a/src/backend/executor/nodeCustom.c b/src/backend/executor/nodeCustom.c
index a9ad5af6a98..f027d24993f 100644
--- a/src/backend/executor/nodeCustom.c
+++ b/src/backend/executor/nodeCustom.c
@@ -217,6 +217,15 @@ ExecCustomScanInitializeWorker(CustomScanState *node,
}
}
+void
+ExecCustomScanRetrieveInstrumentation(CustomScanState *node)
+{
+ const CustomExecMethods *methods = node->methods;
+
+ if (methods->RetrieveInstrumentationCustomScan)
+ methods->RetrieveInstrumentationCustomScan(node);
+}
+
void
ExecShutdownCustomScan(CustomScanState *node)
{
diff --git a/src/include/executor/nodeCustom.h b/src/include/executor/nodeCustom.h
index fb0acc6e414..0a9cfb40381 100644
--- a/src/include/executor/nodeCustom.h
+++ b/src/include/executor/nodeCustom.h
@@ -37,6 +37,7 @@ extern void ExecCustomScanReInitializeDSM(CustomScanState *node,
ParallelContext *pcxt);
extern void ExecCustomScanInitializeWorker(CustomScanState *node,
ParallelWorkerContext *pwcxt);
+extern void ExecCustomScanRetrieveInstrumentation(CustomScanState *node);
extern void ExecShutdownCustomScan(CustomScanState *node);
#endif /* NODECUSTOM_H */
diff --git a/src/include/nodes/extensible.h b/src/include/nodes/extensible.h
index 517db95c4a3..cda478b538f 100644
--- a/src/include/nodes/extensible.h
+++ b/src/include/nodes/extensible.h
@@ -151,6 +151,9 @@ typedef struct CustomExecMethods
void *coordinate);
void (*ShutdownCustomScan) (CustomScanState *node);
+ /* Optional: retrieve parallel instrumentation */
+ void (*RetrieveInstrumentationCustomScan) (CustomScanState *node);
+
/* Optional: print additional information in EXPLAIN */
void (*ExplainCustomScan) (CustomScanState *node,
List *ancestors,
--
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [PATCH] Add RetrieveInstrumentation hook for CustomScan providers
2026-02-18 09:39 [PATCH] Add RetrieveInstrumentation hook for CustomScan providers Siddharth Kothari <[email protected]>
@ 2026-04-08 05:27 ` Siddharth Kothari <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Siddharth Kothari @ 2026-04-08 05:27 UTC (permalink / raw)
To: [email protected]; +Cc: Vaibhav Jain <[email protected]>; Madhukar <[email protected]>
Hi everyone,
I’m just checking in to see if anyone has had a chance to look at this or
if there’s any further information I should provide to help with the
review. I have also added the patch to PG20-1 CF queue, the link is
https://commitfest.postgresql.org/patch/6524/.
Thanks,
Siddharth
On Wed, Feb 18, 2026 at 3:09 PM Siddharth Kothari <[email protected]> wrote:
> Dear PostgreSQL Hackers,
>
> This email proposes a patch to enhance the CustomScan provider interface.
> The patch file,
> 0001-Add-RetrieveInstrumentationCustomScan-hook-for-Custo.patch, is
> attached.
>
> *Problem:*
>
> CustomScan providers currently lack a standard method to aggregate
> instrumentation data from parallel workers back to the leader process
> before the Dynamic Shared Memory (DSM) segment is unlinked. This makes it
> difficult to gather comprehensive performance metrics from parallelized
> custom scans.
>
> *Solution:*
>
> This patch introduces a new optional hook,
> RetrieveInstrumentationCustomScan, to the CustomExecMethods struct. This
> hook allows custom scan providers to implement logic to collect and
> consolidate instrumentation from shared memory or worker states during the
> parallel query cleanup phase. This hook is invoked via the new
> ExecCustomScanRetrieveInstrumentation function, called from
> ExecParallelRetrieveInstrumentation for T_CustomScanState nodes. Since
> the hook is optional (checked for NULL before calling), it maintains full
> backward compatibility.
>
> *Testing & Compatibility:*
>
> - The patch compiles and passes all core regression tests (make
> check-world) on my x86_64 instance.
> - The changes are not platform-specific.
> - Regression Tests: This patch provides a new *capability* for custom
> scan providers. Since the hook's functionality is only realized when
> implemented by an extension, specific tests would naturally reside within
> that extension rather than in the core regression suite.
>
> This patch does not directly address a specific item on the official TODO
> list but enhances the extensibility framework.
>
> I believe this patch is complete and ready for review. I look forward to
> any feedback and am happy to make revisions. I will also add this patch to
> the next CommitFest.
>
> Thank you,
>
> Siddharth Kothari
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-04-08 05:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-18 09:39 [PATCH] Add RetrieveInstrumentation hook for CustomScan providers Siddharth Kothari <[email protected]>
2026-04-08 05:27 ` Siddharth Kothari <[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