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

Commitd8364f3

Browse files
committed
Per previous analysis, the most correct notion of SampleOverhead is that
it is just the total time to do INSTR_TIME_SET_CURRENT(), and not any ofthe other code involved in InstrStartNode/InstrStopNode. Even though Ifear we may end up reverting this patch altogether, we may as well havethe most correct version in our CVS archive.
1 parente9f6679 commitd8364f3

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

‎src/backend/executor/instrument.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.16 2006/05/30 19:24:25 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.17 2006/06/07 18:49:03 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -42,7 +42,7 @@
4242
*
4343
* The actual sampling interval is randomized with the SampleFunc() value
4444
* as the mean; this hopefully will reduce any measurement bias due to
45-
*cyclicvariation in the node execution time.
45+
* variation in the node execution time.
4646
*/
4747
#ifdefHAVE_CBRT
4848
#defineSampleFunc(niters) cbrt(niters)
@@ -56,8 +56,7 @@
5656
/*
5757
* We sample at every node iteration until we've reached this threshold,
5858
* so that nodes not called a large number of times are completely accurate.
59-
* (Perhaps this should be a GUC variable? But beware of messing up
60-
* CalculateSampleOverhead if value is too small.)
59+
* (Perhaps this should be a GUC variable?)
6160
*/
6261
#defineSAMPLE_THRESHOLD 50
6362

@@ -71,7 +70,6 @@ static bool SampleOverheadCalculated = false;
7170
staticvoid
7271
CalculateSampleOverhead(void)
7372
{
74-
Instrumentationinstr;
7573
inti;
7674

7775
/*
@@ -82,20 +80,20 @@ CalculateSampleOverhead(void)
8280

8381
for (i=0;i<5;i++)
8482
{
83+
Instrumentationtimer;
84+
instr_timetmptime;
8585
intj;
8686
doubleoverhead;
8787

88-
memset(&instr,0,sizeof(instr));
89-
/*
90-
* We know that samples will actually be taken up to SAMPLE_THRESHOLD,
91-
* so that's as far as we can test.
92-
*/
93-
for (j=0;j<SAMPLE_THRESHOLD;j++)
88+
memset(&timer,0,sizeof(timer));
89+
InstrStartNode(&timer);
90+
#defineTEST_COUNT 100
91+
for (j=0;j<TEST_COUNT;j++)
9492
{
95-
InstrStartNode(&instr);
96-
InstrStopNode(&instr,1);
93+
INSTR_TIME_SET_CURRENT(tmptime);
9794
}
98-
overhead=INSTR_TIME_GET_DOUBLE(instr.counter) /instr.samplecount;
95+
InstrStopNode(&timer,1);
96+
overhead=INSTR_TIME_GET_DOUBLE(timer.counter) /TEST_COUNT;
9997
if (overhead<SampleOverhead)
10098
SampleOverhead=overhead;
10199
}
@@ -159,14 +157,20 @@ InstrStopNode(Instrumentation *instr, double nTuples)
159157
{
160158
instr_timeendtime;
161159

160+
/*
161+
* To be sure that SampleOverhead accurately reflects the extra
162+
* overhead, we must do INSTR_TIME_SET_CURRENT() as the *first*
163+
* action that is different between the sampling and non-sampling
164+
* code paths.
165+
*/
166+
INSTR_TIME_SET_CURRENT(endtime);
167+
162168
if (INSTR_TIME_IS_ZERO(instr->starttime))
163169
{
164170
elog(DEBUG2,"InstrStopNode called without start");
165171
return;
166172
}
167173

168-
INSTR_TIME_SET_CURRENT(endtime);
169-
170174
#ifndefWIN32
171175
instr->counter.tv_sec+=endtime.tv_sec-instr->starttime.tv_sec;
172176
instr->counter.tv_usec+=endtime.tv_usec-instr->starttime.tv_usec;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp