Skip to content

Commit 6b12da5

Browse files
committed
Avoid sort in DTMD
1 parent 1a62de9 commit 6b12da5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

dtmd/src/main.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,25 @@ static xid_t max(xid_t a, xid_t b) {
191191

192192
static void gen_snapshot(Snapshot *s) {
193193
Transaction* t;
194+
int n = 0;
194195
s->times_sent = 0;
195-
s->nactive = 0;
196-
s->xmin = MAX_XID;
197-
s->xmax = MIN_XID;
198-
for (t = (Transaction*)active_transactions.next; t != (Transaction*)&active_transactions; t = (Transaction*)t->elem.next) {
196+
for (t = (Transaction*)active_transactions.prev; t != (Transaction*)&active_transactions; t = (Transaction*)t->elem.prev) {
197+
/*
199198
if (t->xid < s->xmin) {
200199
s->xmin = t->xid;
201200
}
202201
if (t->xid >= s->xmax) {
203202
s->xmax = t->xid + 1;
204203
}
205-
s->active[s->nactive++] = t->xid;
204+
*/
205+
s->active[n++] = t->xid;
206206
}
207-
if (s->nactive > 0) {
208-
assert(s->xmin < MAX_XID);
209-
assert(s->xmax > MIN_XID);
207+
s->nactive = n;
208+
if (n > 0) {
209+
s->xmin = s->active[0];
210+
s->xmax = s->active[n-1];
210211
assert(s->xmin <= s->xmax);
211-
snapshot_sort(s);
212+
// snapshot_sort(s);
212213
} else {
213214
s->xmin = s->xmax = 0;
214215
}

0 commit comments

Comments
 (0)