MDEV-23991 dict_table_stats_lock() has unnecessarily long scope

Patch removes dict_index_t::stats_latch. Table/index statistics now
protected with dict_sys->mutex. That way statistics computation can
happen in parallel in several threads and dict_sys->mutex will be locked
only for a short period of time.

This patch is a joint work with Marko Mäkelä

dict_index_t:🔒 make mutable which allows to pass const pointer
when only lock is touched in an object

btr_height_get()
btr_get_size(): make index argument const for better type safety

btr_estimate_number_of_different_key_vals(): now returns computed values
instead of setting fields in dict_index_t directly

remove everything related to dict_index_t::stats_latch

dict_stats_index_set_n_diff(): now returns computed values instead
of setting fields in dict_index_t directly

dict_stats_analyze_index():  now returns computed values instead
of setting fields in dict_index_t directly

Reviewed by: Marko Mäkelä
This commit is contained in:
Eugene Kosov 2020-10-27 12:24:55 +03:00
commit afc9d00c66
21 changed files with 289 additions and 280 deletions

View file

@ -125,8 +125,7 @@ dict_mem_table_create(
ulint n_cols,
ulint n_v_cols,
ulint flags,
ulint flags2,
bool init_stats_latch)
ulint flags2)
{
dict_table_t* table;
mem_heap_t* heap;
@ -182,12 +181,6 @@ dict_mem_table_create(
new(&table->foreign_set) dict_foreign_set();
new(&table->referenced_set) dict_foreign_set();
if (init_stats_latch) {
rw_lock_create(dict_table_stats_key, &table->stats_latch,
SYNC_INDEX_TREE);
table->stats_latch_inited = true;
}
return(table);
}
@ -237,10 +230,6 @@ dict_mem_table_free(
UT_DELETE(table->s_cols);
}
if (table->stats_latch_inited) {
rw_lock_free(&table->stats_latch);
}
mem_heap_free(table->heap);
}