From f0aa073f2bf3d8d85b3d028df89cdb4cdfc4002d Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 4 Nov 2019 22:30:12 +0300 Subject: MDEV-20950 Reduce size of record offsets offset_t: this is a type which represents one record offset. It's unsigned short int. a lot of functions: replace ulint with offset_t btr_pcur_restore_position_func(), page_validate(), row_ins_scan_sec_index_for_duplicate(), row_upd_clust_rec_by_insert_inherit_func(), row_vers_impl_x_locked_low(), trx_undo_prev_version_build(): allocate record offsets on the stack instead of waiting for rec_get_offsets() to allocate it from mem_heap_t. So, reducing memory allocations. RECORD_OFFSET, INDEX_OFFSET: now it's less convenient to store pointers in offset_t* array. One pointer occupies now several offset_t. And those constant are start indexes into array to places where to store pointer values REC_OFFS_HEADER_SIZE: adjusted for the new reality REC_OFFS_NORMAL_SIZE: increase size from 100 to 300 which means less heap allocations. And sizeof(offset_t[REC_OFFS_NORMAL_SIZE]) now is 600 bytes which is smaller than previous 800 bytes. REC_OFFS_SEC_INDEX_SIZE: adjusted for the new reality rem0rec.h, rem0rec.ic, rem0rec.cc: various arguments, return values and local variables types were changed to fix numerous integer conversions issues. enum field_type_t: offset types concept was introduces which replaces old offset flags stuff. Like in earlier version, 2 upper bits are used to store offset type. And this enum represents those types. REC_OFFS_SQL_NULL, REC_OFFS_MASK: removed get_type(), set_type(), get_value(), combine(): these are convenience functions to work with offsets and it's types rec_offs_base()[0]: still uses an old scheme with flags REC_OFFS_COMPACT and REC_OFFS_EXTERNAL rec_offs_base()[i]: these have type offset_t now. Two upper bits contains type. --- storage/innobase/row/row0row.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'storage/innobase/row/row0row.cc') diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index 3e65dc1d28b..c6aedbe2eb5 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -372,7 +372,7 @@ row_build_low( ulint type, const dict_index_t* index, const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, const dict_table_t* col_table, const dtuple_t* add_cols, const dict_add_v_col_t* add_v, @@ -388,7 +388,7 @@ row_build_low( byte* buf; ulint j; mem_heap_t* tmp_heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; + offset_t offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs_init(offsets_); ut_ad(index != NULL); @@ -435,7 +435,7 @@ row_build_low( } /* Avoid a debug assertion in rec_offs_validate(). */ - rec_offs_make_valid(copy, index, const_cast(offsets)); + rec_offs_make_valid(copy, index, const_cast(offsets)); if (!col_table) { ut_ad(!col_map); @@ -525,7 +525,7 @@ row_build_low( } } - rec_offs_make_valid(rec, index, const_cast(offsets)); + rec_offs_make_valid(rec, index, const_cast(offsets)); ut_ad(dtuple_check_typed(row)); @@ -578,7 +578,7 @@ row_build( this record must be at least s-latched and the latch held as long as the row dtuple is used! */ - const ulint* offsets,/*!< in: rec_get_offsets(rec,index) + const offset_t* offsets,/*!< in: rec_get_offsets(rec,index) or NULL, in which case this function will invoke rec_get_offsets() */ const dict_table_t* col_table, @@ -631,7 +631,7 @@ row_build_w_add_vcol( ulint type, const dict_index_t* index, const rec_t* rec, - const ulint* offsets, + const offset_t* offsets, const dict_table_t* col_table, const dtuple_t* add_cols, const dict_add_v_col_t* add_v, @@ -652,7 +652,7 @@ row_rec_to_index_entry_low( /*=======================*/ const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec, index) */ ulint* n_ext, /*!< out: number of externally stored columns */ mem_heap_t* heap) /*!< in: memory heap from which @@ -716,7 +716,7 @@ row_rec_to_index_entry( /*===================*/ const rec_t* rec, /*!< in: record in the index */ const dict_index_t* index, /*!< in: index */ - const ulint* offsets,/*!< in: rec_get_offsets(rec) */ + const offset_t* offsets,/*!< in: rec_get_offsets(rec) */ ulint* n_ext, /*!< out: number of externally stored columns */ mem_heap_t* heap) /*!< in: memory heap from which @@ -737,10 +737,10 @@ row_rec_to_index_entry( copy_rec = rec_copy(buf, rec, offsets); - rec_offs_make_valid(copy_rec, index, const_cast(offsets)); + rec_offs_make_valid(copy_rec, index, const_cast(offsets)); entry = row_rec_to_index_entry_low( copy_rec, index, offsets, n_ext, heap); - rec_offs_make_valid(rec, index, const_cast(offsets)); + rec_offs_make_valid(rec, index, const_cast(offsets)); dtuple_set_info_bits(entry, rec_get_info_bits(rec, rec_offs_comp(offsets))); @@ -782,8 +782,8 @@ row_build_row_ref( ulint clust_col_prefix_len; ulint i; mem_heap_t* tmp_heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; + offset_t offsets_[REC_OFFS_NORMAL_SIZE]; + offset_t* offsets = offsets_; rec_offs_init(offsets_); ut_ad(index != NULL); @@ -878,7 +878,7 @@ row_build_row_ref_in_tuple( held as long as the row reference is used! */ const dict_index_t* index, /*!< in: secondary index */ - ulint* offsets,/*!< in: rec_get_offsets(rec, index) + offset_t* offsets,/*!< in: rec_get_offsets(rec, index) or NULL */ trx_t* trx) /*!< in: transaction */ { @@ -891,7 +891,7 @@ row_build_row_ref_in_tuple( ulint clust_col_prefix_len; ulint i; mem_heap_t* heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; + offset_t offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs_init(offsets_); ut_ad(!dict_index_is_clust(index)); -- cgit v1.2.1