diff options
author | unknown <marko@hundin.mysql.fi> | 2005-04-22 15:47:46 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2005-04-22 15:47:46 +0300 |
commit | f51eb30b5a9f769ebe1af8cbd56fc6f3183d4bb3 (patch) | |
tree | 1752616269ea663882fa62451283e57b384d24e3 /innobase | |
parent | 1c8f5500963814507754e878e092fdc76ebce6a7 (diff) | |
download | mariadb-git-f51eb30b5a9f769ebe1af8cbd56fc6f3183d4bb3.tar.gz |
rem0cmp.c:
Add UNIV_LIKELY and UNIV_UNLIKELY hints.
cmp_dtuple_rec_with_match(): Move condition outside loop.
Reduce the number of comparisons per iteration.
mtr0mtr.c:
mtr_memo_slot_release(): Add a UNIV_LIKELY hint.
Simplify the preprocessor magic.
buf0buf.c:
buf_page_optimistic_get_func(): Add UNIV_UNLIKELY hints.
Introduce an exit_func label to remove duplicated error exits.
innobase/buf/buf0buf.c:
buf_page_optimistic_get_func(): Add UNIV_UNLIKELY hints.
Introduce an exit_func label to remove duplicated error exits.
innobase/mtr/mtr0mtr.c:
mtr_memo_slot_release(): Add a UNIV_LIKELY hint.
Simplify the preprocessor magic.
innobase/rem/rem0cmp.c:
Add UNIV_LIKELY and UNIV_UNLIKELY hints.
cmp_dtuple_rec_with_match(): Move condition outside loop.
Reduce the number of comparisons per iteration.
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/buf/buf0buf.c | 23 | ||||
-rw-r--r-- | innobase/mtr/mtr0mtr.c | 12 | ||||
-rw-r--r-- | innobase/rem/rem0cmp.c | 91 |
3 files changed, 52 insertions, 74 deletions
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c index 89f851709db..fca0b9f85f8 100644 --- a/innobase/buf/buf0buf.c +++ b/innobase/buf/buf0buf.c @@ -1286,8 +1286,9 @@ buf_page_optimistic_get_func( /* If AWE is used, block may have a different frame now, e.g., NULL */ - if (block->state != BUF_BLOCK_FILE_PAGE || block->frame != guess) { - + if (UNIV_UNLIKELY(block->state != BUF_BLOCK_FILE_PAGE) + || UNIV_UNLIKELY(block->frame != guess)) { + exit_func: mutex_exit(&(buf_pool->mutex)); return(FALSE); @@ -1320,19 +1321,17 @@ buf_page_optimistic_get_func( fix_type = MTR_MEMO_PAGE_X_FIX; } - if (!success) { + if (UNIV_UNLIKELY(!success)) { mutex_enter(&(buf_pool->mutex)); block->buf_fix_count--; #ifdef UNIV_SYNC_DEBUG rw_lock_s_unlock(&(block->debug_latch)); -#endif - mutex_exit(&(buf_pool->mutex)); - - return(FALSE); +#endif + goto exit_func; } - if (!UT_DULINT_EQ(modify_clock, block->modify_clock)) { + if (UNIV_UNLIKELY(!UT_DULINT_EQ(modify_clock, block->modify_clock))) { #ifdef UNIV_SYNC_DEBUG buf_page_dbg_add_level(block->frame, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ @@ -1347,10 +1346,8 @@ buf_page_optimistic_get_func( block->buf_fix_count--; #ifdef UNIV_SYNC_DEBUG rw_lock_s_unlock(&(block->debug_latch)); -#endif - mutex_exit(&(buf_pool->mutex)); - - return(FALSE); +#endif + goto exit_func; } mtr_memo_push(mtr, block, fix_type); @@ -1368,7 +1365,7 @@ buf_page_optimistic_get_func( #ifdef UNIV_DEBUG_FILE_ACCESSES ut_a(block->file_page_was_freed == FALSE); #endif - if (!accessed) { + if (UNIV_UNLIKELY(!accessed)) { /* In the case of a first access, try to apply linear read-ahead */ diff --git a/innobase/mtr/mtr0mtr.c b/innobase/mtr/mtr0mtr.c index 6e918806eb1..da045be1f62 100644 --- a/innobase/mtr/mtr0mtr.c +++ b/innobase/mtr/mtr0mtr.c @@ -48,16 +48,11 @@ mtr_memo_slot_release( object = slot->object; type = slot->type; - if (object != NULL) { + if (UNIV_LIKELY(object != NULL)) { if (type <= MTR_MEMO_BUF_FIX) { buf_page_release((buf_block_t*)object, type, mtr); } else if (type == MTR_MEMO_S_LOCK) { rw_lock_s_unlock((rw_lock_t*)object); -#ifndef UNIV_DEBUG - } else { - rw_lock_x_unlock((rw_lock_t*)object); - } -#endif #ifdef UNIV_DEBUG } else if (type == MTR_MEMO_X_LOCK) { rw_lock_x_unlock((rw_lock_t*)object); @@ -65,8 +60,11 @@ mtr_memo_slot_release( ut_ad(type == MTR_MEMO_MODIFY); ut_ad(mtr_memo_contains(mtr, object, MTR_MEMO_PAGE_X_FIX)); - } +#else + } else { + rw_lock_x_unlock((rw_lock_t*)object); #endif + } } slot->object = NULL; diff --git a/innobase/rem/rem0cmp.c b/innobase/rem/rem0cmp.c index f8aed202586..0a918d0e470 100644 --- a/innobase/rem/rem0cmp.c +++ b/innobase/rem/rem0cmp.c @@ -451,6 +451,20 @@ cmp_dtuple_rec_with_match( ut_ad(cur_field <= dtuple_get_n_fields_cmp(dtuple)); ut_ad(cur_field <= rec_offs_n_fields(offsets)); + if (cur_bytes == 0 && cur_field == 0) { + ulint rec_info = rec_get_info_bits(rec, + rec_offs_comp(offsets)); + ulint tup_info = dtuple_get_info_bits(dtuple); + + if (rec_info & REC_INFO_MIN_REC_FLAG) { + ret = !(tup_info & REC_INFO_MIN_REC_FLAG); + goto order_resolved; + } else if (tup_info & REC_INFO_MIN_REC_FLAG) { + ret = -1; + goto order_resolved; + } + } + /* Match fields in a loop; stop if we run out of fields in dtuple or find an externally stored field */ @@ -469,32 +483,7 @@ cmp_dtuple_rec_with_match( the predefined minimum record, or the field is externally stored */ - if (cur_bytes == 0) { - if (cur_field == 0) { - - if (rec_get_info_bits(rec, - rec_offs_comp(offsets)) - & REC_INFO_MIN_REC_FLAG) { - - if (dtuple_get_info_bits(dtuple) - & REC_INFO_MIN_REC_FLAG) { - - ret = 0; - } else { - ret = 1; - } - - goto order_resolved; - } - - if (dtuple_get_info_bits(dtuple) - & REC_INFO_MIN_REC_FLAG) { - ret = -1; - - goto order_resolved; - } - } - + if (UNIV_LIKELY(cur_bytes == 0)) { if (rec_offs_nth_extern(offsets, cur_field)) { /* We do not compare to an externally stored field */ @@ -504,24 +493,20 @@ cmp_dtuple_rec_with_match( goto order_resolved; } - if (dtuple_f_len == UNIV_SQL_NULL - || rec_f_len == UNIV_SQL_NULL) { - - if (dtuple_f_len == rec_f_len) { + if (dtuple_f_len == UNIV_SQL_NULL) { + if (rec_f_len == UNIV_SQL_NULL) { goto next_field; } - if (rec_f_len == UNIV_SQL_NULL) { - /* We define the SQL null to be the - smallest possible value of a field - in the alphabetical order */ - - ret = 1; - } else { - ret = -1; - } + ret = -1; + goto order_resolved; + } else if (rec_f_len == UNIV_SQL_NULL) { + /* We define the SQL null to be the + smallest possible value of a field + in the alphabetical order */ + ret = 1; goto order_resolved; } } @@ -555,7 +540,7 @@ cmp_dtuple_rec_with_match( /* Compare then the fields */ for (;;) { - if (rec_f_len <= cur_bytes) { + if (UNIV_UNLIKELY(rec_f_len <= cur_bytes)) { if (dtuple_f_len <= cur_bytes) { goto next_field; @@ -572,7 +557,7 @@ cmp_dtuple_rec_with_match( rec_byte = *rec_b_ptr; } - if (dtuple_f_len <= cur_bytes) { + if (UNIV_UNLIKELY(dtuple_f_len <= cur_bytes)) { dtuple_byte = dtype_get_pad_char(cur_type); if (dtuple_byte == ULINT_UNDEFINED) { @@ -600,14 +585,16 @@ cmp_dtuple_rec_with_match( rec_byte = cmp_collate(rec_byte); dtuple_byte = cmp_collate(dtuple_byte); } - - if (dtuple_byte > rec_byte) { - ret = 1; - goto order_resolved; - } else if (dtuple_byte < rec_byte) { - ret = -1; - goto order_resolved; + ret = dtuple_byte - rec_byte; + if (UNIV_UNLIKELY(ret)) { + if (ret < 0) { + ret = -1; + goto order_resolved; + } else { + ret = 1; + goto order_resolved; + } } next_byte: /* Next byte */ @@ -983,12 +970,8 @@ cmp_debug_dtuple_rec_with_match( if (rec_get_info_bits(rec, rec_offs_comp(offsets)) & REC_INFO_MIN_REC_FLAG) { - if (dtuple_get_info_bits(dtuple) - & REC_INFO_MIN_REC_FLAG) { - ret = 0; - } else { - ret = 1; - } + ret = !(dtuple_get_info_bits(dtuple) + & REC_INFO_MIN_REC_FLAG); goto order_resolved; } |