Commit e773660d authored by marko's avatar marko

branches/zip: btr_cur_optimistic_insert(): Optimize some tests,

eliminate some local variables, and add branching hints.
parent 0178dba1
...@@ -1053,14 +1053,12 @@ btr_cur_optimistic_insert( ...@@ -1053,14 +1053,12 @@ btr_cur_optimistic_insert(
page_cur_t* page_cursor; page_cur_t* page_cursor;
buf_block_t* block; buf_block_t* block;
page_t* page; page_t* page;
page_zip_des_t* page_zip;
ulint max_size; ulint max_size;
rec_t* dummy_rec; rec_t* dummy_rec;
ulint level; ulint level;
ibool reorg; ibool reorg;
ibool inherit; ibool inherit;
ulint rec_size; ulint rec_size;
ulint type;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint err; ulint err;
...@@ -1069,7 +1067,6 @@ btr_cur_optimistic_insert( ...@@ -1069,7 +1067,6 @@ btr_cur_optimistic_insert(
block = btr_cur_get_block(cursor); block = btr_cur_get_block(cursor);
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
index = cursor->index; index = cursor->index;
page_zip = buf_block_get_page_zip(block);
if (!dtuple_check_typed_no_assert(entry)) { if (!dtuple_check_typed_no_assert(entry)) {
fputs("InnoDB: Error in a tuple to insert into ", stderr); fputs("InnoDB: Error in a tuple to insert into ", stderr);
...@@ -1089,8 +1086,8 @@ btr_cur_optimistic_insert( ...@@ -1089,8 +1086,8 @@ btr_cur_optimistic_insert(
/* Calculate the record size when entry is converted to a record */ /* Calculate the record size when entry is converted to a record */
rec_size = rec_get_converted_size(index, entry, ext, n_ext); rec_size = rec_get_converted_size(index, entry, ext, n_ext);
if (page_zip_rec_needs_ext(rec_size, page_is_comp(page), page_zip if (page_zip_rec_needs_ext(rec_size, page_is_comp(page),
? page_zip_get_size(page_zip) : 0)) { buf_block_get_zip_size(block))) {
/* The record is so big that we have to store some fields /* The record is so big that we have to store some fields
externally on separate database pages */ externally on separate database pages */
...@@ -1100,18 +1097,18 @@ btr_cur_optimistic_insert( ...@@ -1100,18 +1097,18 @@ btr_cur_optimistic_insert(
return(DB_TOO_BIG_RECORD); return(DB_TOO_BIG_RECORD);
} }
rec_size = rec_get_converted_size(index, entry, ext, n_ext);
} }
/* If there have been many consecutive inserts, and we are on the leaf /* If there have been many consecutive inserts, and we are on the leaf
level, check if we have to split the page to reserve enough free space level, check if we have to split the page to reserve enough free space
for future updates of records. */ for future updates of records. */
type = index->type; if (dict_index_is_clust(index)
if ((type & DICT_CLUSTERED)
&& (dict_index_get_space_reserve() + rec_size > max_size)
&& (page_get_n_recs(page) >= 2) && (page_get_n_recs(page) >= 2)
&& (0 == level) && UNIV_LIKELY(0 == level)
&& (dict_index_get_space_reserve() + rec_size > max_size)
&& (btr_page_get_split_rec_to_right(cursor, &dummy_rec) && (btr_page_get_split_rec_to_right(cursor, &dummy_rec)
|| btr_page_get_split_rec_to_left(cursor, &dummy_rec))) { || btr_page_get_split_rec_to_left(cursor, &dummy_rec))) {
fail: fail:
...@@ -1122,10 +1119,10 @@ btr_cur_optimistic_insert( ...@@ -1122,10 +1119,10 @@ btr_cur_optimistic_insert(
return(DB_FAIL); return(DB_FAIL);
} }
if (!(((max_size >= rec_size) if (UNIV_UNLIKELY(max_size < BTR_CUR_PAGE_REORGANIZE_LIMIT
&& (max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)) || max_size < rec_size)
|| (page_get_max_insert_size(page, 1) >= rec_size) && UNIV_LIKELY(page_get_n_recs(page) > 1)
|| (page_get_n_recs(page) <= 1))) { && page_get_max_insert_size(page, 1) < rec_size) {
goto fail; goto fail;
} }
...@@ -1157,7 +1154,7 @@ btr_cur_optimistic_insert( ...@@ -1157,7 +1154,7 @@ btr_cur_optimistic_insert(
if (UNIV_UNLIKELY(!(*rec))) { if (UNIV_UNLIKELY(!(*rec))) {
/* If the record did not fit, reorganize */ /* If the record did not fit, reorganize */
if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) { if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) {
ut_a(page_zip); ut_a(buf_block_get_page_zip(block));
goto fail; goto fail;
} }
...@@ -1172,7 +1169,7 @@ btr_cur_optimistic_insert( ...@@ -1172,7 +1169,7 @@ btr_cur_optimistic_insert(
ext, n_ext, mtr); ext, n_ext, mtr);
if (UNIV_UNLIKELY(!*rec)) { if (UNIV_UNLIKELY(!*rec)) {
if (UNIV_LIKELY(page_zip != NULL)) { if (UNIV_LIKELY(buf_block_get_page_zip(block) != 0)) {
goto fail; goto fail;
} }
...@@ -1208,9 +1205,9 @@ btr_cur_optimistic_insert( ...@@ -1208,9 +1205,9 @@ btr_cur_optimistic_insert(
fprintf(stderr, "Insert into page %lu, max ins size %lu," fprintf(stderr, "Insert into page %lu, max ins size %lu,"
" rec %lu ind type %lu\n", " rec %lu ind type %lu\n",
buf_block_get_page_no(block), max_size, buf_block_get_page_no(block), max_size,
rec_size + PAGE_DIR_SLOT_SIZE, type); rec_size + PAGE_DIR_SLOT_SIZE, index->type);
#endif #endif
if (!(type & DICT_CLUSTERED)) { if (!dict_index_is_clust(index)) {
/* We have added a record to page: update its free bits */ /* We have added a record to page: update its free bits */
ibuf_update_free_bits_if_full(cursor->index, block, max_size, ibuf_update_free_bits_if_full(cursor->index, block, max_size,
rec_size + PAGE_DIR_SLOT_SIZE); rec_size + PAGE_DIR_SLOT_SIZE);
......
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