MDEV-22523 index->rtr_ssn.mutex is wasting memory
As part of the SPATIAL INDEX implementation in InnoDB, dict_index_t was expanded by a rtr_ssn_t field. There are only 3 operations for this field, all protected by rtr_ssn_t::mutex: * btr_cur_search_to_nth_level() stores the least significant 32 bits of the 64-bit value that is stored in the index root page. (This would better be done when the table is opened for the very first time.) * rtr_get_new_ssn_id() increments the value by 1. * rtr_get_current_ssn_id() reads the current value. All these operations can be implemented equally safely by using atomic memory access operations.
This commit is contained in:
parent
4ae778bbec
commit
ba3d58ad4c
@ -1475,10 +1475,9 @@ retry_page_get:
|
||||
node_seq_t root_seq_no;
|
||||
|
||||
root_seq_no = page_get_ssn_id(page);
|
||||
|
||||
mutex_enter(&(index->rtr_ssn.mutex));
|
||||
index->rtr_ssn.seq_no = root_seq_no + 1;
|
||||
mutex_exit(&(index->rtr_ssn.mutex));
|
||||
my_atomic_store32_explicit(
|
||||
&index->rtr_ssn, root_seq_no + 1,
|
||||
MY_MEMORY_ORDER_RELAXED);
|
||||
}
|
||||
|
||||
/* Save the MBR */
|
||||
|
@ -741,7 +741,6 @@ dict_mem_index_create(
|
||||
dict_index_zip_pad_mutex_create_lazy(index);
|
||||
|
||||
if (type & DICT_SPATIAL) {
|
||||
mutex_create(LATCH_ID_RTR_SSN_MUTEX, &index->rtr_ssn.mutex);
|
||||
index->rtr_track = static_cast<rtr_info_track_t*>(
|
||||
mem_heap_alloc(
|
||||
heap,
|
||||
@ -1067,7 +1066,6 @@ dict_mem_index_free(
|
||||
rtr_info->index = NULL;
|
||||
}
|
||||
|
||||
mutex_destroy(&index->rtr_ssn.mutex);
|
||||
mutex_destroy(&index->rtr_track->rtr_active_mutex);
|
||||
UT_DELETE(index->rtr_track->rtr_active);
|
||||
}
|
||||
|
@ -626,7 +626,6 @@ static PSI_mutex_info all_innodb_mutexes[] = {
|
||||
PSI_KEY(rtr_active_mutex),
|
||||
PSI_KEY(rtr_match_mutex),
|
||||
PSI_KEY(rtr_path_mutex),
|
||||
PSI_KEY(rtr_ssn_mutex),
|
||||
PSI_KEY(trx_sys_mutex),
|
||||
PSI_KEY(zip_pad_mutex)
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2012, Facebook Inc.
|
||||
Copyright (c) 2013, 2019, MariaDB Corporation.
|
||||
Copyright (c) 2013, 2020, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -964,7 +964,8 @@ struct dict_index_t{
|
||||
/* in which slot the next sample should be
|
||||
saved. */
|
||||
/* @} */
|
||||
rtr_ssn_t rtr_ssn;/*!< Node sequence number for RTree */
|
||||
/** R-tree split sequence number */
|
||||
volatile int32 rtr_ssn;
|
||||
rtr_info_track_t*
|
||||
rtr_track;/*!< tracking all R-Tree search cursors */
|
||||
trx_id_t trx_id; /*!< id of the transaction that created this
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2017, MariaDB Corporation.
|
||||
Copyright (c) 2017, 2020, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -132,13 +132,9 @@ rtr_get_new_ssn_id(
|
||||
/*===============*/
|
||||
dict_index_t* index) /*!< in/out: the index struct */
|
||||
{
|
||||
node_seq_t ssn;
|
||||
|
||||
mutex_enter(&(index->rtr_ssn.mutex));
|
||||
ssn = ++index->rtr_ssn.seq_no;
|
||||
mutex_exit(&(index->rtr_ssn.mutex));
|
||||
|
||||
return(ssn);
|
||||
node_seq_t ssn= my_atomic_add32_explicit(&index->rtr_ssn, 1,
|
||||
MY_MEMORY_ORDER_RELAXED);
|
||||
return ssn + 1;
|
||||
}
|
||||
/*****************************************************************//**
|
||||
Get the current Split Sequence Number.
|
||||
@ -149,13 +145,7 @@ rtr_get_current_ssn_id(
|
||||
/*===================*/
|
||||
dict_index_t* index) /*!< in: index struct */
|
||||
{
|
||||
node_seq_t ssn;
|
||||
|
||||
mutex_enter(&(index->rtr_ssn.mutex));
|
||||
ssn = index->rtr_ssn.seq_no;
|
||||
mutex_exit(&(index->rtr_ssn.mutex));
|
||||
|
||||
return(ssn);
|
||||
return my_atomic_load32_explicit(&index->rtr_ssn, MY_MEMORY_ORDER_RELAXED);
|
||||
}
|
||||
|
||||
/*********************************************************************//**
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2018, MariaDB Corporation.
|
||||
Copyright (c) 2018, 2020, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -143,12 +143,6 @@ typedef struct rtr_info_track {
|
||||
rtr_active */
|
||||
} rtr_info_track_t;
|
||||
|
||||
/* Node Sequence Number and mutex protects it. */
|
||||
typedef struct rtree_ssn {
|
||||
ib_mutex_t mutex; /*!< mutex protect the seq num */
|
||||
node_seq_t seq_no; /*!< the SSN (node sequence number) */
|
||||
} rtr_ssn_t;
|
||||
|
||||
/* This is to record the record movement between pages. Used for corresponding
|
||||
lock movement */
|
||||
typedef struct rtr_rec_move {
|
||||
|
@ -3,6 +3,7 @@
|
||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2008, Google Inc.
|
||||
Copyright (c) 2012, Facebook Inc.
|
||||
Copyright (c) 2020, MariaDB Corporation.
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
Google, Inc. Those modifications are gratefully acknowledged and are described
|
||||
@ -81,7 +82,6 @@ extern mysql_pfs_key_t recv_writer_mutex_key;
|
||||
extern mysql_pfs_key_t rtr_active_mutex_key;
|
||||
extern mysql_pfs_key_t rtr_match_mutex_key;
|
||||
extern mysql_pfs_key_t rtr_path_mutex_key;
|
||||
extern mysql_pfs_key_t rtr_ssn_mutex_key;
|
||||
extern mysql_pfs_key_t redo_rseg_mutex_key;
|
||||
extern mysql_pfs_key_t noredo_rseg_mutex_key;
|
||||
extern mysql_pfs_key_t page_zip_stat_per_index_mutex_key;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2017, 2018, MariaDB Corporation.
|
||||
Copyright (c) 2017, 2020, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -327,7 +327,6 @@ enum latch_id_t {
|
||||
LATCH_ID_REDO_RSEG,
|
||||
LATCH_ID_NOREDO_RSEG,
|
||||
LATCH_ID_RW_LOCK_DEBUG,
|
||||
LATCH_ID_RTR_SSN_MUTEX,
|
||||
LATCH_ID_RTR_ACTIVE_MUTEX,
|
||||
LATCH_ID_RTR_MATCH_MUTEX,
|
||||
LATCH_ID_RTR_PATH_MUTEX,
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2017, 2018, MariaDB Corporation.
|
||||
Copyright (c) 2017, 2020, MariaDB Corporation.
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
Google, Inc. Those modifications are gratefully acknowledged and are described
|
||||
@ -383,8 +383,7 @@ private:
|
||||
{
|
||||
return(latch->get_id() == LATCH_ID_RTR_ACTIVE_MUTEX
|
||||
|| latch->get_id() == LATCH_ID_RTR_PATH_MUTEX
|
||||
|| latch->get_id() == LATCH_ID_RTR_MATCH_MUTEX
|
||||
|| latch->get_id() == LATCH_ID_RTR_SSN_MUTEX);
|
||||
|| latch->get_id() == LATCH_ID_RTR_MATCH_MUTEX);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1375,8 +1374,6 @@ sync_latch_meta_init()
|
||||
rw_lock_debug_mutex_key);
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
LATCH_ADD_MUTEX(RTR_SSN_MUTEX, SYNC_ANY_LATCH, rtr_ssn_mutex_key);
|
||||
|
||||
LATCH_ADD_MUTEX(RTR_ACTIVE_MUTEX, SYNC_ANY_LATCH,
|
||||
rtr_active_mutex_key);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
Copyright (c) 2008, Google Inc.
|
||||
Copyright (c) 2020, MariaDB Corporation.
|
||||
|
||||
Portions of this file contain modifications contributed and copyrighted by
|
||||
Google, Inc. Those modifications are gratefully acknowledged and are described
|
||||
@ -73,7 +74,6 @@ mysql_pfs_key_t rw_lock_debug_mutex_key;
|
||||
mysql_pfs_key_t rtr_active_mutex_key;
|
||||
mysql_pfs_key_t rtr_match_mutex_key;
|
||||
mysql_pfs_key_t rtr_path_mutex_key;
|
||||
mysql_pfs_key_t rtr_ssn_mutex_key;
|
||||
mysql_pfs_key_t rw_lock_list_mutex_key;
|
||||
mysql_pfs_key_t rw_lock_mutex_key;
|
||||
mysql_pfs_key_t srv_innodb_monitor_mutex_key;
|
||||
|
Loading…
x
Reference in New Issue
Block a user