@@ -115,9 +115,6 @@ static void dtm_sleep(timestamp_t interval)
115
115
{
116
116
struct timespec ts ;
117
117
struct timespec rem ;
118
- #if TRACE_SLEEP_TIME
119
- timestamp_t now = dtm_get_current_time ();
120
- #endif
121
118
ts .tv_sec = 0 ;
122
119
ts .tv_nsec = interval * 1000 ;
123
120
@@ -126,17 +123,6 @@ static void dtm_sleep(timestamp_t interval)
126
123
Assert (errno == EINTR );
127
124
ts = rem ;
128
125
}
129
- #if TRACE_SLEEP_TIME
130
- totalSleepTime += dtm_get_current_time () - now ;
131
- if (now > prevReportTime + USEC * 10 ) {
132
- prevReportTime = now ;
133
- if (firstReportTime == 0 ) {
134
- firstReportTime = now ;
135
- } else {
136
- fprintf (stderr , "Sleep %lu of %lu usec (%f%%)\n" , totalSleepTime , now - firstReportTime , totalSleepTime * 100.0 /(now - firstReportTime ));
137
- }
138
- }
139
- #endif
140
126
}
141
127
142
128
static cid_t dtm_get_cid ()
@@ -155,7 +141,23 @@ static cid_t dtm_sync(cid_t global_cid)
155
141
cid_t local_cid ;
156
142
while ((local_cid = dtm_get_cid ()) < global_cid ) {
157
143
SpinLockRelease (& local -> lock );
144
+ #if TRACE_SLEEP_TIME
145
+ {
146
+ timestamp_t now = dtm_get_current_time ();
147
+ #endif
158
148
dtm_sleep (global_cid - local_cid );
149
+ #if TRACE_SLEEP_TIME
150
+ totalSleepTime += dtm_get_current_time () - now ;
151
+ if (now > prevReportTime + USEC * 10 ) {
152
+ prevReportTime = now ;
153
+ if (firstReportTime == 0 ) {
154
+ firstReportTime = now ;
155
+ } else {
156
+ fprintf (stderr , "Sleep %lu of %lu usec (%f%%)\n" , totalSleepTime , now - firstReportTime , totalSleepTime * 100.0 /(now - firstReportTime ));
157
+ }
158
+ }
159
+ }
160
+ #endif
159
161
SpinLockAcquire (& local -> lock );
160
162
}
161
163
return global_cid ;
@@ -449,7 +451,23 @@ bool DtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
449
451
{
450
452
DTM_TRACE ((stderr , "%d: wait for in-doubt transaction %u in snapshot %lu\n" , getpid (), xid , dtm_tx .snapshot ));
451
453
SpinLockRelease (& local -> lock );
454
+ #if TRACE_SLEEP_TIME
455
+ {
456
+ timestamp_t now = dtm_get_current_time ();
457
+ #endif
452
458
dtm_sleep (delay );
459
+ #if TRACE_SLEEP_TIME
460
+ totalSleepTime += dtm_get_current_time () - now ;
461
+ if (now > prevReportTime + USEC * 10 ) {
462
+ prevReportTime = now ;
463
+ if (firstReportTime == 0 ) {
464
+ firstReportTime = now ;
465
+ } else {
466
+ fprintf (stderr , "Sleep %lu of %lu usec (%f%%)\n" , totalSleepTime , now - firstReportTime , totalSleepTime * 100.0 /(now - firstReportTime ));
467
+ }
468
+ }
469
+ }
470
+ #endif
453
471
if (delay * 2 <= MAX_WAIT_TIMEOUT ) {
454
472
delay *= 2 ;
455
473
}
0 commit comments