Skip unnecessary mdb_page_get()s when spilling

Do not bring in pages merely to see if they should be skipped.
mdb.master3
Hallvard Furuseth 7 years ago committed by Howard Chu
parent 6dd5a4d7f6
commit 34461da97b
  1. 13
      libraries/liblmdb/mdb.c

@ -2237,8 +2237,8 @@ mdb_pages_xkeep(MDB_cursor *mc, unsigned pflags, int all)
MDB_xcursor *mx; MDB_xcursor *mx;
MDB_page *dp, *mp; MDB_page *dp, *mp;
MDB_node *leaf; MDB_node *leaf;
unsigned i, j; unsigned i, j, x;
int rc = MDB_SUCCESS, level; int rc = MDB_SUCCESS;
/* Mark pages seen by cursors: First m0, then tracked cursors */ /* Mark pages seen by cursors: First m0, then tracked cursors */
for (i = txn->mt_numdbs;; ) { for (i = txn->mt_numdbs;; ) {
@ -2270,14 +2270,17 @@ mdb_pages_xkeep(MDB_cursor *mc, unsigned pflags, int all)
mark_done: mark_done:
if (all) { if (all) {
/* Mark dirty root pages */ /* Mark dirty root pages */
MDB_ID2L dl = txn->mt_u.dirty_list;
for (i=0; i<txn->mt_numdbs; i++) { for (i=0; i<txn->mt_numdbs; i++) {
if (txn->mt_dbflags[i] & DB_DIRTY) { if (txn->mt_dbflags[i] & DB_DIRTY) {
pgno_t pgno = txn->mt_dbs[i].md_root; pgno_t pgno = txn->mt_dbs[i].md_root;
if (pgno == P_INVALID) if (pgno == P_INVALID)
continue; continue;
if ((rc = MDB_PAGE_GET(m0, pgno, 1, &dp, &level)) != MDB_SUCCESS) x = mdb_mid2l_search(dl, pgno);
break; if (! (x <= dl[0].mid && dl[x].mid == pgno))
if ((dp->mp_flags & Mask) == pflags && level <= 1) continue;
dp = dl[x].mptr;
if ((dp->mp_flags & Mask) == pflags)
dp->mp_flags ^= P_KEEP; dp->mp_flags ^= P_KEEP;
} }
} }

Loading…
Cancel
Save