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/include/gis0rtree.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'storage/innobase/include/gis0rtree.h') diff --git a/storage/innobase/include/gis0rtree.h b/storage/innobase/include/gis0rtree.h index e5942b71c64..ffb6beb922b 100644 --- a/storage/innobase/include/gis0rtree.h +++ b/storage/innobase/include/gis0rtree.h @@ -28,6 +28,7 @@ Created 2013/03/27 Jimmy Yang and Allen Lai #define gis0rtree_h #include "btr0cur.h" +#include "rem0types.h" /* Whether MBR 'a' contains 'b' */ #define MBR_CONTAIN_CMP(a, b) \ @@ -90,7 +91,7 @@ rtr_page_split_and_insert( btr_cur_t* cursor, /*!< in/out: cursor at which to insert; when the function returns, the cursor is positioned on the predecessor of the inserted record */ - ulint** offsets,/*!< out: offsets on inserted record */ + offset_t** offsets,/*!< out: offsets on inserted record */ mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */ const dtuple_t* tuple, /*!< in: tuple to insert */ ulint n_ext, /*!< in: number of externally stored columns */ @@ -152,7 +153,7 @@ rtr_rec_cal_increase( dtuple in some of the common fields, or which has an equal number or more fields than dtuple */ - const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + const offset_t* offsets,/*!< in: array returned by rec_get_offsets() */ double* area); /*!< out: increased area */ /****************************************************************//** @@ -276,7 +277,7 @@ void rtr_get_mbr_from_rec( /*=================*/ const rec_t* rec, /*!< in: data tuple */ - const ulint* offsets,/*!< in: offsets array */ + const offset_t* offsets,/*!< in: offsets array */ rtr_mbr_t* mbr); /*!< out MBR */ /****************************************************************//** @@ -308,10 +309,10 @@ rtr_page_get_father( Returns the father block to a page. It is assumed that mtr holds an X or SX latch on the tree. @return rec_get_offsets() of the node pointer record */ -ulint* +offset_t* rtr_page_get_father_block( /*======================*/ - ulint* offsets,/*!< in: work area for the return value */ + offset_t* offsets,/*!< in: work area for the return value */ mem_heap_t* heap, /*!< in: memory heap to use */ dict_index_t* index, /*!< in: b-tree index */ buf_block_t* block, /*!< in: child page in the index */ @@ -418,8 +419,8 @@ rtr_merge_and_update_mbr( /*=====================*/ btr_cur_t* cursor, /*!< in/out: cursor */ btr_cur_t* cursor2, /*!< in: the other cursor */ - ulint* offsets, /*!< in: rec offsets */ - ulint* offsets2, /*!< in: rec offsets */ + offset_t* offsets, /*!< in: rec offsets */ + offset_t* offsets2, /*!< in: rec offsets */ page_t* child_page, /*!< in: the child page. */ buf_block_t* merge_block, /*!< in: page to merge */ buf_block_t* block, /*!< in: page be merged */ @@ -444,8 +445,8 @@ rtr_merge_mbr_changed( /*==================*/ btr_cur_t* cursor, /*!< in: cursor */ btr_cur_t* cursor2, /*!< in: the other cursor */ - ulint* offsets, /*!< in: rec offsets */ - ulint* offsets2, /*!< in: rec offsets */ + offset_t* offsets, /*!< in: rec offsets */ + offset_t* offsets2, /*!< in: rec offsets */ rtr_mbr_t* new_mbr, /*!< out: MBR to update */ buf_block_t* merge_block, /*!< in: page to merge */ buf_block_t* block, /*!< in: page be merged */ @@ -459,7 +460,7 @@ bool rtr_update_mbr_field( /*=================*/ btr_cur_t* cursor, /*!< in: cursor pointed to rec.*/ - ulint* offsets, /*!< in: offsets on rec. */ + offset_t* offsets, /*!< in: offsets on rec. */ btr_cur_t* cursor2, /*!< in/out: cursor pointed to rec that should be deleted. this cursor is for btr_compress to -- cgit v1.2.1