- Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathpg_wait_sampling.h
81 lines (70 loc) · 1.63 KB
/
pg_wait_sampling.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* pg_wait_sampling.h
* Headers for pg_wait_sampling extension.
*
* Copyright (c) 2015-2025, Postgres Professional
*
* IDENTIFICATION
* contrib/pg_wait_sampling/pg_wait_sampling.h
*/
#ifndef__PG_WAIT_SAMPLING_H__
#define__PG_WAIT_SAMPLING_H__
#include"datatype/timestamp.h"
#include"storage/latch.h"
#include"storage/lock.h"
#include"storage/shm_mq.h"
#definePG_WAIT_SAMPLING_MAGIC 0xCA94B107
#defineCOLLECTOR_QUEUE_SIZE (16 * 1024)
#defineHISTORY_TIME_MULTIPLIER 10
#definePGWS_QUEUE_LOCK 0
#definePGWS_COLLECTOR_LOCK 1
typedefstruct
{
intpid;
uint32wait_event_info;
uint64queryId;
uint64count;
} ProfileItem;
typedefstruct
{
intpid;
uint32wait_event_info;
uint64queryId;
TimestampTzts;
} HistoryItem;
typedefstruct
{
boolwraparound;
Sizeindex;
Sizecount;
HistoryItem*items;
} History;
typedefenum
{
NO_REQUEST,
HISTORY_REQUEST,
PROFILE_REQUEST,
PROFILE_RESET
} SHMRequest;
typedefstruct
{
Latch*latch;
SHMRequestrequest;
} CollectorShmqHeader;
/* GUC variables */
externintpgws_historySize;
externintpgws_historyPeriod;
externintpgws_profilePeriod;
externboolpgws_profilePid;
externintpgws_profileQueries;
externboolpgws_sampleCpu;
/* pg_wait_sampling.c */
externCollectorShmqHeader*pgws_collector_hdr;
externshm_mq*pgws_collector_mq;
externuint64*pgws_proc_queryids;
externvoidpgws_init_lock_tag(LOCKTAG*tag, uint32lock);
externboolpgws_should_sample_proc(PGPROC*proc, int*pid_p, uint32*wait_event_info_p);
/* collector.c */
externvoidpgws_register_wait_collector(void);
externPGDLLEXPORTvoidpgws_collector_main(Datummain_arg);
#endif