List:Commits« Previous MessageNext Message »
From:marko.makela Date:October 27 2010 7:07am
Subject:bzr push into mysql-5.5-innodb branch (marko.makela:3204 to 3206) Bug#57707
View as plain text  
 3206 Marko Mäkelä	2010-10-27
      Bug #57707 InnoDB buf_page_t size has doubled on 32-bit systems
      
      buf_page_t: Remove the buf_pool pointer. Add buf_pool_index:6 next to
      buf_fix_count:19 (it was buf_fix_count:25). This will limit the number
      of concurrent transactions to somewhere around 524,288.
      
      buf_pool_index(buf_pool): A new function to determine the index of a
      buffer pool in buf_pool_ptr[].
      
      buf_pool_ptr: Make this a dynamically allocated array instead of an
      array of pointers. Allocate the array in buf_pool_init() and free in
      buf_pool_free().
      
      buf_pool_free_instance(): No longer free the buf_pool object, as it is
      allocated from a big array.
      
      buf_pool_from_bpage(), buf_pool_from_block(): Move the definitions to
      the beginning of the files, because some compilers have (had) problems
      with forward definitions of inline functions. Calculate the buffer
      pool from buf_pool_index.
      
      buf_pool_from_array(): Add debug assertions for input validation.

    modified:
      storage/innobase/buf/buf0buf.c
      storage/innobase/include/buf0buf.h
      storage/innobase/include/buf0buf.ic
 3205 Marko Mäkelä	2010-10-27
      Bug #57730 Clean up references to InnoDB Plugin
      
      CMakeLists.txt: Remove the checks for mysql_storage_engine.cmake
      and MYSQL_VERSION_ID.
      
      ha_innodb.cc, ha_innodb.h: Remove the checks for MYSQL_VERSION_ID.

    modified:
      storage/innobase/CMakeLists.txt
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/ha_innodb.h
 3204 Inaam Rana	2010-10-26
      Fix compiler warning introduced by previous commit.

    modified:
      storage/innobase/include/trx0undo.h
      storage/innobase/trx/trx0trx.c
      storage/innobase/trx/trx0undo.c
=== modified file 'storage/innobase/CMakeLists.txt'
--- a/storage/innobase/CMakeLists.txt	revid:inaam.rana@strippedp42
+++ b/storage/innobase/CMakeLists.txt	revid:marko.makela@stripped
@@ -13,7 +13,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
-# This is the CMakeLists for InnoDB Plugin
+# This is the CMakeLists for InnoDB
 
 INCLUDE(CheckFunctionExists)
 INCLUDE(CheckCSourceCompiles)
@@ -254,29 +254,7 @@ IF(WITH_INNODB)
   SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
 ENDIF()
 
-
-#The plugin's CMakeLists.txt still needs to work with previous versions of MySQL.
-IF(EXISTS ${SOURCE_DIR}/storage/mysql_storage_engine.cmake)
-	# Old plugin support on Windows only, 
-	# use tricks to force ha_innodb.dll name for DLL
-	INCLUDE(${SOURCE_DIR}/storage/mysql_storage_engine.cmake)
-	MYSQL_STORAGE_ENGINE(INNOBASE)
-	GET_TARGET_PROPERTY(LIB_LOCATION ha_innobase LOCATION)
-	IF(LIB_LOCATION)
-		SET_TARGET_PROPERTIES(ha_innobase PROPERTIES OUTPUT_NAME ha_innodb)
-	ENDIF()
-ELSEIF (MYSQL_VERSION_ID LESS "50137")
-	# Windows only, no plugin support
-	IF (NOT SOURCE_SUBLIBS)
-		ADD_DEFINITIONS(-DMYSQL_SERVER)
-		ADD_LIBRARY(innobase STATIC ${INNOBASE_SOURCES})
-		# Require mysqld_error.h, which is built as part of the GenError
-		ADD_DEPENDENCIES(innobase GenError)
-	ENDIF()
-ELSE()
-	# New plugin support, cross-platform ,  base name for shared module is "ha_innodb"
-	MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE 
-		DEFAULT
-		MODULE_OUTPUT_NAME ha_innodb
-		LINK_LIBRARIES ${ZLIB_LIBRARY})
-ENDIF()
+MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE 
+  DEFAULT
+  MODULE_OUTPUT_NAME ha_innodb
+  LINK_LIBRARIES ${ZLIB_LIBRARY})

=== modified file 'storage/innobase/buf/buf0buf.c'
--- a/storage/innobase/buf/buf0buf.c	revid:inaam.rana@stripped2
+++ b/storage/innobase/buf/buf0buf.c	revid:marko.makela@oracle.com-20101027065656-gru5r7k3qqyu64l9
@@ -246,8 +246,8 @@ static const int WAIT_FOR_READ	= 5000;
 /** Number of attemtps made to read in a page in the buffer pool */
 static const ulint BUF_PAGE_READ_MAX_RETRIES = 100;
 
-/** The buffer buf_pool of the database */
-UNIV_INTERN buf_pool_t*	buf_pool_ptr[MAX_BUFFER_POOLS];
+/** The buffer pools of the database */
+UNIV_INTERN buf_pool_t*	buf_pool_ptr;
 
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
 static ulint	buf_dbg_counter	= 0; /*!< This is used to insert validation
@@ -858,7 +858,7 @@ buf_block_init(
 
 	block->frame = frame;
 
-	block->page.buf_pool = buf_pool;
+	block->page.buf_pool_index = buf_pool_index(buf_pool);
 	block->page.state = BUF_BLOCK_NOT_USED;
 	block->page.buf_fix_count = 0;
 	block->page.io_fix = BUF_IO_NONE;
@@ -1280,8 +1280,6 @@ buf_pool_free_instance(
 	mem_free(buf_pool->chunks);
 	hash_table_free(buf_pool->page_hash);
 	hash_table_free(buf_pool->zip_hash);
-	mem_free(buf_pool);
-	buf_pool = NULL;
 }
 
 /********************************************************************//**
@@ -1294,25 +1292,22 @@ buf_pool_init(
 	ulint	total_size,	/*!< in: size of the total pool in bytes */
 	ulint	n_instances)	/*!< in: number of instances */
 {
-	ulint	i;
+	ulint		i;
+	const ulint	size	= total_size / n_instances;
+
+	ut_ad(n_instances < MAX_BUFFER_POOLS);
+	ut_ad(n_instances == srv_buf_pool_instances);
 
 	/* We create an extra buffer pool instance, this instance is used
 	for flushing the flush lists, to keep track of n_flush for all
 	the buffer pools and also used as a waiting object during flushing. */
-	for (i = 0; i < n_instances; i++) {
-		buf_pool_t*	ptr;
-		ulint		size;
-
-		ptr = mem_zalloc(sizeof(*ptr));
+	buf_pool_ptr = mem_zalloc(n_instances * sizeof *buf_pool_ptr);
 
-		size = total_size / n_instances;
-
-		buf_pool_ptr[i] = ptr;
+	for (i = 0; i < n_instances; i++) {
+		buf_pool_t*	ptr	= &buf_pool_ptr[i];
 
 		if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) {
 
-			mem_free(buf_pool_ptr[i]);
-
 			/* Free all the instances created so far. */
 			buf_pool_free(i);
 
@@ -1341,8 +1336,10 @@ buf_pool_free(
 
 	for (i = 0; i < n_instances; i++) {
 		buf_pool_free_instance(buf_pool_from_array(i));
-		buf_pool_ptr[i] = NULL;
 	}
+
+	mem_free(buf_pool_ptr);
+	buf_pool_ptr = NULL;
 }
 
 /********************************************************************//**
@@ -3685,7 +3682,7 @@ err_exit:
 		bpage = buf_buddy_alloc(buf_pool, sizeof *bpage, &lru);
 
 		/* Initialize the buf_pool pointer. */
-		bpage->buf_pool = buf_pool;
+		bpage->buf_pool_index = buf_pool_index(buf_pool);
 
 		/* If buf_buddy_alloc() allocated storage from the LRU list,
 		it released and reacquired buf_pool->mutex.  Thus, we must

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	revid:inaam.rana@stripped
+++ b/storage/innobase/handler/ha_innodb.cc	revid:marko.makela@oracle.com-20101027065656-gru5r7k3qqyu64l9
@@ -95,10 +95,6 @@ extern "C" {
 #  define MYSQL_PLUGIN_IMPORT /* nothing */
 # endif /* MYSQL_PLUGIN_IMPORT */
 
-#if MYSQL_VERSION_ID < 50124
-bool check_global_access(THD *thd, ulong want_access);
-#endif /* MYSQL_VERSION_ID < 50124 */
-
 /** to protect innobase_open_files */
 static mysql_mutex_t innobase_share_mutex;
 /** to force correct commit order in binlog */
@@ -1885,11 +1881,7 @@ innobase_convert_identifier(
 				FALSE=id is an UTF-8 string */
 {
 	char nz[NAME_LEN + 1];
-#if MYSQL_VERSION_ID >= 50141
 	char nz2[NAME_LEN + 1 + EXPLAIN_FILENAME_MAX_EXTRA_LENGTH];
-#else /* MYSQL_VERSION_ID >= 50141 */
-	char nz2[NAME_LEN + 1 + sizeof srv_mysql50_table_name_prefix];
-#endif /* MYSQL_VERSION_ID >= 50141 */
 
 	const char*	s	= id;
 	int		q;
@@ -1907,13 +1899,9 @@ innobase_convert_identifier(
 		nz[idlen] = 0;
 
 		s = nz2;
-#if MYSQL_VERSION_ID >= 50141
 		idlen = explain_filename((THD*) thd, nz, nz2, sizeof nz2,
 					 EXPLAIN_PARTITIONS_AS_COMMENT);
 		goto no_quote;
-#else /* MYSQL_VERSION_ID >= 50141 */
-		idlen = filename_to_tablename(nz, nz2, sizeof nz2);
-#endif /* MYSQL_VERSION_ID >= 50141 */
 	}
 
 	/* See if the identifier needs to be quoted. */
@@ -1924,9 +1912,7 @@ innobase_convert_identifier(
 	}
 
 	if (q == EOF) {
-#if MYSQL_VERSION_ID >= 50141
 no_quote:
-#endif /* MYSQL_VERSION_ID >= 50141 */
 		if (UNIV_UNLIKELY(idlen > buflen)) {
 			idlen = buflen;
 		}

=== modified file 'storage/innobase/handler/ha_innodb.h'
--- a/storage/innobase/handler/ha_innodb.h	revid:inaam.rana@strippedr8zp42
+++ b/storage/innobase/handler/ha_innodb.h	revid:marko.makela@stripped
@@ -276,14 +276,13 @@ int thd_binlog_format(const MYSQL_THD th
 */
 void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all);
 
-#if MYSQL_VERSION_ID > 50140
 /**
   Check if binary logging is filtered for thread's current db.
   @param  thd   Thread handle
   @retval 1 the query is not filtered, 0 otherwise.
 */
 bool thd_binlog_filter_ok(const MYSQL_THD thd);
-#endif /* MYSQL_VERSION_ID > 50140 */
+
 /**
   Check if the query may generate row changes which
   may end up in the binary.

=== modified file 'storage/innobase/include/buf0buf.h'
--- a/storage/innobase/include/buf0buf.h	revid:inaam.rana@stripped27014558-ax7egimco5r8zp42
+++ b/storage/innobase/include/buf0buf.h	revid:marko.makela@strippedu5r7k3qqyu64l9
@@ -69,7 +69,7 @@ Created 11/5/1995 Heikki Tuuri
 #define BUF_POOL_WATCH_SIZE 1		/*!< Maximum number of concurrent
 					buffer pool watches */
 
-extern	buf_pool_t*	buf_pool_ptr[MAX_BUFFER_POOLS]; /*!< The buffer pools
+extern	buf_pool_t*	buf_pool_ptr;	/*!< The buffer pools
 					of the database */
 #ifdef UNIV_DEBUG
 extern ibool		buf_debug_prints;/*!< If this is set TRUE, the program
@@ -1034,6 +1034,15 @@ buf_page_address_fold(
 	ulint	space,	/*!< in: space id */
 	ulint	offset)	/*!< in: offset of the page within space */
 	__attribute__((const));
+/********************************************************************//**
+Calculates the index of a buffer pool to the buf_pool[] array.
+@return	the position of the buffer pool in buf_pool[] */
+UNIV_INLINE
+ulint
+buf_pool_index(
+/*===========*/
+	const buf_pool_t*	buf_pool)	/*!< in: buffer pool */
+	__attribute__((nonnull, const));
 /******************************************************************//**
 Returns the buffer pool instance given a page instance
 @return buf_pool */
@@ -1065,8 +1074,9 @@ Returns the buffer pool instance given i
 UNIV_INLINE
 buf_pool_t*
 buf_pool_from_array(
-/*====================*/
-	ulint	index);	/*!< in: array index to get buffer pool instance from */
+/*================*/
+	ulint	index);		/*!< in: array index to get
+				buffer pool instance from */
 /******************************************************************//**
 Returns the control block of a file page, NULL if not found.
 @return	block, NULL if not found */
@@ -1204,8 +1214,13 @@ struct buf_page_struct{
 	unsigned	io_fix:2;	/*!< type of pending I/O operation;
 					also protected by buf_pool->mutex
 					@see enum buf_io_fix */
-	unsigned	buf_fix_count:25;/*!< count of how manyfold this block
+	unsigned	buf_fix_count:19;/*!< count of how manyfold this block
 					is currently bufferfixed */
+	unsigned	buf_pool_index:6;/*!< index number of the buffer pool
+					that this block belongs to */
+# if MAX_BUFFER_POOLS > 64
+#  error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6"
+# endif
 	/* @} */
 #endif /* !UNIV_HOTBACKUP */
 	page_zip_des_t	zip;		/*!< compressed page; zip.data
@@ -1324,8 +1339,6 @@ struct buf_page_struct{
 					frees a page in buffer pool */
 # endif /* UNIV_DEBUG_FILE_ACCESSES */
 #endif /* !UNIV_HOTBACKUP */
-	buf_pool_t*	buf_pool;	/*!< buffer pool instance this
-					page belongs to */
 };
 
 /** The buffer control block structure */

=== modified file 'storage/innobase/include/buf0buf.ic'
--- a/storage/innobase/include/buf0buf.ic	revid:inaam.rana@stripped
+++ b/storage/innobase/include/buf0buf.ic	revid:marko.makela@stripped
@@ -46,6 +46,48 @@ buf_pool_get_curr_size(void)
 	return(srv_buf_pool_curr_size);
 }
 
+/********************************************************************//**
+Calculates the index of a buffer pool to the buf_pool[] array.
+@return	the position of the buffer pool in buf_pool[] */
+UNIV_INLINE
+ulint
+buf_pool_index(
+/*===========*/
+	const buf_pool_t*	buf_pool)	/*!< in: buffer pool */
+{
+	ulint	i = buf_pool - buf_pool_ptr;
+	ut_ad(i < MAX_BUFFER_POOLS);
+	ut_ad(i < srv_buf_pool_instances);
+	return(i);
+}
+
+/******************************************************************//**
+Returns the buffer pool instance given a page instance
+@return buf_pool */
+UNIV_INLINE
+buf_pool_t*
+buf_pool_from_bpage(
+/*================*/
+	const buf_page_t*	bpage) /*!< in: buffer pool page */
+{
+	ulint	i;
+	i = bpage->buf_pool_index;
+	ut_ad(i < srv_buf_pool_instances);
+	return(&buf_pool_ptr[i]);
+}
+
+/******************************************************************//**
+Returns the buffer pool instance given a block instance
+@return buf_pool */
+UNIV_INLINE
+buf_pool_t*
+buf_pool_from_block(
+/*================*/
+	const buf_block_t*	block) /*!< in: block */
+{
+	return(buf_pool_from_bpage(&block->page));
+}
+
 /*********************************************************************//**
 Gets the current size of buffer buf_pool in pages.
 @return size in pages*/
@@ -886,33 +928,6 @@ buf_block_buf_fix_dec(
 }
 
 /******************************************************************//**
-Returns the buffer pool instance given a page instance
-@return buf_pool */
-UNIV_INLINE
-buf_pool_t*
-buf_pool_from_bpage(
-/*================*/
-	const buf_page_t*	bpage) /*!< in: buffer pool page */
-{
-	/* Every page must be in some buffer pool. */
-	ut_ad(bpage->buf_pool != NULL);
-
-	return(bpage->buf_pool);
-}
-
-/******************************************************************//**
-Returns the buffer pool instance given a block instance
-@return buf_pool */
-UNIV_INLINE
-buf_pool_t*
-buf_pool_from_block(
-/*================*/
-	const buf_block_t*	block) /*!< in: block */
-{
-	return(buf_pool_from_bpage(&block->page));
-}
-
-/******************************************************************//**
 Returns the buffer pool instance given space and offset of page
 @return buffer pool */
 UNIV_INLINE
@@ -929,7 +944,7 @@ buf_pool_get(
 	ignored_offset = offset >> 6; /* 2log of BUF_READ_AHEAD_AREA (64)*/
 	fold = buf_page_address_fold(space, ignored_offset);
 	index = fold % srv_buf_pool_instances;
-	return buf_pool_ptr[index];
+	return(&buf_pool_ptr[index]);
 }
 
 /******************************************************************//**
@@ -939,10 +954,12 @@ UNIV_INLINE
 buf_pool_t*
 buf_pool_from_array(
 /*================*/
-	ulint	index) 		/*!< in: array index to get
+	ulint	index)		/*!< in: array index to get
 				buffer pool instance from */
 {
-	return buf_pool_ptr[index];
+	ut_ad(index < MAX_BUFFER_POOLS);
+	ut_ad(index < srv_buf_pool_instances);
+	return(&buf_pool_ptr[index]);
 }
 
 /******************************************************************//**

Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20101027065656-gru5r7k3qqyu64l9.bundle
Thread
bzr push into mysql-5.5-innodb branch (marko.makela:3204 to 3206) Bug#57707marko.makela27 Oct