Transcript
  • InnoDB Performance and Usability PatchesMySQL CE 2009

    Vadim Tkachenko,Ewen Fortune

    Percona IncMySQLPerformanceBlog.com

  • Who are we ?Vadim TkachenkoCo-Founder of Percona IncLead of R&D departmentCo-Author MySQLPerformanceBlog.comCo-Author High Performance MySQL 2nd edition bookEwen FortuneConsultant, Percona IncSpecial Thanks Yasufumi KinoshitaNot here, but author of most patchesInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • What is this talk about?Patches made by Percona for InnoDB Storage EngineTwo main focusesPerformance improvement patchesUsability patchesMake InnoDB a bit more friendly World changed since time of Pentium 100MHz and 8MB of RAMBut many such assumptions still in InnoDB codeInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Why we do itMost requirements and changes come from practical work with customersWe need InnoDB fully utilizing modern hardware today16 coresRAIDsSSD / FusionIO / other storage technologiesInnoDB team is conservative in making improvements in this area

    InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • FutureWhy patches ? Why it cant be included in InnoDB?We are often asked about, but actually question is to InnoDB team(empty space due to uncertainty of MySQL future in Oracle)

    Anyway we will continue our workInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Versions5.0Set of patchesSHOW PATCHES to see full list5.1Storage engine XtraDBBased on InnoDB + patches, not real competitor of InnoDB, but drop-in enhanced versionInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Performance PatchesInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • ScalabilityEnhanced read_write locksImproves InnoDB scalability on systems with 8-16 cores Similar on Google implementation, InnoDB-plugin-1.0.3Our implementation is alternativeTopic to research which one is betterInnoDB-plugin may be preferred, InnoDB team made hard job porting it to many platformsAnd now in 5.4Split buffer_pool mutex even moreAdditional split of buffer_pool mutex to 5.0.33InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • IO patchesInnoDB IO patchesPart similar to Googles InnoDB IO patches, but again alternative Several parts some of them now in 5.4InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • IO multiple threadsRead_io_threadsNumber of threads for reads requests (by default 1)Not really useful as used only for read-ahead requestsWrite_io_threadsNumber of threads for write requests (by default 1)This is one you may want to use on system with multiple disksIo_capacityAmount of IO operations per second InnoDB assumes server can do (by default 100, which is not right assumptions for modern systems)InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • IO Adaptive checkpointInnoDB flushing of dirty buffer_pool pages may be intensiveLack of free pages may be controlled by innodb_max_dirty_pages_pctFlushing at the moment of checkpoint is not controllable, intensive and may hurtInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Adaptive checkpointingInnoDB Performance and Usability Patches-*-InnoDB default behavior, hiccups during buffer_pool flushing

    InnoDB Performance and Usability Patches

  • Adaptive checkpointWhat we do:Flush pages more intensivethe closer checkpoint the more intensiveInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Adaptive_checkpointAdaptive_checkpoint=1InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • IO Control of Insert bufferIbuf_max_size maximal size of insert buffer (by default can be half of buffer_pool)Ibuf_accel_rate IO rate for background thread, works in pair with io_capacity

    InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • IO multiple pagesRead_ahead = (both | linear | random)Control to use or not internal InnoDB read-ahead logicFlush_neighbor_pages = (yes|no)By default InnoDB also writes neighborhoods of flushing pagesAll these operations were made for disks with expensive (in time sense) random reads may be not needed for SSD / FusionIO / other devices with cheap random readsInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Extra rollback segmentsBy default InnoDB uses single segment protected by mutexSensitive in intensive parallel insert load

    InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Fix group commitBroken in 5.0Problem appears on slow disks with enabled binary-logs

    InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • BenchmarkTpcc-like workload100 Warehouses (about 10GB of data)Buffer_pool=5GBSystem: Dell PowerEdge R900, RAID 10 on 8 disks, RAM 32GBO_DIRECT for InnoDB, xfs filesystem, mounted with nobarrier5.0.77 vs 5.0.77-perconaHad no chance to test 5.4 yetInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • BenchmarkInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

    Chart1

    1487.81495.7

    6711.66559

    8252.19471.8

    7128.411302.1

    6527.110935.6

    6210.610013.3

    5767.69567.9

    3931.98244.2

    5.0.77

    5.0.77-percona

    threads

    TpcM

    Sheet1

    Column15.0.775.0.77-percona

    11487.81495.7

    46711.66559

    88252.19471.8

    167128.411302.1

    326527.110935.6

    646210.610013.3

    1285767.69567.9

    2563931.98244.2

    To resize chart data range, drag lower right corner of range.

  • Usability patchesInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • MicroslowInnoDB partInnoDB Performance and Usability Patches-*-InnoDB_IO_r_ops: 1 InnoDB_IO_r_bytes: 16384 InnoDB_IO_r_wait: 0.028487 # InnoDB_rec_lock_wait: 0.000000 InnoDB_queue_wait: 0.000000 # InnoDB_pages_distinct: 5

    InnoDB Performance and Usability Patches

  • Limit data dictionaryProblem:Data dictionary entry of once opened table kept in memory forever (or while DELETE table)Is not problem for regular usage (100-1000 tables)Is problem for instances with 10K+ tables10GB+ of memory just allocated for datadictionary entriesOur solution:LRU based datadictionary entriesRemove from memory oldest entries if limit reachedInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • IO access patternInnoDB Performance and Usability Patches-*-mysql> select INDEX_ID,TABLE_NAME,INDEX_NAME,sum(N_READ),sum(N_WRITE) from INFORMATION_SCHEMA.INNODB_ALL_PAGE_IO groupby INDEX_ID; +------------+------------------+-------------------+-------------+--------------+| INDEX_ID | TABLE_NAME | INDEX_NAME | sum(N_READ) | sum(N_WRITE) |+------------+------------------+-------------------+-------------+--------------+| 30 | tpcc/item | PRIMARY | 547 | 0 || 32 | tpcc/district | PRIMARY | 1 | 1 || 36 | tpcc/history | GEN_CLUST_INDEX | 11 | 5 || 37 | tpcc/history | fkey_history_1 | 166 | 163 || 38 | tpcc/history | fkey_history_2 | 37 | 30 || 39 | tpcc/new_orders | PRIMARY | 76 | 76 || 43 | tpcc/order_line | PRIMARY | 218 | 189 || 44 | tpcc/order_line | fkey_order_line_2 | 1040 | 1040 || 46 | tpcc/stock | PRIMARY | 3137 | 1764 || 47 | tpcc/stock | fkey_stock_2 | 269 | 0 || 48 | tpcc/customer | PRIMARY | 960 | 580 || 49 | tpcc/customer | idx_customer | 171 | 0 || 50 | tpcc/orders | PRIMARY | 94 | 70 || 51 | tpcc/orders | idx_orders | 142 | 129 |Show pattern of pages on disk accessed

    InnoDB Performance and Usability Patches

  • Show buffer pool contentWhat is in buffer_pool

    InnoDB Performance and Usability Patches-*-select space,offset, RECORDS, DATASIZE, INDEX_NAME,TABLE_SCHEMA,TABLE_NAME from information_schema.INNODB_BUFFER_POOL_CONTENT limit 10;+-------+---------+---------+----------+------------+--------------+-------------+| space | offset | RECORDS | DATASIZE | INDEX_NAME | TABLE_SCHEMA | TABLE_NAME |+-------+---------+---------+----------+------------+--------------+-------------+| 1584 | 640643 | 9 | 10312 | PRIMARY | art104 | article104 | | 1648 | 2100 | 135 | 15226 | PRIMARY | art114 | author114 | | 1492 | 4507 | 158 | 15130 | PRIMARY | art87 | author87 | | 1406 | 17498 | 141 | 16056 | img_status | art52 | img_out52 | | 1466 | 47632 | 49 | 15140 | PRIMARY | art62 | img_out62 | | 1470 | 1395457 | 24 | 14769 | PRIMARY | art84 | article84 | | 1460 | 16025 | 62 | 15174 | PRIMARY | art61 | img_out61 | | 1458 | 560956 | 20 | 14977 | PRIMARY | art61 | article61 | | 1466 | 67953 | 56 | 15182 | PRIMARY | art62 | img_out62 | | 1621 | 162962 | 46 | 15134 | PRIMARY | art110 | link_out110 | +-------+---------+---------+----------+------------+--------------+-------------+

    InnoDB Performance and Usability Patches

  • Show memory usageExtended information about memory consumingInnoDB Performance and Usability Patches-*----------------------- BUFFER POOL AND MEMORY ---------------------- Total memory allocated 328830416; in additional pool allocated 2117120 + Internal hash tables (constant factor + variable factor) + Adaptive hash index 4839388 (4425628 + 413760) + Page hash 138716 + Dictionary cache 3383508 (3320220 + 63288) + File system 41848 (41336 + 512) + Lock system 332788 (332468 + 320) + Recovery system 0 (0 + 0) + Threads 41900 (41348 + 552) Buffer pool size 16384 + Buffer pool size, bytes 268435456 Free buffers 12396

    InnoDB Performance and Usability Patches

  • Show locks held---TRANSACTION 0 163390, ACTIVE 0 sec, process no 15571, OS thread id 1159485776 inserting mysql tables in use 1, locked 1 7 lock struct(s), heap size 1216, undo log entries 4 MySQL thread id 15, query id 15455 127.0.0.1 root update INSERT INTO history(h_c_d_id, h_c_w_id, h_c_id, h_d_id, h_w_id, h_date, h_amount, h_data) VALUES(?, ?, ?, ?, ?, ?, ?, ?) Trx read view will not see trx with id >= 0 163391, sees < 0 163086 TABLE LOCK table `test/warehouse` trx id 0 163390 lock mode IX RECORD LOCKS space id 10 page no 3 n bits 168 index `PRIMARY` of table `test/warehouse` trx id 0 163390 lock_mode X locks rec but not gap TABLE LOCK table `test/district` trx id 0 163390 lock mode IX RECORD LOCKS space id 18 page no 7 n bits 216 index `PRIMARY` of table `test/district` trx id 0 163390 lock_mode X locks rec but not gap TABLE LOCK table `test/customer` trx id 0 163390 lock mode IX RECORD LOCKS space id 19 page no 57918 n bits 96 index `PRIMARY` of table `test/customer` trx id 0 163390 lock_mode X locks rec but not gap TABLE LOCK table `test/history` trx id 0 163390 lock mode IX InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Extra undo slotsBy default 1024 slots to store transaction undo information, that may limit count of concurrent transactions to 512We increase to 4072Only on 5.1 XtraDBUse it only if you need, breaks compatibility with InnoDBInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • TransactionalReplicationSimilar to Googles patchInformation in relay-log.info is not consistent with InnoDB state.When server crash MySQL will repeat several transactionYou are lucky if replication fails on Duplicate key errorIn worst case you will have several transactions executed twiceOur solution: store information of binary log name and position and relay-log name and position in InnoDB transactional log fileInnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • PlansStill hunt performance improvementsOperations tasks:Fast recoveryThere is reported bug http://bugs.mysql.com/bug.php?id=29847Preload table / index into buffer_pool.Copy single .ibd table from one server to differentOpen InnoDB tables in parallelCurrently serializedDifferent improvements on statisticsSome patches already published (not by us)InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • To finalizeMost of patches is not rocket scienceCould be developed or included in official tree long time agoEven more, for some patches we just only uncommented few lines of codeExpect most of them in MariaDB 5.1InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

  • Questions ?Thank you for coming!InnoDB Performance and Usability Patches-*-

    InnoDB Performance and Usability Patches

    **


Top Related