Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 09463b6

Browse filesBrowse files
author
Sergey Shinderuk
committed
Add some comments
Author: Oleg Tselebrovskiy
1 parent 2cc26e6 commit 09463b6
Copy full SHA for 09463b6

File tree

2 files changed

+12
-3
lines changed
Filter options

2 files changed

+12
-3
lines changed

‎collector.c

Copy file name to clipboardExpand all lines: collector.c
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ get_next_observation(History *observations)
131131
{
132132
HistoryItem *result;
133133

134+
/* Check for wraparound */
134135
if (observations->index >= observations->count)
135136
{
136137
observations->index = 0;
@@ -217,6 +218,7 @@ send_history(History *observations, shm_mq_handle *mqh)
217218
else
218219
count = observations->index;
219220

221+
/* Send array size first since receive_array expects this */
220222
mq_result = shm_mq_send_compat(mqh, sizeof(count), &count, false, true);
221223
if (mq_result == SHM_MQ_DETACHED)
222224
{
@@ -253,6 +255,7 @@ send_profile(HTAB *profile_hash, shm_mq_handle *mqh)
253255
Size count = hash_get_num_entries(profile_hash);
254256
shm_mq_result mq_result;
255257

258+
/* Send array size first since receive_array expects this */
256259
mq_result = shm_mq_send_compat(mqh, sizeof(count), &count, false, true);
257260
if (mq_result == SHM_MQ_DETACHED)
258261
{
@@ -380,7 +383,7 @@ pgws_collector_main(Datum main_arg)
380383
ProcessConfigFile(PGC_SIGHUP);
381384
}
382385

383-
/* Wait calculate time to next sample for history or profile */
386+
/* Calculate time to next sample for history or profile */
384387
current_ts = GetCurrentTimestamp();
385388

386389
history_diff = millisecs_diff(history_ts, current_ts);

‎pg_wait_sampling.c

Copy file name to clipboardExpand all lines: pg_wait_sampling.c
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void _PG_init(void);
4444

4545
static bool shmem_initialized = false;
4646

47-
/* Hooks */
47+
/* Hooks variables */
4848
static ExecutorStart_hook_type prev_ExecutorStart = NULL;
4949
static ExecutorRun_hook_type prev_ExecutorRun = NULL;
5050
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL;
@@ -65,6 +65,7 @@ static shm_mq *recv_mq = NULL;
6565
static shm_mq_handle *recv_mqh = NULL;
6666
static LOCKTAG queueTag;
6767

68+
/* Hook functions */
6869
#if PG_VERSION_NUM >= 150000
6970
static shmem_request_hook_type prev_shmem_request_hook = NULL;
7071
#endif
@@ -126,7 +127,6 @@ static const struct config_enum_entry pgws_profile_queries_options[] =
126127
{NULL, 0, false}
127128
};
128129

129-
/* GUC variables */
130130
int pgws_historySize = 5000;
131131
int pgws_historyPeriod = 10;
132132
int pgws_profilePeriod = 10;
@@ -253,6 +253,7 @@ pgws_shmem_startup(void)
253253

254254
if (!found)
255255
{
256+
/* Create shared objects */
256257
toc = shm_toc_create(PG_WAIT_SAMPLING_MAGIC, pgws, segsize);
257258

258259
pgws_collector_hdr = shm_toc_allocate(toc, sizeof(CollectorShmqHeader));
@@ -266,6 +267,7 @@ pgws_shmem_startup(void)
266267
}
267268
else
268269
{
270+
/* Attach to existing shared objects */
269271
toc = shm_toc_attach(PG_WAIT_SAMPLING_MAGIC, pgws);
270272
pgws_collector_hdr = shm_toc_lookup(toc, 0, false);
271273
pgws_collector_mq = shm_toc_lookup(toc, 1, false);
@@ -522,6 +524,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
522524

523525
if (!PG_ARGISNULL(0))
524526
{
527+
/* pg_wait_sampling_get_current(pid int4) function */
525528
HistoryItem *item;
526529
PGPROC *proc;
527530

@@ -535,6 +538,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
535538
}
536539
else
537540
{
541+
/* pg_wait_sampling_current view */
538542
int procCount = ProcGlobal->allProcCount,
539543
i,
540544
j = 0;
@@ -600,6 +604,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
600604
}
601605
else
602606
{
607+
/* nothing left */
603608
SRF_RETURN_DONE(funcctx);
604609
}
605610
}
@@ -621,6 +626,7 @@ pgws_init_lock_tag(LOCKTAG *tag, uint32 lock)
621626
tag->locktag_lockmethodid = USER_LOCKMETHOD;
622627
}
623628

629+
/* Get array (history or profile data) from shared memory */
624630
static void *
625631
receive_array(SHMRequest request, Size item_size, Size *count)
626632
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.