Commit 9a999469 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Recude sizeof(mtr_t)

Use bit-fields for some mtr_t members to improve locality of reference.
Because mtr_t is never shared between threads, there are no considerations
regarding concurrent access.
parent 8b6cfda6
...@@ -161,10 +161,13 @@ struct mtr_t { ...@@ -161,10 +161,13 @@ struct mtr_t {
/** X-latch a not yet latched block after a savepoint. */ /** X-latch a not yet latched block after a savepoint. */
inline void x_latch_at_savepoint(ulint savepoint, buf_block_t* block); inline void x_latch_at_savepoint(ulint savepoint, buf_block_t* block);
/** Get the logging mode. /** @return the logging mode */
@return logging mode */ mtr_log_t get_log_mode() const
inline mtr_log_t get_log_mode() const {
MY_ATTRIBUTE((warn_unused_result)); ut_ad(m_log_mode >= MTR_LOG_ALL);
ut_ad(m_log_mode <= MTR_LOG_SHORT_INSERTS);
return static_cast<mtr_log_t>(m_log_mode);
}
/** Change the logging mode. /** Change the logging mode.
@param mode logging mode @param mode logging mode
...@@ -302,31 +305,26 @@ struct mtr_t { ...@@ -302,31 +305,26 @@ struct mtr_t {
@param[in] type object type: MTR_MEMO_PAGE_X_FIX, ... */ @param[in] type object type: MTR_MEMO_PAGE_X_FIX, ... */
void release_page(const void* ptr, mtr_memo_type_t type); void release_page(const void* ptr, mtr_memo_type_t type);
/** Note that the mini-transaction has modified data. */ /** Note that the mini-transaction has modified data. */
void set_modified() { m_modifications = true; } void set_modified() { m_modifications = true; }
/** Set the state to not-modified. This will not log the /** Set the state to not-modified. This will not log the changes.
changes. This is only used during redo log apply, to avoid This is only used during redo log apply, to avoid logging the changes. */
logging the changes. */ void discard_modifications() { m_modifications = false; }
void discard_modifications() { m_modifications = false; }
/** Get the LSN of commit(). /** Get the LSN of commit().
@return the commit LSN @return the commit LSN
@retval 0 if the transaction only modified temporary tablespaces */ @retval 0 if the transaction only modified temporary tablespaces */
lsn_t commit_lsn() const lsn_t commit_lsn() const { ut_ad(has_committed()); return m_commit_lsn; }
{
ut_ad(has_committed());
return(m_commit_lsn);
}
/** Note that we are inside the change buffer code. */ /** Note that we are inside the change buffer code. */
void enter_ibuf() { m_inside_ibuf = true; } void enter_ibuf() { m_inside_ibuf= true; }
/** Note that we have exited from the change buffer code. */ /** Note that we have exited from the change buffer code. */
void exit_ibuf() { m_inside_ibuf = false; } void exit_ibuf() { m_inside_ibuf= false; }
/** @return true if we are inside the change buffer code */ /** @return true if we are inside the change buffer code */
bool is_inside_ibuf() const { return m_inside_ibuf; } bool is_inside_ibuf() const { return m_inside_ibuf; }
/** Get flush observer /** Get flush observer
@return flush observer */ @return flush observer */
...@@ -500,41 +498,41 @@ struct mtr_t { ...@@ -500,41 +498,41 @@ struct mtr_t {
bool m_commit= false; bool m_commit= false;
#endif #endif
/** memo stack for locks etc. */ /** specifies which operations should be logged; default MTR_LOG_ALL */
mtr_buf_t m_memo; uint16_t m_log_mode:2;
/** mini-transaction log */
mtr_buf_t m_log;
/** true if mtr has made at least one buffer pool page dirty */ /** whether at least one buffer pool page was written to */
bool m_made_dirty; uint16_t m_modifications:1;
/** true if inside ibuf changes */ /** whether at least one previously clean buffer pool page was written to */
bool m_inside_ibuf; uint16_t m_made_dirty:1;
/** true if the mini-transaction modified buffer pool pages */ /** whether change buffer is latched; only needed in non-debug builds
bool m_modifications; to suppress some read-ahead operations, @see ibuf_inside() */
uint16_t m_inside_ibuf:1;
/** Count of how many page initial log records have been /** number of m_log records */
written to the mtr log */ uint16_t m_n_log_recs:13;
ib_uint32_t m_n_log_recs;
/** specifies which operations should be logged; default
value MTR_LOG_ALL */
mtr_log_t m_log_mode;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/** Persistent user tablespace associated with the /** Persistent user tablespace associated with the
mini-transaction, or 0 (TRX_SYS_SPACE) if none yet */ mini-transaction, or 0 (TRX_SYS_SPACE) if none yet */
ulint m_user_space_id; uint32_t m_user_space_id;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/** User tablespace that is being modified by the mini-transaction */
fil_space_t* m_user_space;
/** Flush Observer */ /** acquired dict_index_t::lock, fil_space_t::latch, buf_block_t */
FlushObserver* m_flush_observer; mtr_buf_t m_memo;
/** mini-transaction log */
mtr_buf_t m_log;
/** user tablespace that is being modified by the mini-transaction */
fil_space_t* m_user_space;
/** page flush observer for innodb_log_optimize_ddl=ON */
FlushObserver *m_flush_observer;
/** LSN at commit time */ /** LSN at commit time */
lsn_t m_commit_lsn; lsn_t m_commit_lsn;
}; };
#include "mtr0mtr.ic" #include "mtr0mtr.ic"
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation. Copyright (c) 2017, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -177,19 +177,6 @@ mtr_t::release_block_at_savepoint( ...@@ -177,19 +177,6 @@ mtr_t::release_block_at_savepoint(
slot->object = NULL; slot->object = NULL;
} }
/**
Gets the logging mode of a mini-transaction.
@return logging mode: MTR_LOG_NONE, ... */
mtr_log_t
mtr_t::get_log_mode() const
{
ut_ad(m_log_mode >= MTR_LOG_ALL);
ut_ad(m_log_mode <= MTR_LOG_SHORT_INSERTS);
return m_log_mode;
}
/** /**
Changes the logging mode of a mini-transaction. Changes the logging mode of a mini-transaction.
@return old mode */ @return old mode */
...@@ -200,7 +187,7 @@ mtr_t::set_log_mode(mtr_log_t mode) ...@@ -200,7 +187,7 @@ mtr_t::set_log_mode(mtr_log_t mode)
ut_ad(mode >= MTR_LOG_ALL); ut_ad(mode >= MTR_LOG_ALL);
ut_ad(mode <= MTR_LOG_SHORT_INSERTS); ut_ad(mode <= MTR_LOG_SHORT_INSERTS);
const mtr_log_t old_mode = m_log_mode; const mtr_log_t old_mode = get_log_mode();
switch (old_mode) { switch (old_mode) {
case MTR_LOG_NO_REDO: case MTR_LOG_NO_REDO:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment