Hi Laurynas,
As discussed on IRC, I’m only posting comments specific to the port itself. I’ll handle everything else in the followup work on AHI.
On Wed, Aug 28 2013 13:59:04 +0400, Laurynas Biveinis wrote:
[...]
> - btr_search_latch_temp = (rw_lock_t*) mem_alloc(sizeof(rw_lock_t)); > + /* btr_search_index_num should be <= 32. (bits of > + trx->has_search_latch) */ > + ut_ad(btr_search_index_num <= 32);
This assertion is wrong. We allow 64 AHI partitions in 64-bit architectures in 5.5, and its documented. It’s just that the code comment is wrong.
> > - rw_lock_create(btr_search_latch_key, &btr_search_latch, > - SYNC_SEARCH_SYS); > + btr_search_latch_temp_arr = (rw_lock_t**) > + mem_alloc(sizeof(rw_lock_t *) * btr_search_index_num);
What’s so temporal about btr_search_latch_temp_arr[]? It might make sense in the single-lock code (though the reasoning for it is dubious), but it correctly does not have “temp” in 5.5 code, as it’s a regular array.
> index = block->index; > - > - if (UNIV_LIKELY(!index)) { > - > - rw_lock_s_unlock(&btr_search_latch); > - > + if (UNIV_UNLIKELY(!index)) { > + rw_lock_s_unlock(btr_search_latch); > return; > } > > + ut_a(btr_search_latch == btr_search_get_latch(index->id)); > +
Shouldn’t this be a debug assertion? btr_search_latch is basically a constant attribute of each index. So it’s more of a code invariant.
> -btr_search_validate(void) > -/*=====================*/ > +btr_search_validate_one_table( > +/*==========================*/ > + ulint t) > { > ha_node_t* node; > ulint n_page_dumps = 0; > @@ -1874,24 +1944,20 @@ > > rec_offs_init(offsets_); > > - rw_lock_x_lock(&btr_search_latch); > - buf_pool_mutex_enter_all(); > - > - cell_count = hash_get_n_cells(btr_search_sys->hash_index); > + cell_count = hash_get_n_cells(btr_search_sys->hash_index[t]); >
Why buf_pool_mutex_enter_all() / buf_pool_mutex_exit_all() calls are being removed from btr_search_validate[_one_table]()?
> +ha_assert_btr_x_locked( > +/*===================*/ > + const hash_table_t* table) /*!<in: hash table to check */ > +{ > + ulint i; > + > + ut_ad(table->adaptive); > + > + for (i = 0; i < btr_search_index_num; i++) > + if (btr_search_sys->hash_index[i] == table) > + break;
Braces.
> +/********************************************************************//** > +Latches all adaptive hash index latches in shared mode. */ > +UNIV_INLINE > +void > +btr_search_s_lock_all(void); > +/*========================*/ > + > +/********************************************************************//** > +Unlatches all adaptive hash index latches in shared mode. */ > +UNIV_INLINE > +void > +btr_search_s_unlock_all(void); > +/*==========================*/ > +
These ones are declared and defined, but not used.
> === modified file 'Percona-Server/storage/innobase/include/mtr0log.ic' > --- Percona-Server/storage/innobase/include/mtr0log.ic 2013-08-06 15:16:34 +0000 > +++ Percona-Server/storage/innobase/include/mtr0log.ic 2013-08-28 09:57:53 +0000 > @@ -28,6 +28,7 @@ > #include "buf0buf.h" > #include "buf0dblwr.h" > #include "fsp0types.h" > +#include "btr0types.h" > #include "trx0sys.h"
Why new #includes in mtr0log.ic, que0que.h and read0read.h, trx0roll.h, trx0trx.cc, ut0ut.cc and os0file.cc?
> trx_search_latch_release_if_reserved( > @@ -172,7 +172,13 @@ > trx_t* trx) /*!< in: transaction */ > { > if (trx->has_search_latch) {
This “if” is not really needed. Though the entire function will go away along with trx_t::has_search_latch in the followup work.
> - rw_lock_s_unlock(&btr_search_latch); > + ulint i; > + > + for (i = 0; i < btr_search_index_num; i++) { > + if (trx->has_search_latch & (1UL << i)) { > + rw_lock_s_unlock(btr_search_latch_temp_arr[i]); > + } > + } > > trx->has_search_latch = FALSE;
Should assign 0 instead of FALSE technically, but again, this code will be removed later anyway.
> +trx_search_latch_lock( > +/*==================*/ > + trx_t* trx, /*!< in: latching transcation */ > + ulint index_id) /*!< in: index to latch AHI for */ > +{ > + ulint latch_mask = 1UL << (index_id % btr_search_index_num); > + > + if (!(trx->has_search_latch & latch_mask)) { > + > + if (trx->has_search_latch < latch_mask) { > + > + rw_lock_s_lock(btr_search_get_latch(index_id)); > + trx->has_search_latch |= latch_mask; > + } else { > + > + ibool taken_latches = trx->has_search_latch;
ibool? but again, no practical importance and will be removed later anyway.
« Back to merge proposal
Hi Laurynas,
As discussed on IRC, I’m only posting comments specific to the port
itself. I’ll handle everything else in the followup work on AHI.
On Wed, Aug 28 2013 13:59:04 +0400, Laurynas Biveinis wrote:
[...]
> - btr_search_ latch_temp = (rw_lock_t*) mem_alloc( sizeof( rw_lock_ t)); index_num should be <= 32. (bits of search_ latch) */ search_ index_num <= 32);
> + /* btr_search_
> + trx->has_
> + ut_ad(btr_
This assertion is wrong. We allow 64 AHI partitions in 64-bit
architectures in 5.5, and its documented. It’s just that the code
comment is wrong.
> create( btr_search_ latch_key, &btr_search_latch, latch_temp_ arr = (rw_lock_t**) sizeof( rw_lock_ t *) * btr_search_ index_num) ;
> - rw_lock_
> - SYNC_SEARCH_SYS);
> + btr_search_
> + mem_alloc(
What’s so temporal about btr_search_ latch_temp_ arr[]? It might make
sense in the single-lock code (though the reasoning for it is dubious),
but it correctly does not have “temp” in 5.5 code, as it’s a regular array.
[...]
> index = block->index; !index) ) { s_unlock( &btr_search_ latch); !index) ) { s_unlock( btr_search_ latch); search_ latch == btr_search_ get_latch( index-> id));
> -
> - if (UNIV_LIKELY(
> -
> - rw_lock_
> -
> + if (UNIV_UNLIKELY(
> + rw_lock_
> return;
> }
>
> + ut_a(btr_
> +
Shouldn’t this be a debug assertion? btr_search_latch is basically a
constant attribute of each index. So it’s more of a code invariant.
[...]
> -btr_search_ validate( void) ======= ======= ===*/ validate_ one_table( ======= ======= ======= =*/ init(offsets_ ); x_lock( &btr_search_ latch); mutex_enter_ all(); n_cells( btr_search_ sys->hash_ index); n_cells( btr_search_ sys->hash_ index[t] );
> -/*====
> +btr_search_
> +/*====
> + ulint t)
> {
> ha_node_t* node;
> ulint n_page_dumps = 0;
> @@ -1874,24 +1944,20 @@
>
> rec_offs_
>
> - rw_lock_
> - buf_pool_
> -
> - cell_count = hash_get_
> + cell_count = hash_get_
>
Why buf_pool_ mutex_enter_ all() / buf_pool_ mutex_exit_ all() calls are validate[ _one_table] ()?
being removed from btr_search_
[...]
> +ha_assert_ btr_x_locked( ======= ======= =*/ >adaptive) ; index_num; i++) sys->hash_ index[i] == table)
> +/*====
> + const hash_table_t* table) /*!<in: hash table to check */
> +{
> + ulint i;
> +
> + ut_ad(table-
> +
> + for (i = 0; i < btr_search_
> + if (btr_search_
> + break;
Braces.
[...]
> +/***** ******* ******* ******* ******* ******* ******* ******* ******* ******* //** s_lock_ all(void) ; ======= ======= ======* / ******* ******* ******* ******* ******* ******* ******* ******* ******* //** s_unlock_ all(void) ; ======= ======= ======= =*/
> +Latches all adaptive hash index latches in shared mode. */
> +UNIV_INLINE
> +void
> +btr_search_
> +/*====
> +
> +/*****
> +Unlatches all adaptive hash index latches in shared mode. */
> +UNIV_INLINE
> +void
> +btr_search_
> +/*====
> +
These ones are declared and defined, but not used.
[...]
> === modified file 'Percona- Server/ storage/ innobase/ include/ mtr0log. ic' Server/ storage/ innobase/ include/ mtr0log. ic 2013-08-06 15:16:34 +0000 Server/ storage/ innobase/ include/ mtr0log. ic 2013-08-28 09:57:53 +0000
> --- Percona-
> +++ Percona-
> @@ -28,6 +28,7 @@
> #include "buf0buf.h"
> #include "buf0dblwr.h"
> #include "fsp0types.h"
> +#include "btr0types.h"
> #include "trx0sys.h"
Why new #includes in mtr0log.ic, que0que.h and read0read.h, trx0roll.h,
trx0trx.cc, ut0ut.cc and os0file.cc?
[...]
> trx_search_ latch_release_ if_reserved( search_ latch) {
> @@ -172,7 +172,13 @@
> trx_t* trx) /*!< in: transaction */
> {
> if (trx->has_
This “if” is not really needed. Though the entire function will go away has_search_ latch in the followup work.
along with trx_t::
> - rw_lock_ s_unlock( &btr_search_ latch); index_num; i++) { search_ latch & (1UL << i)) { s_unlock( btr_search_ latch_temp_ arr[i]) ; search_ latch = FALSE;
> + ulint i;
> +
> + for (i = 0; i < btr_search_
> + if (trx->has_
> + rw_lock_
> + }
> + }
>
> trx->has_
Should assign 0 instead of FALSE technically, but again, this code will
be removed later anyway.
[...]
> +trx_search_ latch_lock( ======= ======= */ index_num) ; >has_search_ latch & latch_mask)) { search_ latch < latch_mask) { s_lock( btr_search_ get_latch( index_id) ); search_ latch |= latch_mask; search_ latch;
> +/*====
> + trx_t* trx, /*!< in: latching transcation */
> + ulint index_id) /*!< in: index to latch AHI for */
> +{
> + ulint latch_mask = 1UL << (index_id % btr_search_
> +
> + if (!(trx-
> +
> + if (trx->has_
> +
> + rw_lock_
> + trx->has_
> + } else {
> +
> + ibool taken_latches = trx->has_
ibool? but again, no practical importance and will be removed later anyway.