Commit a57c1a66 authored by Yoni Fogel's avatar Yoni Fogel

[t:5067] Reduce GC-system overhead for read-only transactions

git-svn-id: file:///svn/toku/tokudb@44750 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7029824b
...@@ -136,8 +136,8 @@ verify_snapshot_system(TXN_MANAGER txn_manager UU()) { ...@@ -136,8 +136,8 @@ verify_snapshot_system(TXN_MANAGER txn_manager UU()) {
// Only committed entries have return a youngest. // Only committed entries have return a youngest.
invariant(youngest == TXNID_NONE); invariant(youngest == TXNID_NONE);
} }
else { else if (youngest != TXNID_NONE) {
invariant(youngest != TXNID_NONE); // A committed entry might have been read-only, in which case it won't return anything.
// This snapshot reads 'live_xid' so it's youngest cannot be older than snapshot_xid. // This snapshot reads 'live_xid' so it's youngest cannot be older than snapshot_xid.
invariant(youngest >= snapshot_xid); invariant(youngest >= snapshot_xid);
} }
...@@ -586,26 +586,29 @@ void toku_txn_manager_finish_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { ...@@ -586,26 +586,29 @@ void toku_txn_manager_finish_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
r = toku_omt_delete_at(txn_manager->live_root_txns, idx); r = toku_omt_delete_at(txn_manager->live_root_txns, idx);
invariant_zero(r); invariant_zero(r);
if (!is_snapshot) { if (txn->begin_was_logged) {
// If it's a snapshot, we already calculated index_in_snapshot_txnids. if (!is_snapshot) {
r = toku_omt_find_zero(txn_manager->snapshot_txnids, toku_find_xid_by_xid, (OMTVALUE) txn->txnid64, NULL, &index_in_snapshot_txnids); // If it's a snapshot, we already calculated index_in_snapshot_txnids.
invariant(r == DB_NOTFOUND); // Otherwise, calculate it now.
} r = toku_omt_find_zero(txn_manager->snapshot_txnids, toku_find_xid_by_xid, (OMTVALUE) txn->txnid64, NULL, &index_in_snapshot_txnids);
uint32_t num_references = toku_omt_size(txn_manager->snapshot_txnids) - index_in_snapshot_txnids; invariant(r == DB_NOTFOUND);
if (num_references > 0) { }
// This transaction exists in a live list of another transaction. uint32_t num_references = toku_omt_size(txn_manager->snapshot_txnids) - index_in_snapshot_txnids;
struct referenced_xid_tuple *XMALLOC(tuple); if (num_references > 0) {
tuple->begin_id = txn->txnid64; // This transaction exists in a live list of another transaction.
tuple->end_id = ++txn_manager->last_xid; struct referenced_xid_tuple *XMALLOC(tuple);
tuple->references = num_references; tuple->begin_id = txn->txnid64;
tuple->end_id = ++txn_manager->last_xid;
r = toku_omt_insert( tuple->references = num_references;
txn_manager->referenced_xids,
tuple, r = toku_omt_insert(
find_tuple_by_xid, txn_manager->referenced_xids,
(OMTVALUE)txn->txnid64, tuple,
NULL); find_tuple_by_xid,
lazy_assert_zero(r); (OMTVALUE)txn->txnid64,
NULL);
lazy_assert_zero(r);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment