Skip to content

Commit cd0546f

Browse files
author
Alexander Korotkov
committed
Better comments.
1 parent 365263b commit cd0546f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

collector.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ collector_main(Datum main_arg)
298298
alloc_history(&observations, collector_hdr->historySize);
299299
MemoryContextSwitchTo(old_context);
300300

301+
/* Start counting time for history and profile samples */
301302
profile_ts = history_ts = GetCurrentTimestamp();
302303

303304
while (1)
@@ -311,6 +312,7 @@ collector_main(Datum main_arg)
311312
bool write_history,
312313
write_profile;
313314

315+
/* Wait calculate time to next sample for history or profile */
314316
current_ts = GetCurrentTimestamp();
315317

316318
history_diff = millisecs_diff(history_ts, current_ts);
@@ -343,6 +345,10 @@ collector_main(Datum main_arg)
343345
if (shutdown_requested)
344346
break;
345347

348+
/*
349+
* Wait until next sample time or request to do something through
350+
* shared memory.
351+
*/
346352
rc = WaitLatch(&MyProc->procLatch, WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
347353
Min(history_period - (int)history_diff,
348354
profile_period - (int)profile_diff));

pg_wait_sampling.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS)
290290

291291
item = &params->items[funcctx->call_cntr];
292292

293+
/* Make and return next tuple to caller */
293294
MemSet(values, 0, sizeof(values));
294295
MemSet(nulls, 0, sizeof(nulls));
295296

@@ -439,7 +440,7 @@ pg_wait_sampling_get_profile(PG_FUNCTION_ARGS)
439440
MemSet(values, 0, sizeof(values));
440441
MemSet(nulls, 0, sizeof(nulls));
441442

442-
/* Values available to all callers */
443+
/* Make and return next tuple to caller */
443444
event_type = pgstat_get_wait_event_type(item->wait_event_info);
444445
event = pgstat_get_wait_event(item->wait_event_info);
445446
values[0] = Int32GetDatum(item->pid);
@@ -538,10 +539,10 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS)
538539

539540
item = &history->items[history->index];
540541

542+
/* Make and return next tuple to caller */
541543
MemSet(values, 0, sizeof(values));
542544
MemSet(nulls, 0, sizeof(nulls));
543545

544-
/* Values available to all callers */
545546
event_type = pgstat_get_wait_event_type(item->wait_event_info);
546547
event = pgstat_get_wait_event(item->wait_event_info);
547548
values[0] = Int32GetDatum(item->pid);

pg_wait_sampling.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pg_wait_sampling extension
2-
comment = 'track statistics of wait events using sampling'
2+
comment = 'sampling based statistics of wait events '
33
default_version = '1.0'
44
module_pathname = '$libdir/pg_wait_sampling'
55
relocatable = true

0 commit comments

Comments
 (0)