Bug #72466 More memory overhead per page in the InnoDB buffer pool
Submitted: 26 Apr 2014 14:57 Modified: 28 Apr 2014 6:23
Reporter: Mark Callaghan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.4 OS:Any
Assigned to: CPU Architecture:Any

[26 Apr 2014 14:57] Mark Callaghan
Description:
Looking at memory overhead for InnoDB with innodb_page_size=4kb between 5.6.12 and 5.7.4. Used the same build options (PS disabled) and same my.cnf with one exception.
* 5.6 - buffer_pool_size=110G
* 5.7- buffer_pool_size=105G

Looking at VSZ and RSS from ps output shows that 5.7 uses about 2.7% more memory for 5G less in the buffer pool. Normalizing for the differences in buffer_pool_size it uses 7.5% more memory for the same size buffer pool. 

            VSZ              RSS
5.6 -> 132272564 131386384
5.7 -> 135881780 134215368

How to repeat:
my.cnf for 5.7.4 listed below

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

table-definition-cache=1000
table-open-cache=2000
table-open-cache-instances=1
max_connections=2000
key_buffer_size=200M
metadata_locks_hash_instances=256 
query_cache_size=0
query_cache_type=0
skip_log_bin

innodb_buffer_pool_instances=8
innodb_io_capacity=16000
innodb_lru_scan_depth=2000
innodb_checksum_algorithm=CRC32
innodb_thread_concurrency=0
# innodb_log_file_size=1900M
innodb_log_file_size=3900M
innodb_flush_log_at_trx_commit=2
innodb_doublewrite=0
innodb_thread_concurrency=0
innodb_max_dirty_pages_pct=80
innodb_max_dirty_pages_pct_lwm=0
innodb_file_format=barracuda
innodb_file_per_table

default_tmp_storage_engine=MyISAM
innodb_purge_threads=8
innodb_compression_pad_pct_max=37
innodb_compression_failure_threshold_pct=10
innodb_old_blocks_pct=50
innodb_old_blocks_time=1000
innodb_adaptive_flushing=1
innodb_adaptive_flushing_lwm=10
innodb_flushing_avg_loops=30

eq_range_index_dive_limit=1000
lock_wait_timeout=60

innodb_compression_level=1
innodb_lock_wait_timeout=2
innodb_log_buffer_size=4M
innodb_log_compressed_pages=0
innodb_read_io_threads=8
innodb_write_io_threads=8
innodb_stats_on_metadata=0

innodb_page_size=4k
innodb_doublewrite=0
innodb_flush_log_at_trx_commit=2
innodb_flush_neighbors=0

innodb_flush_method=O_DIRECT
innodb_buffer_pool_size=105G

Suggested fix:
use less memory
[26 Apr 2014 15:04] Mark Callaghan
5.6.12 includes the Facebook patch. Asking others whether we did anything to use less memory
[26 Apr 2014 15:11] Mark Callaghan
This is something we made better in 5.6

https://github.com/facebook/mysql-5.6/commit/91e979e8436b83400e918fa0f251036e50d0cb5f
[26 Apr 2014 15:12] Mark Callaghan
So this is a feature request, not a bug report.
[28 Apr 2014 6:22] MySQL Verification Team
Hello Mark,

Thank you for the feature request!

Thanks,
Umesh
[28 Apr 2014 6:42] Sunny Bains
For v5.7 you can use -DMUTEX_TYPE="futex" to get rid of the event in a mutex on Linux systems.
[28 Apr 2014 7:17] Sunny Bains
There is also this unused member variable in os0event.cc.

=== modified file 'storage/innobase/os/os0event.cc'
--- storage/innobase/os/os0event.cc	revid:tor.didriksen@oracle.com-20140423150641-94y77lkeyak7vg3f
+++ storage/innobase/os/os0event.cc	2014-04-28 07:23:15 +0000
@@ -84,7 +84,6 @@ typedef pthread_cond_t		os_cond_t;
 #endif /* _WIN32 */
 
 typedef std::list<os_event_t> os_event_list_t;
-typedef os_event_list_t::iterator event_iter_t;
 
 /** InnoDB condition variable. */
 struct os_event {
@@ -289,10 +288,6 @@ private:
 
 	os_cond_t		cond_var;	/*!< condition variable is
 						used in waiting for the event */
-
-public:
-	event_iter_t		event_iter;	/*!< For O(1) removal from
-						list */
 protected:
 	// Disable copying
 	os_event(const os_event&);