From 122382417b1223fbcac1220fc0b863a373bddd69 Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Wed, 25 Nov 2015 00:01:19 +1100 Subject: WT-2337 Avoid yields if we race allocating transaction IDs. It had a major perf impact on parallel populate workloads including YCSB. --- src/include/txn.i | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/include/txn.i b/src/include/txn.i index f19cf259174..ef9d5a273cf 100644 --- a/src/include/txn.i +++ b/src/include/txn.i @@ -323,6 +323,7 @@ __wt_txn_id_alloc(WT_SESSION_IMPL *session, bool publish) { WT_TXN_GLOBAL *txn_global; uint64_t id; + u_int i; txn_global = &S2C(session)->txn_global; @@ -353,14 +354,17 @@ __wt_txn_id_alloc(WT_SESSION_IMPL *session, bool publish) if (publish) { session->txn.id = id; - WT_PUBLISH(WT_SESSION_TXN_STATE(session)->id, id); + WT_SESSION_TXN_STATE(session)->id = id; } - while (txn_global->current != id || - !__wt_atomic_casv64(&txn_global->current, id, id + 1)) - __wt_yield(); + for (i = 0; txn_global->current != id; i++) + if (i < 100) + WT_PAUSE(); + else + __wt_yield(); - return (id); + WT_PUBLISH(txn_global->current, id + 1); + return (id); } /* -- cgit v1.2.1