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

Commitfe0d923

Browse files
committed
Trace sleep time
1 parent4c26d45 commitfe0d923

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

‎contrib/pg_dtm/sockhub/sockhub.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void ShubLoop(Shub* shub)
469469
if (shub->params->delay!=0) {
470470
continue;
471471
}
472-
}
472+
}
473473
if (shub->in_buffer_used!=0) {/* if buffer is not empty... */
474474
/* ...then send it */
475475
#ifSHOW_SENT_STATISTIC

‎contrib/pg_tsdtm/pg_dtm.c‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
#defineUSEC 1000000
4141

42+
#defineTRACE_SLEEP_TIME 1
43+
4244
typedefuint64timestamp_t;
4345

4446
typedefstructDtmTransStatus
@@ -72,7 +74,10 @@ static HTAB* xid2status;
7274
staticHTAB*gtid2xid;
7375
staticDtmNodeState*local;
7476
staticDtmTransStatedtm_tx;
75-
77+
statictimestamp_tfirstReportTime;
78+
statictimestamp_tprevReportTime;
79+
statictimestamp_ttotalSleepTime;
80+
staticuint64totalSleepInterrupts;
7681
staticintDtmVacuumDelay;
7782

7883
staticSnapshotDtmGetSnapshot(Snapshotsnapshot);
@@ -110,12 +115,25 @@ static void dtm_sleep(timestamp_t interval)
110115
{
111116
structtimespects;
112117
structtimespecrem;
113-
ts.tv_sec=interval /USEC;
114-
ts.tv_nsec=interval %USEC*1000;
118+
#ifTRACE_SLEEP_TIME
119+
timestamp_tnow=dtm_get_current_time();
120+
#endif
115121
while (nanosleep(&ts,&rem)<0) {
122+
totalSleepInterrupts+=1;
116123
Assert(errno==EINTR);
117124
ts=rem;
118125
}
126+
#ifTRACE_SLEEP_TIME
127+
totalSleepTime+=dtm_get_current_time()-now;
128+
if (now>prevReportTime+USEC*10) {
129+
prevReportTime=now;
130+
if (firstReportTime==0) {
131+
firstReportTime=now;
132+
}else {
133+
fprintf(stderr,"Sleep %lu of %lu usec (%f%%)\n",totalSleepTime,now-firstReportTime,totalSleepTime*100.0/firstReportTime);
134+
}
135+
}
136+
#endif
119137
}
120138

121139
staticcid_tdtm_get_cid()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp