Commit f51eb30b authored by unknown's avatar unknown

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.
parent 1c8f5500
...@@ -1286,8 +1286,9 @@ buf_page_optimistic_get_func( ...@@ -1286,8 +1286,9 @@ buf_page_optimistic_get_func(
/* If AWE is used, block may have a different frame now, e.g., NULL */ /* 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)); mutex_exit(&(buf_pool->mutex));
return(FALSE); return(FALSE);
...@@ -1320,19 +1321,17 @@ buf_page_optimistic_get_func( ...@@ -1320,19 +1321,17 @@ buf_page_optimistic_get_func(
fix_type = MTR_MEMO_PAGE_X_FIX; fix_type = MTR_MEMO_PAGE_X_FIX;
} }
if (!success) { if (UNIV_UNLIKELY(!success)) {
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
block->buf_fix_count--; block->buf_fix_count--;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_s_unlock(&(block->debug_latch)); rw_lock_s_unlock(&(block->debug_latch));
#endif #endif
mutex_exit(&(buf_pool->mutex)); goto exit_func;
return(FALSE);
} }
if (!UT_DULINT_EQ(modify_clock, block->modify_clock)) { if (UNIV_UNLIKELY(!UT_DULINT_EQ(modify_clock, block->modify_clock))) {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(block->frame, SYNC_NO_ORDER_CHECK); buf_page_dbg_add_level(block->frame, SYNC_NO_ORDER_CHECK);
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
...@@ -1347,10 +1346,8 @@ buf_page_optimistic_get_func( ...@@ -1347,10 +1346,8 @@ buf_page_optimistic_get_func(
block->buf_fix_count--; block->buf_fix_count--;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_s_unlock(&(block->debug_latch)); rw_lock_s_unlock(&(block->debug_latch));
#endif #endif
mutex_exit(&(buf_pool->mutex)); goto exit_func;
return(FALSE);
} }
mtr_memo_push(mtr, block, fix_type); mtr_memo_push(mtr, block, fix_type);
...@@ -1368,7 +1365,7 @@ buf_page_optimistic_get_func( ...@@ -1368,7 +1365,7 @@ buf_page_optimistic_get_func(
#ifdef UNIV_DEBUG_FILE_ACCESSES #ifdef UNIV_DEBUG_FILE_ACCESSES
ut_a(block->file_page_was_freed == FALSE); ut_a(block->file_page_was_freed == FALSE);
#endif #endif
if (!accessed) { if (UNIV_UNLIKELY(!accessed)) {
/* In the case of a first access, try to apply linear /* In the case of a first access, try to apply linear
read-ahead */ read-ahead */
......
...@@ -48,16 +48,11 @@ mtr_memo_slot_release( ...@@ -48,16 +48,11 @@ mtr_memo_slot_release(
object = slot->object; object = slot->object;
type = slot->type; type = slot->type;
if (object != NULL) { if (UNIV_LIKELY(object != NULL)) {
if (type <= MTR_MEMO_BUF_FIX) { if (type <= MTR_MEMO_BUF_FIX) {
buf_page_release((buf_block_t*)object, type, mtr); buf_page_release((buf_block_t*)object, type, mtr);
} else if (type == MTR_MEMO_S_LOCK) { } else if (type == MTR_MEMO_S_LOCK) {
rw_lock_s_unlock((rw_lock_t*)object); rw_lock_s_unlock((rw_lock_t*)object);
#ifndef UNIV_DEBUG
} else {
rw_lock_x_unlock((rw_lock_t*)object);
}
#endif
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
} else if (type == MTR_MEMO_X_LOCK) { } else if (type == MTR_MEMO_X_LOCK) {
rw_lock_x_unlock((rw_lock_t*)object); rw_lock_x_unlock((rw_lock_t*)object);
...@@ -65,8 +60,11 @@ mtr_memo_slot_release( ...@@ -65,8 +60,11 @@ mtr_memo_slot_release(
ut_ad(type == MTR_MEMO_MODIFY); ut_ad(type == MTR_MEMO_MODIFY);
ut_ad(mtr_memo_contains(mtr, object, ut_ad(mtr_memo_contains(mtr, object,
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
} #else
} else {
rw_lock_x_unlock((rw_lock_t*)object);
#endif #endif
}
} }
slot->object = NULL; slot->object = NULL;
......
...@@ -451,6 +451,20 @@ cmp_dtuple_rec_with_match( ...@@ -451,6 +451,20 @@ cmp_dtuple_rec_with_match(
ut_ad(cur_field <= dtuple_get_n_fields_cmp(dtuple)); ut_ad(cur_field <= dtuple_get_n_fields_cmp(dtuple));
ut_ad(cur_field <= rec_offs_n_fields(offsets)); 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 /* Match fields in a loop; stop if we run out of fields in dtuple
or find an externally stored field */ or find an externally stored field */
...@@ -469,32 +483,7 @@ cmp_dtuple_rec_with_match( ...@@ -469,32 +483,7 @@ cmp_dtuple_rec_with_match(
the predefined minimum record, or the field is externally the predefined minimum record, or the field is externally
stored */ stored */
if (cur_bytes == 0) { if (UNIV_LIKELY(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 (rec_offs_nth_extern(offsets, cur_field)) { if (rec_offs_nth_extern(offsets, cur_field)) {
/* We do not compare to an externally /* We do not compare to an externally
stored field */ stored field */
...@@ -504,24 +493,20 @@ cmp_dtuple_rec_with_match( ...@@ -504,24 +493,20 @@ cmp_dtuple_rec_with_match(
goto order_resolved; goto order_resolved;
} }
if (dtuple_f_len == UNIV_SQL_NULL if (dtuple_f_len == UNIV_SQL_NULL) {
|| rec_f_len == UNIV_SQL_NULL) { if (rec_f_len == UNIV_SQL_NULL) {
if (dtuple_f_len == rec_f_len) {
goto next_field; goto next_field;
} }
if (rec_f_len == UNIV_SQL_NULL) { ret = -1;
/* We define the SQL null to be the goto order_resolved;
smallest possible value of a field } else if (rec_f_len == UNIV_SQL_NULL) {
in the alphabetical order */ /* We define the SQL null to be the
smallest possible value of a field
ret = 1; in the alphabetical order */
} else {
ret = -1;
}
ret = 1;
goto order_resolved; goto order_resolved;
} }
} }
...@@ -555,7 +540,7 @@ cmp_dtuple_rec_with_match( ...@@ -555,7 +540,7 @@ cmp_dtuple_rec_with_match(
/* Compare then the fields */ /* Compare then the fields */
for (;;) { for (;;) {
if (rec_f_len <= cur_bytes) { if (UNIV_UNLIKELY(rec_f_len <= cur_bytes)) {
if (dtuple_f_len <= cur_bytes) { if (dtuple_f_len <= cur_bytes) {
goto next_field; goto next_field;
...@@ -572,7 +557,7 @@ cmp_dtuple_rec_with_match( ...@@ -572,7 +557,7 @@ cmp_dtuple_rec_with_match(
rec_byte = *rec_b_ptr; 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); dtuple_byte = dtype_get_pad_char(cur_type);
if (dtuple_byte == ULINT_UNDEFINED) { if (dtuple_byte == ULINT_UNDEFINED) {
...@@ -600,14 +585,16 @@ cmp_dtuple_rec_with_match( ...@@ -600,14 +585,16 @@ cmp_dtuple_rec_with_match(
rec_byte = cmp_collate(rec_byte); rec_byte = cmp_collate(rec_byte);
dtuple_byte = cmp_collate(dtuple_byte); dtuple_byte = cmp_collate(dtuple_byte);
} }
if (dtuple_byte > rec_byte) {
ret = 1;
goto order_resolved;
} else if (dtuple_byte < rec_byte) { ret = dtuple_byte - rec_byte;
ret = -1; if (UNIV_UNLIKELY(ret)) {
goto order_resolved; if (ret < 0) {
ret = -1;
goto order_resolved;
} else {
ret = 1;
goto order_resolved;
}
} }
next_byte: next_byte:
/* Next byte */ /* Next byte */
...@@ -983,12 +970,8 @@ cmp_debug_dtuple_rec_with_match( ...@@ -983,12 +970,8 @@ cmp_debug_dtuple_rec_with_match(
if (rec_get_info_bits(rec, rec_offs_comp(offsets)) if (rec_get_info_bits(rec, rec_offs_comp(offsets))
& REC_INFO_MIN_REC_FLAG) { & REC_INFO_MIN_REC_FLAG) {
if (dtuple_get_info_bits(dtuple) ret = !(dtuple_get_info_bits(dtuple)
& REC_INFO_MIN_REC_FLAG) { & REC_INFO_MIN_REC_FLAG);
ret = 0;
} else {
ret = 1;
}
goto order_resolved; goto order_resolved;
} }
......
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