Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd4d9dad

Browse files
author
Alexander Korotkov
committed
pg_wait_sampling.profile_pid setting to collect profile in not per-proccess manner.
1 parent354c23b commitd4d9dad

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

‎README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,17 @@ GUCs.
109109
| pg_wait_sampling.history_size| int4| Size of history in-memory ring buffer| 5000|
110110
| pg_wait_sampling.history_period| int4| Period for history sampling in milliseconds| 10|
111111
| pg_wait_sampling.profile_period| int4| Period for profile sampling in milliseconds| 10|
112+
| pg_wait_sampling.profile_pid| int4| Whether profile should be per pid| true|
112113

113-
These GUCs are allowed to be changed by superuser. Also, they are placed into
114-
shared memory. Thus, they could be changed from any backend and affects worker
114+
If pg\_wait\_sampling.profile\_pid is set to false, sampling profile wouldn't be
115+
collected in per-process manner. In this case the value of pid could would
116+
be always zero and corresponding row contain samples among all the processes.
117+
118+
These GUCs are allowed to be changed by superuser. Also, they are placed into
119+
shared memory. Thus, they could be changed from any backend and affects worker
115120
runtime.
116121

122+
117123
See
118124
[PostgreSQL documentation](http://www.postgresql.org/docs/devel/static/monitoring-stats.html#WAIT-EVENT-TABLE)
119125
for list of possible wait events.

‎collector.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ get_next_observation(History *observations)
138138
*/
139139
staticvoid
140140
probe_waits(History*observations,HTAB*profile_hash,
141-
boolwrite_history,boolwrite_profile)
141+
boolwrite_history,boolwrite_profile,boolprofile_pid)
142142
{
143143
inti,
144144
newSize;
@@ -178,6 +178,9 @@ probe_waits(History *observations, HTAB *profile_hash,
178178
ProfileItem*profileItem;
179179
boolfound;
180180

181+
if (!profile_pid)
182+
item.pid=0;
183+
181184
profileItem= (ProfileItem*)hash_search(profile_hash,&item,HASH_ENTER,&found);
182185
if (found)
183186
profileItem->count++;
@@ -325,7 +328,7 @@ collector_main(Datum main_arg)
325328
if (write_history||write_profile)
326329
{
327330
probe_waits(&observations,profile_hash,
328-
write_history,write_profile);
331+
write_history,write_profile,collector_hdr->profilePid);
329332

330333
if (write_history)
331334
{

‎pg_wait_sampling.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ shmem_int_guc_check_hook(int *newval, void **extra, GucSource source)
7575
return true;
7676
}
7777

78+
staticbool
79+
shmem_bool_guc_check_hook(bool*newval,void**extra,GucSourcesource)
80+
{
81+
if (UsedShmemSegAddr==NULL)
82+
return false;
83+
return true;
84+
}
85+
7886
/*
7987
* This union allows us to mix the numerous different types of structs
8088
* that we are organizing.
@@ -100,7 +108,8 @@ setup_gucs()
100108
i;
101109
boolhistory_size_found= false,
102110
history_period_found= false,
103-
profile_period_found= false;
111+
profile_period_found= false,
112+
profile_pid_found= false;
104113

105114
guc_vars=get_guc_variables();
106115
numOpts=GetNumConfigOptions();
@@ -131,6 +140,12 @@ setup_gucs()
131140
var->integer.variable=&collector_hdr->profilePeriod;
132141
collector_hdr->profilePeriod=10;
133142
}
143+
elseif (!strcmp(name,"pg_wait_sampling.profile_pid"))
144+
{
145+
profile_pid_found= true;
146+
var->_bool.variable=&collector_hdr->profilePid;
147+
collector_hdr->profilePid= true;
148+
}
134149
}
135150

136151
if (!history_size_found)
@@ -151,7 +166,14 @@ setup_gucs()
151166
&collector_hdr->profilePeriod,10,1,INT_MAX,
152167
PGC_SUSET,0,shmem_int_guc_check_hook,NULL,NULL);
153168

154-
if (history_size_found||history_period_found||profile_period_found)
169+
if (!profile_pid_found)
170+
DefineCustomBoolVariable("pg_wait_sampling.profile_pid",
171+
"Sets whether profile should be collected per pid.",NULL,
172+
&collector_hdr->profilePid, true,
173+
PGC_SUSET,0,shmem_bool_guc_check_hook,NULL,NULL);
174+
175+
if (history_size_found||history_period_found
176+
||profile_period_found||profile_pid_found)
155177
ProcessConfigFile(PGC_SIGHUP);
156178
}
157179

‎pg_wait_sampling.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct
6262
inthistorySize;
6363
inthistoryPeriod;
6464
intprofilePeriod;
65+
boolprofilePid;
6566
}CollectorShmqHeader;
6667

6768
/* pg_wait_sampling.c */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp