SlideShare una empresa de Scribd logo
1 de 20
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Feed me more: MySQL Memory analysed
FOSDEM MySQL Devroom 2013
Raghavendra Prabhu
raghavendra.prabhu@percona.com
Percona
3rd Feb, 2013
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Outline
Introduction
MySQL - Buffers and storage engines
OS/Tools/Instrumentation
Solutions
Cases / Examples
Future
Conclusion
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Overview
During capacity planning, a frequent question which pops up is “How
much memory should I allocate for MySQL and for the system in
general?”.
Memory is quite underestimated much like everything else but more so
than others.
Umpteen thumb rules about this on the Internet, often overruns the
memory and/or frequently OOMs.
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Bufferbloat
Buffers
read_buffer, read_rnd_buffer, join_buffer_size, sort_buffer_size
cache->length=length+blobs*sizeof(char*);
cache->blobs=blobs;
*blob_ptr=0;
size=max(thd->variables.join_buff_size, cache->length);
MySQL variables - max_connections, table_cache and
open_files_limit
wanted_files=10+max_connections+table_cache_size*2;
max_open_files=max(max(wanted_files, max_connections*5),open_files_limit)
tmp_table_size and max_heap_size on tmpfs
tmpdir and tmpfs
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
InnoDB
Buffer pool
Bounded and initialized at startup unless done so (Twitter, XtraDB)
O_DIRECT, ALL_O_DIRECT
Compression and Multiple Page sizes (XtraDB and MySQL 5.6)
Adaptive Hash Index
Role, Bounded, LRU/Reclaim and disable/enable
Multiple partitions - implications on locking
Hash tables & Internals: mem_heap_create_in_btr_search,
MEM_HEAP_BTR_SEARCH, MEM_HEAP_BUFFER,
MEM_HEAP_DYNAMIC
Data dictionary
Unbounded
XtraDB variable - innodb_dict_size_limit
Other ways
Change buffer
XtraDB variable to limit this / Why to limit
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
OS
Sysctls
vm.swappiness, vm.vfs_cache_pressure, vm.drop_caches
vm.overcommit_memory, vm.zone_reclaim_mode
NUMA
NUMA policies: DEFAULT, BIND, INTERLEAVE, PREFERRED
Numastat: numa_hit, numa_miss, numa_foreign, interleave_hit,
local_node, other_node; lp:1083488
numad and AutoNUMA
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Instrumentation/Tools
Instrumentation
getrusage - RUSAGE_THREAD, RUSAGE_SELF,
RUSAGE_CHILDREN
Malloc
tcmalloc - also supports profiling
jemalloc and e/glibc malloc
additional_mem_size and malloc, use_sys_malloc
Perf
perf-top, perf-list
perf-record, perf-report
perf-timechart
Tools
smem, atop, page-types - PSS, stall/pag, memory-map
Valgrind - massif, memcheck, callgrind - UNIV_DEBUG_VALGRIND
LLVM/Clang - ASAN, MSAN - CTI v/s DBI
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Code
Hinting
Not with O_DIRECT handles, Users: Galera, Xtrabackup, MySQL
Madvise and Fadvise
MADV_DONTDUMP
MADV_WILLNEED, MADV_DONTNEED, MADV_SEQUENTIAL
Caveats
Fincore
sudo linux-fincore /data/mysql/galera.cache
filename size total_pages min_cac
–––– –– –––––- –––––––- ––––––
/data/mysql/galera.cache 21,474,837,800 5,242,881
–-
total cached size: 15,944,663,040
Don’t mix O_DIRECT and others
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
OOM and Cgroups
OOM adjustments
vm.panic_on_oom, oom_kill_allocating_task, oom_score_adj
Memory Cgroups
Multiple instances and/or shared
Per instance settings like swappiness
Overhead?
OOM: Proactive and Reactive measures
Proactive: Turn down the load
Reactive: Kill! or move
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Virtualization
Memory ballooning
You balloon the memory whenever required
Qemu monitor: info balloon
balloon virtio
KSM with KVM/Xen
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Misc
Hugepages huge pages
Supported in mysql
Boot-time allocation better
Fragmentation and performance
Transparent Huge pages
No need for setup
Possible bugs? - compaction_alloc and compact_zone
Disable the defrag
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Cases
NUMA and swap
perf and global statistic counter in rowselsearchformysql - upstream
mem_cgroup_del_lru_list and watermark
19.08% [kernel] [k] mem_cgroup_del_lru_list
14.52% [kernel] [k] intel_idle
7.98% [kernel] [k] __isolate_lru_page
6.14% [kernel] [k] shrink_inactive_list
3.83% [kernel] [k] mem_cgroup_add_lru_list
3.60% mysqld [.] 0x4c584e
3.14% [kernel] [k] page_waitqueue
3.09% [kernel] [k] isolate_pages_global
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Examples
smem stack
smem -m -t -k -P aurora
Map PIDs AVGPSS PSS
[stack:34760] 1 1.8M 1.8M
[stack:34668] 1 2.0M 2.0M
[stack:34694] 1 2.2M 2.2M
[heap] 1 6.4M 6.4M
[stack:34746] 1 9.2M 9.2M
[stack:35015] 1 19.5M 19.5M
/usr/lib/aurora/libxul.so 1 24.4M 24.4M
<anonymous> 2 337.8M 675.7M
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Examples (contd.)
Valgrind
./mysql-test-run.pl –valgrind
–valgrind-option="–suppressions=$PWD/valgrind.supp"
–valgrind-option=’–show-reachable=yes’
–valgrind-option=’–gen-suppressions=all’
–vardir=$HOME/mysql t/fake.test
=13145== 16,384 bytes in 1 blocks are still reachable in loss record 738 o
=13145== at 0x4C2C1DE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-a
=13145== by 0x5D78B60: CRYPTO_realloc (in /usr/lib/libcrypto.so.1.0.0)
=13145== by 0x5E20E31: lh_insert (in /usr/lib/libcrypto.so.1.0.0)
=13145== by 0x5E23E0D: int_err_set_item (in /usr/lib/libcrypto.so.1.0.0)
=13145== by 0x5E24458: ERR_load_strings (in /usr/lib/libcrypto.so.1.0.0)
=13145== by 0x5AF99BD: ERR_load_SSL_strings (in /usr/lib/libssl.so.1.0.0)
=13145== by 0xA3C315: new_VioSSLFd (viosslfactories.c:159)
=13145== by 0xA3C91E: new_VioSSLAcceptorFd (viosslfactories.c:288)
=13145== by 0x51D509: mysqld_main(int, char**) (mysqld.cc:3735)
=13145== by 0x513974: main (main.cc:25)
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Examples (contd.)
Perf-report
# 7.15% mysqld mysqld [.] 0x11b0fe
- 0x959389
- 91.87% yaSSL::SSL::makeMasterSecret()
- 79.56% yaSSL::CertManager::sendVerify() const
page_cur_parse_insert_rec.clone.0
row_search_for_mysql
row_search_for_mysql
- row_search_for_mysql
- 61.21% row_vers_impl_x_locked_off_kernel
Create_func_from_unixtime::create_native(THD*, st_mysq
Create_func_is_used_lock::create(THD*, Item*)
Item_func_set_user_var::fix_length_and_dec()
Item_func::fix_fields(THD*, Item**)
handler::delete_table(char const*)
Item_copy_string::val_int()
Item_field::val_bool_result()
Item_cache_datetime::val_str(String*)
Item_type_holder::make_field_by_type(TABLE*)
Item_param::set_param_type_and_swap_value(Item_param*)
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
MySQL 5.6
Multi thread purge
Data dictionary LRU
Malloc
Grouping allocations
Stack instead of heap
Removing allocations
Page size - XtraDB 5.5 and MySQL 5.6
Separate Undo logs?
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Bugs/Features
Bugs reported / in-review
Per thread variables: http://dev.mysql.com/worklog/task/?id=681
Fadvise relay logs:
https://bugs.launchpad.net/percona-server/+bug/1073170
LRU and AHI:
https://bugs.launchpad.net/percona-server/+bug/1083536
Data Dictionary and Buffer pool:
https://bugs.launchpad.net/percona-server/+bug/1083514
MADV_DONTDUMP:
https://bugs.launchpad.net/percona-server/+bug/1092645
SSL leak: https://bugs.launchpad.net/percona-server/+bug/1049076
Leak on a filtered slave:
https://bugs.launchpad.net/percona-server/+bug/1042946
Features planned/interest
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Appendix I
Insert call-chain
btr_search_build_page_hash_index
btr_search_update_hash_on_insert
btr_search_update_hash_ref
ha_insert_for_fold
mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t))
mem_heap_add_block
mem_heap_create_block
buf_block_alloc
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Appendix II
Hash table
struct hash_table_struct {
ulint n_cells;
hash_cell_t* array;
ulint n_mutexes;
mutex_t* mutexes;
mem_heap_t** heaps;
mem_heap_t* heap;
};
Raghavendra Prabhu Percona
MySQL Memory analysed
Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion
Appendix III
Heap structure
struct mem_block_info_struct {
ulint magic_n;
char file_name[8];
ulint line;
UT_LIST_BASE_NODE_T(mem_block_t) base;
UT_LIST_NODE_T(mem_block_t) list;
ulint len;
ulint total_size;
ulint type;
ulint free;
ulint start;
void* free_block;
void* buf_block;
};
Raghavendra Prabhu Percona
MySQL Memory analysed

Más contenido relacionado

Similar a Feed me more: MySQL Memory analysed

50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
50-Tips-for-Boosting-MySQL-Performance-CON2655.pdfAsparuhPolyovski2
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingMarian Marinov
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
Meb Backup & Recovery Performance
Meb Backup & Recovery PerformanceMeb Backup & Recovery Performance
Meb Backup & Recovery PerformanceKeith Hollman
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMark Leith
 
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021Valeriy Kravchuk
 
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d methodAjith Narayanan
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDinakar Guniguntala
 
Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)Valeriy Kravchuk
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Valeriy Kravchuk
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
PoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAUlf Wendel
 
Making Backups in Extreme Situations
Making Backups in Extreme SituationsMaking Backups in Extreme Situations
Making Backups in Extreme SituationsSveta Smirnova
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Valeriy Kravchuk
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudRevolution Analytics
 
tuningfor_oracle
 tuningfor_oracle tuningfor_oracle
tuningfor_oraclestyxyx
 
Nuvola: a tale of migration to AWS
Nuvola: a tale of migration to AWSNuvola: a tale of migration to AWS
Nuvola: a tale of migration to AWSMatteo Moretti
 
Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7Mark Leith
 
MySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMorgan Tocker
 

Similar a Feed me more: MySQL Memory analysed (20)

50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
50-Tips-for-Boosting-MySQL-Performance-CON2655.pdf
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
Meb Backup & Recovery Performance
Meb Backup & Recovery PerformanceMeb Backup & Recovery Performance
Meb Backup & Recovery Performance
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema Improvements
 
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
 
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d method
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)Applying profilers to my sql (fosdem 2017)
Applying profilers to my sql (fosdem 2017)
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
PoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HA
 
Making Backups in Extreme Situations
Making Backups in Extreme SituationsMaking Backups in Extreme Situations
Making Backups in Extreme Situations
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the Cloud
 
tuningfor_oracle
 tuningfor_oracle tuningfor_oracle
tuningfor_oracle
 
Nuvola: a tale of migration to AWS
Nuvola: a tale of migration to AWSNuvola: a tale of migration to AWS
Nuvola: a tale of migration to AWS
 
Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7
 
MySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMySQL Performance Metrics that Matter
MySQL Performance Metrics that Matter
 

Más de Raghavendra Prabhu

Orchestrating Cassandra with Kubernetes Operator and PaaSTA
Orchestrating Cassandra with Kubernetes Operator and PaaSTAOrchestrating Cassandra with Kubernetes Operator and PaaSTA
Orchestrating Cassandra with Kubernetes Operator and PaaSTARaghavendra Prabhu
 
Orchestrating Cassandra with Kubernetes
Orchestrating Cassandra with KubernetesOrchestrating Cassandra with Kubernetes
Orchestrating Cassandra with KubernetesRaghavendra Prabhu
 
Cassandra Operator with Yelp PaaSTA
Cassandra Operator with Yelp PaaSTACassandra Operator with Yelp PaaSTA
Cassandra Operator with Yelp PaaSTARaghavendra Prabhu
 
Safe and Fast Automation on AWS for Fun and Profit
Safe and Fast Automation on AWS for Fun and ProfitSafe and Fast Automation on AWS for Fun and Profit
Safe and Fast Automation on AWS for Fun and ProfitRaghavendra Prabhu
 
Orchestrating Cassandra with Kubernetes: Challenges and Opportunities
Orchestrating Cassandra with Kubernetes: Challenges and OpportunitiesOrchestrating Cassandra with Kubernetes: Challenges and Opportunities
Orchestrating Cassandra with Kubernetes: Challenges and OpportunitiesRaghavendra Prabhu
 
Pass Elk: CAP Theorem since 90s and Beyond
Pass Elk: CAP Theorem since 90s and BeyondPass Elk: CAP Theorem since 90s and Beyond
Pass Elk: CAP Theorem since 90s and BeyondRaghavendra Prabhu
 
Cassandra in Docker at Yelp: Opportunities and Challenges
Cassandra in Docker at Yelp: Opportunities and ChallengesCassandra in Docker at Yelp: Opportunities and Challenges
Cassandra in Docker at Yelp: Opportunities and ChallengesRaghavendra Prabhu
 
Taskerman: A Distributed Cluster Task Manager
Taskerman: A Distributed Cluster Task ManagerTaskerman: A Distributed Cluster Task Manager
Taskerman: A Distributed Cluster Task ManagerRaghavendra Prabhu
 
Taskerman - a distributed cluster task manager
Taskerman - a distributed cluster task managerTaskerman - a distributed cluster task manager
Taskerman - a distributed cluster task managerRaghavendra Prabhu
 
Linux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and OpportunitiesLinux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and OpportunitiesRaghavendra Prabhu
 
Clusternaut: Orchestrating  Percona XtraDB Cluster with Kubernetes
Clusternaut:  Orchestrating  Percona XtraDB Cluster with KubernetesClusternaut:  Orchestrating  Percona XtraDB Cluster with Kubernetes
Clusternaut: Orchestrating  Percona XtraDB Cluster with KubernetesRaghavendra Prabhu
 
Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.
Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.
Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.Raghavendra Prabhu
 
Working from home - fun, facts and scares!
Working from home -  fun, facts and scares!Working from home -  fun, facts and scares!
Working from home - fun, facts and scares!Raghavendra Prabhu
 
Securing databases with systemd for containers and services
Securing databases with systemd for containers and services Securing databases with systemd for containers and services
Securing databases with systemd for containers and services Raghavendra Prabhu
 
Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm
Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm
Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm Raghavendra Prabhu
 
Dock'em: Distributed Systems Testing with NetEm and Docker
Dock'em: Distributed Systems Testing with NetEm and Docker Dock'em: Distributed Systems Testing with NetEm and Docker
Dock'em: Distributed Systems Testing with NetEm and Docker Raghavendra Prabhu
 
Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...
Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...
Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...Raghavendra Prabhu
 
Jutsu or Dô: Open documentation: continuous process than a body
Jutsu or Dô: Open documentation: continuous process than a body Jutsu or Dô: Open documentation: continuous process than a body
Jutsu or Dô: Open documentation: continuous process than a body Raghavendra Prabhu
 
Corpus collapsum: Partition tolerance of Galera in a noisy high load environment
Corpus collapsum: Partition tolerance of Galera in a noisy high load environmentCorpus collapsum: Partition tolerance of Galera in a noisy high load environment
Corpus collapsum: Partition tolerance of Galera in a noisy high load environmentRaghavendra Prabhu
 

Más de Raghavendra Prabhu (20)

Orchestrating Cassandra with Kubernetes Operator and PaaSTA
Orchestrating Cassandra with Kubernetes Operator and PaaSTAOrchestrating Cassandra with Kubernetes Operator and PaaSTA
Orchestrating Cassandra with Kubernetes Operator and PaaSTA
 
Orchestrating Cassandra with Kubernetes
Orchestrating Cassandra with KubernetesOrchestrating Cassandra with Kubernetes
Orchestrating Cassandra with Kubernetes
 
Cassandra Operator with Yelp PaaSTA
Cassandra Operator with Yelp PaaSTACassandra Operator with Yelp PaaSTA
Cassandra Operator with Yelp PaaSTA
 
Safe and Fast Automation on AWS for Fun and Profit
Safe and Fast Automation on AWS for Fun and ProfitSafe and Fast Automation on AWS for Fun and Profit
Safe and Fast Automation on AWS for Fun and Profit
 
Orchestrating Cassandra with Kubernetes: Challenges and Opportunities
Orchestrating Cassandra with Kubernetes: Challenges and OpportunitiesOrchestrating Cassandra with Kubernetes: Challenges and Opportunities
Orchestrating Cassandra with Kubernetes: Challenges and Opportunities
 
Pass Elk: CAP Theorem since 90s and Beyond
Pass Elk: CAP Theorem since 90s and BeyondPass Elk: CAP Theorem since 90s and Beyond
Pass Elk: CAP Theorem since 90s and Beyond
 
Cassandra in Docker at Yelp: Opportunities and Challenges
Cassandra in Docker at Yelp: Opportunities and ChallengesCassandra in Docker at Yelp: Opportunities and Challenges
Cassandra in Docker at Yelp: Opportunities and Challenges
 
Taskerman: A Distributed Cluster Task Manager
Taskerman: A Distributed Cluster Task ManagerTaskerman: A Distributed Cluster Task Manager
Taskerman: A Distributed Cluster Task Manager
 
Taskerman - a distributed cluster task manager
Taskerman - a distributed cluster task managerTaskerman - a distributed cluster task manager
Taskerman - a distributed cluster task manager
 
NUMA and Java Databases
NUMA and Java DatabasesNUMA and Java Databases
NUMA and Java Databases
 
Linux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and OpportunitiesLinux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and Opportunities
 
Clusternaut: Orchestrating  Percona XtraDB Cluster with Kubernetes
Clusternaut:  Orchestrating  Percona XtraDB Cluster with KubernetesClusternaut:  Orchestrating  Percona XtraDB Cluster with Kubernetes
Clusternaut: Orchestrating  Percona XtraDB Cluster with Kubernetes
 
Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.
Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.
Clusternaut: Orchestrating Percona XtraDB Cluster with Kubernetes.
 
Working from home - fun, facts and scares!
Working from home -  fun, facts and scares!Working from home -  fun, facts and scares!
Working from home - fun, facts and scares!
 
Securing databases with systemd for containers and services
Securing databases with systemd for containers and services Securing databases with systemd for containers and services
Securing databases with systemd for containers and services
 
Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm
Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm
Corpus collapsum: Partition tolerance testing of Galera with Docker and NetEm
 
Dock'em: Distributed Systems Testing with NetEm and Docker
Dock'em: Distributed Systems Testing with NetEm and Docker Dock'em: Distributed Systems Testing with NetEm and Docker
Dock'em: Distributed Systems Testing with NetEm and Docker
 
Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...
Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...
Galera with Docker: How Synchronous Replication and Linux Containers mesh tog...
 
Jutsu or Dô: Open documentation: continuous process than a body
Jutsu or Dô: Open documentation: continuous process than a body Jutsu or Dô: Open documentation: continuous process than a body
Jutsu or Dô: Open documentation: continuous process than a body
 
Corpus collapsum: Partition tolerance of Galera in a noisy high load environment
Corpus collapsum: Partition tolerance of Galera in a noisy high load environmentCorpus collapsum: Partition tolerance of Galera in a noisy high load environment
Corpus collapsum: Partition tolerance of Galera in a noisy high load environment
 

Último

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Último (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Feed me more: MySQL Memory analysed

  • 1. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Feed me more: MySQL Memory analysed FOSDEM MySQL Devroom 2013 Raghavendra Prabhu raghavendra.prabhu@percona.com Percona 3rd Feb, 2013 Raghavendra Prabhu Percona MySQL Memory analysed
  • 2. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Outline Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Raghavendra Prabhu Percona MySQL Memory analysed
  • 3. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Overview During capacity planning, a frequent question which pops up is “How much memory should I allocate for MySQL and for the system in general?”. Memory is quite underestimated much like everything else but more so than others. Umpteen thumb rules about this on the Internet, often overruns the memory and/or frequently OOMs. Raghavendra Prabhu Percona MySQL Memory analysed
  • 4. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Bufferbloat Buffers read_buffer, read_rnd_buffer, join_buffer_size, sort_buffer_size cache->length=length+blobs*sizeof(char*); cache->blobs=blobs; *blob_ptr=0; size=max(thd->variables.join_buff_size, cache->length); MySQL variables - max_connections, table_cache and open_files_limit wanted_files=10+max_connections+table_cache_size*2; max_open_files=max(max(wanted_files, max_connections*5),open_files_limit) tmp_table_size and max_heap_size on tmpfs tmpdir and tmpfs Raghavendra Prabhu Percona MySQL Memory analysed
  • 5. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion InnoDB Buffer pool Bounded and initialized at startup unless done so (Twitter, XtraDB) O_DIRECT, ALL_O_DIRECT Compression and Multiple Page sizes (XtraDB and MySQL 5.6) Adaptive Hash Index Role, Bounded, LRU/Reclaim and disable/enable Multiple partitions - implications on locking Hash tables & Internals: mem_heap_create_in_btr_search, MEM_HEAP_BTR_SEARCH, MEM_HEAP_BUFFER, MEM_HEAP_DYNAMIC Data dictionary Unbounded XtraDB variable - innodb_dict_size_limit Other ways Change buffer XtraDB variable to limit this / Why to limit Raghavendra Prabhu Percona MySQL Memory analysed
  • 6. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion OS Sysctls vm.swappiness, vm.vfs_cache_pressure, vm.drop_caches vm.overcommit_memory, vm.zone_reclaim_mode NUMA NUMA policies: DEFAULT, BIND, INTERLEAVE, PREFERRED Numastat: numa_hit, numa_miss, numa_foreign, interleave_hit, local_node, other_node; lp:1083488 numad and AutoNUMA Raghavendra Prabhu Percona MySQL Memory analysed
  • 7. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Instrumentation/Tools Instrumentation getrusage - RUSAGE_THREAD, RUSAGE_SELF, RUSAGE_CHILDREN Malloc tcmalloc - also supports profiling jemalloc and e/glibc malloc additional_mem_size and malloc, use_sys_malloc Perf perf-top, perf-list perf-record, perf-report perf-timechart Tools smem, atop, page-types - PSS, stall/pag, memory-map Valgrind - massif, memcheck, callgrind - UNIV_DEBUG_VALGRIND LLVM/Clang - ASAN, MSAN - CTI v/s DBI Raghavendra Prabhu Percona MySQL Memory analysed
  • 8. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Code Hinting Not with O_DIRECT handles, Users: Galera, Xtrabackup, MySQL Madvise and Fadvise MADV_DONTDUMP MADV_WILLNEED, MADV_DONTNEED, MADV_SEQUENTIAL Caveats Fincore sudo linux-fincore /data/mysql/galera.cache filename size total_pages min_cac –––– –– –––––- –––––––- –––––– /data/mysql/galera.cache 21,474,837,800 5,242,881 –- total cached size: 15,944,663,040 Don’t mix O_DIRECT and others Raghavendra Prabhu Percona MySQL Memory analysed
  • 9. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion OOM and Cgroups OOM adjustments vm.panic_on_oom, oom_kill_allocating_task, oom_score_adj Memory Cgroups Multiple instances and/or shared Per instance settings like swappiness Overhead? OOM: Proactive and Reactive measures Proactive: Turn down the load Reactive: Kill! or move Raghavendra Prabhu Percona MySQL Memory analysed
  • 10. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Virtualization Memory ballooning You balloon the memory whenever required Qemu monitor: info balloon balloon virtio KSM with KVM/Xen Raghavendra Prabhu Percona MySQL Memory analysed
  • 11. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Misc Hugepages huge pages Supported in mysql Boot-time allocation better Fragmentation and performance Transparent Huge pages No need for setup Possible bugs? - compaction_alloc and compact_zone Disable the defrag Raghavendra Prabhu Percona MySQL Memory analysed
  • 12. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Cases NUMA and swap perf and global statistic counter in rowselsearchformysql - upstream mem_cgroup_del_lru_list and watermark 19.08% [kernel] [k] mem_cgroup_del_lru_list 14.52% [kernel] [k] intel_idle 7.98% [kernel] [k] __isolate_lru_page 6.14% [kernel] [k] shrink_inactive_list 3.83% [kernel] [k] mem_cgroup_add_lru_list 3.60% mysqld [.] 0x4c584e 3.14% [kernel] [k] page_waitqueue 3.09% [kernel] [k] isolate_pages_global Raghavendra Prabhu Percona MySQL Memory analysed
  • 13. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Examples smem stack smem -m -t -k -P aurora Map PIDs AVGPSS PSS [stack:34760] 1 1.8M 1.8M [stack:34668] 1 2.0M 2.0M [stack:34694] 1 2.2M 2.2M [heap] 1 6.4M 6.4M [stack:34746] 1 9.2M 9.2M [stack:35015] 1 19.5M 19.5M /usr/lib/aurora/libxul.so 1 24.4M 24.4M <anonymous> 2 337.8M 675.7M Raghavendra Prabhu Percona MySQL Memory analysed
  • 14. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Examples (contd.) Valgrind ./mysql-test-run.pl –valgrind –valgrind-option="–suppressions=$PWD/valgrind.supp" –valgrind-option=’–show-reachable=yes’ –valgrind-option=’–gen-suppressions=all’ –vardir=$HOME/mysql t/fake.test =13145== 16,384 bytes in 1 blocks are still reachable in loss record 738 o =13145== at 0x4C2C1DE: realloc (in /usr/lib/valgrind/vgpreload_memcheck-a =13145== by 0x5D78B60: CRYPTO_realloc (in /usr/lib/libcrypto.so.1.0.0) =13145== by 0x5E20E31: lh_insert (in /usr/lib/libcrypto.so.1.0.0) =13145== by 0x5E23E0D: int_err_set_item (in /usr/lib/libcrypto.so.1.0.0) =13145== by 0x5E24458: ERR_load_strings (in /usr/lib/libcrypto.so.1.0.0) =13145== by 0x5AF99BD: ERR_load_SSL_strings (in /usr/lib/libssl.so.1.0.0) =13145== by 0xA3C315: new_VioSSLFd (viosslfactories.c:159) =13145== by 0xA3C91E: new_VioSSLAcceptorFd (viosslfactories.c:288) =13145== by 0x51D509: mysqld_main(int, char**) (mysqld.cc:3735) =13145== by 0x513974: main (main.cc:25) Raghavendra Prabhu Percona MySQL Memory analysed
  • 15. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Examples (contd.) Perf-report # 7.15% mysqld mysqld [.] 0x11b0fe - 0x959389 - 91.87% yaSSL::SSL::makeMasterSecret() - 79.56% yaSSL::CertManager::sendVerify() const page_cur_parse_insert_rec.clone.0 row_search_for_mysql row_search_for_mysql - row_search_for_mysql - 61.21% row_vers_impl_x_locked_off_kernel Create_func_from_unixtime::create_native(THD*, st_mysq Create_func_is_used_lock::create(THD*, Item*) Item_func_set_user_var::fix_length_and_dec() Item_func::fix_fields(THD*, Item**) handler::delete_table(char const*) Item_copy_string::val_int() Item_field::val_bool_result() Item_cache_datetime::val_str(String*) Item_type_holder::make_field_by_type(TABLE*) Item_param::set_param_type_and_swap_value(Item_param*) Raghavendra Prabhu Percona MySQL Memory analysed
  • 16. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion MySQL 5.6 Multi thread purge Data dictionary LRU Malloc Grouping allocations Stack instead of heap Removing allocations Page size - XtraDB 5.5 and MySQL 5.6 Separate Undo logs? Raghavendra Prabhu Percona MySQL Memory analysed
  • 17. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Bugs/Features Bugs reported / in-review Per thread variables: http://dev.mysql.com/worklog/task/?id=681 Fadvise relay logs: https://bugs.launchpad.net/percona-server/+bug/1073170 LRU and AHI: https://bugs.launchpad.net/percona-server/+bug/1083536 Data Dictionary and Buffer pool: https://bugs.launchpad.net/percona-server/+bug/1083514 MADV_DONTDUMP: https://bugs.launchpad.net/percona-server/+bug/1092645 SSL leak: https://bugs.launchpad.net/percona-server/+bug/1049076 Leak on a filtered slave: https://bugs.launchpad.net/percona-server/+bug/1042946 Features planned/interest Raghavendra Prabhu Percona MySQL Memory analysed
  • 18. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Appendix I Insert call-chain btr_search_build_page_hash_index btr_search_update_hash_on_insert btr_search_update_hash_ref ha_insert_for_fold mem_heap_alloc(hash_get_heap(table, fold), sizeof(ha_node_t)) mem_heap_add_block mem_heap_create_block buf_block_alloc Raghavendra Prabhu Percona MySQL Memory analysed
  • 19. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Appendix II Hash table struct hash_table_struct { ulint n_cells; hash_cell_t* array; ulint n_mutexes; mutex_t* mutexes; mem_heap_t** heaps; mem_heap_t* heap; }; Raghavendra Prabhu Percona MySQL Memory analysed
  • 20. Introduction MySQL - Buffers and storage engines OS/Tools/Instrumentation Solutions Cases / Examples Future Conclusion Appendix III Heap structure struct mem_block_info_struct { ulint magic_n; char file_name[8]; ulint line; UT_LIST_BASE_NODE_T(mem_block_t) base; UT_LIST_NODE_T(mem_block_t) list; ulint len; ulint total_size; ulint type; ulint free; ulint start; void* free_block; void* buf_block; }; Raghavendra Prabhu Percona MySQL Memory analysed