|
39 | 39 |
|
40 | 40 | #defineUSEC 1000000
|
41 | 41 |
|
| 42 | +#defineTRACE_SLEEP_TIME 1 |
| 43 | + |
42 | 44 | typedefuint64timestamp_t;
|
43 | 45 |
|
44 | 46 | typedefstructDtmTransStatus
|
@@ -72,7 +74,10 @@ static HTAB* xid2status;
|
72 | 74 | staticHTAB*gtid2xid;
|
73 | 75 | staticDtmNodeState*local;
|
74 | 76 | staticDtmTransStatedtm_tx;
|
75 |
| - |
| 77 | +statictimestamp_tfirstReportTime; |
| 78 | +statictimestamp_tprevReportTime; |
| 79 | +statictimestamp_ttotalSleepTime; |
| 80 | +staticuint64totalSleepInterrupts; |
76 | 81 | staticintDtmVacuumDelay;
|
77 | 82 |
|
78 | 83 | staticSnapshotDtmGetSnapshot(Snapshotsnapshot);
|
@@ -110,12 +115,25 @@ static void dtm_sleep(timestamp_t interval)
|
110 | 115 | {
|
111 | 116 | structtimespects;
|
112 | 117 | 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 |
115 | 121 | while (nanosleep(&ts,&rem)<0) {
|
| 122 | +totalSleepInterrupts+=1; |
116 | 123 | Assert(errno==EINTR);
|
117 | 124 | ts=rem;
|
118 | 125 | }
|
| 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 |
119 | 137 | }
|
120 | 138 |
|
121 | 139 | staticcid_tdtm_get_cid()
|
|