summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2016-04-17 16:18:23 -0400
committerKeith Bostic <keith@wiredtiger.com>2016-04-17 16:18:23 -0400
commitaaa52e081b7d531b80502dfdf1a682808d43624c (patch)
tree0d750ed10df0759942d42bd8a65eb6a571c46e9d
parent72e6c5ff26b61dbe540172d7d9c9e41c52ea6ea5 (diff)
downloadmongo-aaa52e081b7d531b80502dfdf1a682808d43624c.tar.gz
WT-2558: WT_PAGE structure is 72B, reduce to 64B.
Move the row-store insert and update structures into the WT_PAGE_MODIFY structure.
-rw-r--r--src/btree/bt_cursor.c36
-rw-r--r--src/btree/bt_delete.c7
-rw-r--r--src/btree/bt_discard.c37
-rw-r--r--src/btree/bt_split.c16
-rw-r--r--src/btree/row_modify.c13
-rw-r--r--src/include/btmem.h48
-rw-r--r--src/reconcile/rec_write.c2
7 files changed, 81 insertions, 78 deletions
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index 839a829b960..e61832a49e5 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -168,8 +168,8 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
return (false);
/*
- * Updates aren't stored on the page, an update would have
- * appeared as an "insert" object; no further checks to do.
+ * An update would have appeared as an "insert" object; no
+ * further checks to do.
*/
break;
case BTREE_COL_VAR:
@@ -179,19 +179,18 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
WT_ASSERT(session, cbt->slot < page->pg_var_entries);
/*
- * Column-store updates aren't stored on the page, instead they
- * are stored as "insert" objects. If search returned an insert
- * object we can't return, the returned on-page object must be
- * checked for a match.
+ * Column-store updates are stored as "insert" objects. If
+ * search returned an insert object we can't return, the
+ * returned on-page object must be checked for a match.
*/
if (cbt->ins != NULL && !F_ISSET(cbt, WT_CBT_VAR_ONPAGE_MATCH))
return (false);
/*
- * Updates aren't stored on the page, an update would have
- * appeared as an "insert" object; however, variable-length
- * column store deletes are written into the backing store,
- * check the cell for a record already deleted when read.
+ * Although updates would have appeared as an "insert" objects,
+ * variable-length column store deletes are written into the
+ * backing store; check the cell for a record already deleted
+ * when read.
*/
cip = &page->pg_var_d[cbt->slot];
if ((cell = WT_COL_PTR(page, cip)) == NULL ||
@@ -211,9 +210,11 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
if (cbt->ins != NULL)
return (false);
- /* Updates are stored on the page, check for a delete. */
- if (page->pg_row_upd != NULL && (upd = __wt_txn_read(
- session, page->pg_row_upd[cbt->slot])) != NULL) {
+ /* Check for an update. */
+ if (page->modify != NULL &&
+ page->modify->mod_row_update != NULL &&
+ (upd = __wt_txn_read(session,
+ page->modify->mod_row_update[cbt->slot])) != NULL) {
if (WT_UPDATE_DELETED_ISSET(upd))
return (false);
if (updp != NULL)
@@ -596,9 +597,12 @@ __curfile_update_check(WT_CURSOR_BTREE *cbt)
return (0);
if (cbt->ins != NULL)
return (__wt_txn_update_check(session, cbt->ins->upd));
- if (btree->type == BTREE_ROW && cbt->ref->page->pg_row_upd != NULL)
- return (__wt_txn_update_check(
- session, cbt->ref->page->pg_row_upd[cbt->slot]));
+
+ if (btree->type == BTREE_ROW &&
+ cbt->ref->page->modify != NULL &&
+ cbt->ref->page->modify->mod_row_update != NULL)
+ return (__wt_txn_update_check(session,
+ cbt->ref->page->modify->mod_row_update[cbt->slot]));
return (0);
}
diff --git a/src/btree/bt_delete.c b/src/btree/bt_delete.c
index ba16dd204e8..54b7fedb31d 100644
--- a/src/btree/bt_delete.c
+++ b/src/btree/bt_delete.c
@@ -288,10 +288,9 @@ __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref)
* read-only or if the application never modifies the tree, we're not
* able to do so.)
*/
- if (btree->modified) {
- WT_RET(__wt_page_modify_init(session, page));
+ WT_RET(__wt_page_modify_init(session, page));
+ if (btree->modified)
__wt_page_modify_set(session, page);
- }
/*
* An operation is accessing a "deleted" page, and we're building an
@@ -326,7 +325,7 @@ __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref)
/* Allocate the per-page update array. */
WT_ERR(__wt_calloc_def(session, page->pg_row_entries, &upd_array));
- page->pg_row_upd = upd_array;
+ page->modify->mod_row_update = upd_array;
/*
* Fill in the per-reference update array with references to update
diff --git a/src/btree/bt_discard.c b/src/btree/bt_discard.c
index 4674efe8c44..509333551c4 100644
--- a/src/btree/bt_discard.c
+++ b/src/btree/bt_discard.c
@@ -204,6 +204,23 @@ __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page)
WT_PAGE_COL_FIX ? 1 : page->pg_var_entries,
update_ignore);
break;
+ case WT_PAGE_ROW_LEAF:
+ /*
+ * Free the insert array.
+ *
+ * Row-store tables have one additional slot in the insert array
+ * (the insert array has an extra slot to hold keys that sort
+ * before keys found on the original page).
+ */
+ if (mod->mod_row_insert != NULL)
+ __free_skip_array(session, mod->mod_row_insert,
+ page->pg_row_entries + 1, update_ignore);
+
+ /* Free the update array. */
+ if (mod->mod_row_update != NULL)
+ __free_update(session, mod->mod_row_update,
+ page->pg_row_entries, update_ignore);
+ break;
}
/* Free the overflow on-page, reuse and transaction-cache skiplists. */
@@ -324,10 +341,6 @@ __free_page_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page)
WT_ROW *rip;
uint32_t i;
void *copy;
- bool update_ignore;
-
- /* In some failed-split cases, we can't discard updates. */
- update_ignore = F_ISSET_ATOMIC(page, WT_PAGE_UPDATE_IGNORE);
/*
* Free the in-memory index array.
@@ -342,22 +355,6 @@ __free_page_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page)
page, copy, &ikey, NULL, NULL, NULL);
__wt_free(session, ikey);
}
-
- /*
- * Free the insert array.
- *
- * Row-store tables have one additional slot in the insert array (the
- * insert array has an extra slot to hold keys that sort before keys
- * found on the original page).
- */
- if (page->pg_row_ins != NULL)
- __free_skip_array(session,
- page->pg_row_ins, page->pg_row_entries + 1, update_ignore);
-
- /* Free the update array. */
- if (page->pg_row_upd != NULL)
- __free_update(session,
- page->pg_row_upd, page->pg_row_entries, update_ignore);
}
/*
diff --git a/src/btree/bt_split.c b/src/btree/bt_split.c
index d06ad1d34e7..341bc0309d9 100644
--- a/src/btree/bt_split.c
+++ b/src/btree/bt_split.c
@@ -1520,7 +1520,7 @@ __split_multi_inmem(
/* Build a key. */
if (supd->ins == NULL) {
slot = WT_ROW_SLOT(orig, supd->rip);
- upd = orig->pg_row_upd[slot];
+ upd = orig->modify->mod_row_update[slot];
WT_ERR(__wt_row_leaf_key(
session, orig, supd->rip, key, false));
@@ -1583,7 +1583,7 @@ __split_multi_inmem_final(WT_PAGE *orig, WT_MULTI *multi)
case WT_PAGE_ROW_LEAF:
if (supd->ins == NULL) {
slot = WT_ROW_SLOT(orig, supd->rip);
- orig->pg_row_upd[slot] = NULL;
+ orig->modify->mod_row_update[slot] = NULL;
} else
supd->ins->upd = NULL;
break;
@@ -1783,8 +1783,10 @@ __split_insert(WT_SESSION_IMPL *session, WT_REF *ref)
__wt_page_modify_set(session, right);
if (type == WT_PAGE_ROW_LEAF) {
- WT_ERR(__wt_calloc_one(session, &right->pg_row_ins));
- WT_ERR(__wt_calloc_one(session, &right->pg_row_ins[0]));
+ WT_ERR(__wt_calloc_one(
+ session, &right->modify->mod_row_insert));
+ WT_ERR(__wt_calloc_one(
+ session, &right->modify->mod_row_insert[0]));
} else {
WT_ERR(__wt_calloc_one(
session, &right->modify->mod_col_append));
@@ -1840,7 +1842,7 @@ __split_insert(WT_SESSION_IMPL *session, WT_REF *ref)
* can be ignored.)
*/
tmp_ins_head = type == WT_PAGE_ROW_LEAF ?
- right->pg_row_ins[0] : right->modify->mod_col_append[0];
+ right->modify->mod_row_insert[0] : right->modify->mod_col_append[0];
tmp_ins_head->head[0] = tmp_ins_head->tail[0] = moved_ins;
/*
@@ -1975,8 +1977,8 @@ __split_insert(WT_SESSION_IMPL *session, WT_REF *ref)
* lists have.
*/
if (type == WT_PAGE_ROW_LEAF)
- right->pg_row_ins[0]->head[0] =
- right->pg_row_ins[0]->tail[0] = NULL;
+ right->modify->mod_row_insert[0]->head[0] =
+ right->modify->mod_row_insert[0]->tail[0] = NULL;
else
right->modify->mod_col_append[0]->head[0] =
right->modify->mod_col_append[0]->tail[0] = NULL;
diff --git a/src/btree/row_modify.c b/src/btree/row_modify.c
index 176016bb340..f0424ff93b4 100644
--- a/src/btree/row_modify.c
+++ b/src/btree/row_modify.c
@@ -53,6 +53,7 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
WT_INSERT *ins;
WT_INSERT_HEAD *ins_head, **ins_headp;
WT_PAGE *page;
+ WT_PAGE_MODIFY *mod;
WT_UPDATE *old_upd, *upd, **upd_entry;
size_t ins_size, upd_size;
uint32_t ins_slot;
@@ -70,6 +71,7 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
/* If we don't yet have a modify structure, we'll need one. */
WT_RET(__wt_page_modify_init(session, page));
+ mod = page->modify;
/*
* Modify: allocate an update array as necessary, build a WT_UPDATE
@@ -83,11 +85,12 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
if (cbt->compare == 0) {
if (cbt->ins == NULL) {
/* Allocate an update array as necessary. */
- WT_PAGE_ALLOC_AND_SWAP(session, page,
- page->pg_row_upd, upd_entry, page->pg_row_entries);
+ WT_PAGE_ALLOC_AND_SWAP(session,
+ page, mod->mod_row_update,
+ upd_entry, page->pg_row_entries);
/* Set the WT_UPDATE array reference. */
- upd_entry = &page->pg_row_upd[cbt->slot];
+ upd_entry = &mod->mod_row_update[cbt->slot];
} else
upd_entry = &cbt->ins->upd;
@@ -144,11 +147,11 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt,
* slot. That's hard, so we set a flag.
*/
WT_PAGE_ALLOC_AND_SWAP(session, page,
- page->pg_row_ins, ins_headp, page->pg_row_entries + 1);
+ mod->mod_row_insert, ins_headp, page->pg_row_entries + 1);
ins_slot = F_ISSET(cbt, WT_CBT_SEARCH_SMALLEST) ?
page->pg_row_entries: cbt->slot;
- ins_headp = &page->pg_row_ins[ins_slot];
+ ins_headp = &mod->mod_row_insert[ins_slot];
/* Allocate the WT_INSERT_HEAD structure as necessary. */
WT_PAGE_ALLOC_AND_SWAP(session, page, *ins_headp, ins_head, 1);
diff --git a/src/include/btmem.h b/src/include/btmem.h
index 0b43a3f7302..9700b6f4761 100644
--- a/src/include/btmem.h
+++ b/src/include/btmem.h
@@ -355,6 +355,17 @@ struct __wt_page_modify {
#define mod_col_update u2.column_leaf.update
#undef mod_col_split_recno
#define mod_col_split_recno u2.column_leaf.split_recno
+ struct {
+ /* Inserted items for row-store. */
+ WT_INSERT_HEAD **insert;
+
+ /* Updated items for row-stores. */
+ WT_UPDATE **update;
+ } row_leaf;
+#undef mod_row_insert
+#define mod_row_insert u2.row_leaf.insert
+#undef mod_row_update
+#define mod_row_update u2.row_leaf.update
} u2;
/*
@@ -487,28 +498,11 @@ struct __wt_page {
/* Row-store leaf page. */
struct {
- /*
- * The column-store leaf page modification structures
- * live in the WT_PAGE_MODIFY structure to keep the
- * WT_PAGE structure as small as possible for read-only
- * pages. For consistency, we could move the row-store
- * modification structures into WT_PAGE_MODIFY too, but
- * that doesn't shrink WT_PAGE any further and it would
- * require really ugly naming inside of WT_PAGE_MODIFY
- * to avoid growing that structure.
- */
- WT_INSERT_HEAD **ins; /* Inserts */
- WT_UPDATE **upd; /* Updates */
-
WT_ROW *d; /* Key/value pairs */
uint32_t entries; /* Entries */
} row;
#undef pg_row_d
#define pg_row_d u.row.d
-#undef pg_row_ins
-#define pg_row_ins u.row.ins
-#undef pg_row_upd
-#define pg_row_upd u.row.upd
#undef pg_row_entries
#define pg_row_entries u.row.entries
@@ -1008,12 +1002,15 @@ struct __wt_insert_head {
* of pointers and the specific structure exist, else NULL.
*/
#define WT_ROW_INSERT_SLOT(page, slot) \
- ((page)->pg_row_ins == NULL ? NULL : (page)->pg_row_ins[slot])
+ ((page)->modify == NULL || \
+ (page)->modify->mod_row_insert == NULL ? \
+ NULL : (page)->modify->mod_row_insert[slot])
#define WT_ROW_INSERT(page, ip) \
WT_ROW_INSERT_SLOT(page, WT_ROW_SLOT(page, ip))
#define WT_ROW_UPDATE(page, ip) \
- ((page)->pg_row_upd == NULL ? \
- NULL : (page)->pg_row_upd[WT_ROW_SLOT(page, ip)])
+ ((page)->modify == NULL || \
+ (page)->modify->mod_row_update == NULL ? \
+ NULL : (page)->modify->mod_row_update[WT_ROW_SLOT(page, ip)])
/*
* WT_ROW_INSERT_SMALLEST references an additional slot past the end of the
* the "one per WT_ROW slot" insert array. That's because the insert array
@@ -1021,8 +1018,9 @@ struct __wt_insert_head {
* original page.
*/
#define WT_ROW_INSERT_SMALLEST(page) \
- ((page)->pg_row_ins == NULL ? \
- NULL : (page)->pg_row_ins[(page)->pg_row_entries])
+ ((page)->modify == NULL || \
+ (page)->modify->mod_row_insert == NULL ? \
+ NULL : (page)->modify->mod_row_insert[(page)->pg_row_entries])
/*
* The column-store leaf page update lists are arrays of pointers to structures,
@@ -1048,9 +1046,9 @@ struct __wt_insert_head {
* appends.
*/
#define WT_COL_APPEND(page) \
- ((page)->modify != NULL && \
- (page)->modify->mod_col_append != NULL ? \
- (page)->modify->mod_col_append[0] : NULL)
+ ((page)->modify == NULL || \
+ (page)->modify->mod_col_append == NULL ? \
+ NULL : (page)->modify->mod_col_append[0])
/* WT_FIX_FOREACH walks fixed-length bit-fields on a disk page. */
#define WT_FIX_FOREACH(btree, dsk, v, i) \
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 06550065c27..05225db8a94 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -3431,7 +3431,7 @@ __rec_update_las(WT_SESSION_IMPL *session,
case WT_PAGE_ROW_LEAF:
if (list->ins == NULL) {
slot = WT_ROW_SLOT(page, list->rip);
- upd = page->pg_row_upd[slot];
+ upd = page->modify->mod_row_update[slot];
} else
upd = list->ins->upd;
break;