facebook / mysql-5.6

Facebook's branch of the Oracle MySQL database. This includes MyRocks.
http://myrocks.io
Other
2.48k stars 713 forks source link

mutex contention in the sharded LRU #674

Closed mdcallag closed 3 months ago

mdcallag commented 7 years ago

QPS with MyRocks saturates at 8 clients because of mutex contention on the shard LRU mutexes. I think the workload ends up with 90% of the lookups going to the right end of the key space, so they all access the same block in each level of the LSM tree. This is the "1in10" variation of the test. When I change it to not do that (the "all" variation) then MyRocks does better, but might hit another known problem (ThreadLocalPtr).

I added a new sysbench test (to be shared soon) that does SELECT statements fetching 100 values by PK using an in-list. I first ran the test with 80M rows in 1 table. The table is ~20gb on disk and I started with a 50gb block cache. Compression was disabled and I used a tuned my.cnf including:

rocksdb_pin_l0_filter_and_index_blocks_in_cache ON
rocksdb_table_cache_numshardbits        6
rocksdb_perf_context_level      0

I used a MyRocks build from June 16 that does not include https://github.com/facebook/mysql-5.6/issues/658. The test server has 48 HW threads and the sysbench tests are run for 1, 8, 16, 24, 32, 40 and 48 clients. mysqld and sysbench run on the same host.

The test is run two ways. First it is run in the "all" variation where every lookup finds a row. Then I repeat it for the "1in10" variation where I tell sysbench the key space is 1 to 800M and only keys from 1 to 80M will find rows, so 1 in 10 keys will find a row.

All of the rocksdb options from my.cnf

rocksdb_max_open_files=-1
rocksdb_base_background_compactions=1
rocksdb_max_background_compactions=8
rocksdb_max_total_wal_size=4G
rocksdb_max_background_flushes=4
rocksdb_block_size=16384
rocksdb_table_cache_numshardbits=6
rocksdb_bytes_per_sync=4194304
rocksdb_wal_bytes_per_sync=4194304
rocksdb_compaction_sequential_deletes_count_sd=1
rocksdb_compaction_sequential_deletes=199999
rocksdb_compaction_sequential_deletes_window=200000
rocksdb_default_cf_options=write_buffer_size=64m;target_file_size_base=32m;max_bytes_for_level_base=512m;level0_file_num_compaction_trigger=4;level0_slowdown_writes_trigger=20;level0_stop_writes_trigger=30;max_write_buffer_number=4;compression_per_level=kNoCompression:kNoCompression:kNoCompression:kNoCompression:kNoCompression:kNoCompression;bottommost_compression=kNoCompression;block_based_table_factory={cache_index_and_filter_blocks=1;filter_policy=bloomfilter:10:false;whole_key_filtering=1};level_compaction_dynamic_level_bytes=true;optimize_filters_for_hits=true;compaction_pri=kMinOverlappingRatio
rocksdb_block_cache_size=180g
rocksdb_flush_log_at_trx_commit=2
rocksdb_block_cache_size=50g

Examples of the sysbench command line, but I still need to share oltp_inlist_select.lua

x=800000000; ./sysbench --test=/data/mysql/sysbench.lua/oltp_inlist_select.lua --db-driver=mysql --mysql-user=root --mysql-password=pw --mysql-host=127.0.0.1 --mysql-db=test --mysql-storage-engine=rocksdb --range-size=100 --table-size=$x --tables=1 --threads=16 --events=0 --time=30 run

x=80000000; ./sysbench --test=/data/mysql/sysbench.lua/oltp_inlist_select.lua --db-driver=mysql --mysql-user=root --mysql-password=pw --mysql-host=127.0.0.1 --mysql-db=test --mysql-storage-engine=rocksdb --range-size=100 --table-size=$x --tables=1 --threads=16 --events=0 --time=30 run

QPS by concurrency. Note that MyRocks saturates at ~9000 QPS for for the 1in10 variation which occurs at 8 or 16 clients. It does better on the "all" variation.

QPS for "all" variation
                1       8       16      24      32      40      48
InnoDB-801      1634    11238   15564   15918   17035   17637   18048
InnoDB-5717     1738    12175   16936   16820   17452   18031   18817
InnoDB-5635     1976    10303   11184   11414   12067   12486   13010
MyRocks-Jun16    962     7206   13617   18142   20332   22213   23257

QPS for 1in10 variation
                1       8       16      24      32      40      48
InnoDB-801      2539    10422   12108   12408   13722   14726   15751
InnoDB-5717     2729    11334   11618   11844   13828   15406   17013
InnoDB-5635     1920     4279    4436    4674    5632    6330    6928
MyRocks-Jun16   1918     8883    9411    9330    9116    8977    8863

This is PMP output from the 1in10 variation at 24 threads. Note that 23 or 24 user query threads are block on lll_lock_wait on a mutex from the sharded LRU

     47 pthread_cond_wait@@GLIBC_2.3.2,background_thread_sleep,background_work_sleep_once,background_work,background_thread_entry,start_thread,clone
     25 pthread_cond_wait@@GLIBC_2.3.2,inline_mysql_cond_wait,block_until_new_connection_halflock,one_thread_per_connection_end(THD*,,do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
     15 __lll_lock_wait,pthread_mutex_lock,rocksdb::port::Mutex::Lock(),rocksdb::MutexLock::MutexLock(rocksdb::port::Mutex*),rocksdb::LRUCacheShard::Lookup(rocksdb::Slice,rocksdb::(anonymous,rocksdb::BlockBasedTable::GetFilter(rocksdb::BlockHandle,rocksdb::BlockBasedTable::GetFilter(bool),rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
     12 pthread_cond_wait@@GLIBC_2.3.2,std::condition_variable::wait(std::unique_lock<std::mutex>&),rocksdb::ThreadPoolImpl::Impl::BGThread(unsigned,rocksdb::ThreadPoolImpl::Impl::BGThreadWrapper(void*),execute_native_thread_routine,start_thread,clone
      8 __lll_lock_wait,pthread_mutex_lock,rocksdb::port::Mutex::Lock(),rocksdb::MutexLock::MutexLock(rocksdb::port::Mutex*),rocksdb::LRUCacheShard::Release(rocksdb::Cache::Handle*,,rocksdb::BlockBasedTable::CachableEntry<rocksdb::FilterBlockReader>::Release(rocksdb::Cache*,,rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
      1 sigwait,signal_hand(void*),start_thread,clone
      1 sigwaitinfo,timer_notify_thread_func,start_thread,clone
      1 pthread_mutex_unlock,rocksdb::port::Mutex::Unlock(),rocksdb::MutexLock::~MutexLock(),rocksdb::LRUCacheShard::Release(rocksdb::Cache::Handle*,,rocksdb::BlockBasedTable::CachableEntry<rocksdb::FilterBlockReader>::Release(rocksdb::Cache*,,rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
      1 pthread_cond_wait@@GLIBC_2.3.2,rocksdb::port::CondVar::Wait(),rocksdb::InstrumentedCondVar::WaitInternal(),rocksdb::InstrumentedCondVar::Wait(),rocksdb::DeleteScheduler::BackgroundEmptyTrash(),execute_native_thread_routine,start_thread,clone
      1 pthread_cond_wait@@GLIBC_2.3.2,background_thread_sleep,background_work_sleep_once,background_thread0_work,background_work,background_thread_entry,start_thread,clone
      1 pthread_cond_timedwait@@GLIBC_2.3.2,inline_mysql_cond_timedwait,myrocks::Rdb_drop_index_thread::run(),myrocks::Rdb_thread::thread_func(void*),start_thread,clone
      1 pthread_cond_timedwait@@GLIBC_2.3.2,inline_mysql_cond_timedwait,myrocks::Rdb_background_thread::run(),myrocks::Rdb_thread::thread_func(void*),start_thread,clone
      1 poll,poll,handle_connections_sockets(bool,,handle_connections_sockets_all(),mysqld_main(int,,__libc_start_main,_start

PMP for the "all" variation doesn't show this problem. Although 4 of 24 threads have this at the top of the stack trace -> rocksdb::ThreadLocalPtr::Get(),rocksdb::get_perf_context(), which is a known problem recently fixed by Anirban.

mdcallag commented 7 years ago

QPS for the tests repeated using a 2g block cache (buffer pool) and buffered IO so all data is in the OS page cache. Results for MyRocks are similar to the results above for the cached database.

QPS for all test
                1       8       16      24      32      40      48
InnoDB-801      554     4702     9202   12269   12181   11370    9506
InnoDB-5717     528     2310     6811   11646   14144   17271   17943
InnoDB-5635     351     3118     5317    6786   11876   12344   12857
MyRocks-Jun16   843     6131    11541   15495   17467   19048   20105

QPS for 1in10 test
                1       8       16      24      32      40      48
InnoDB-801      2530     9670    9846    9842   11265   12547   13741
InnoDB-5717     2736    10854   11125   11247   12956   14341   15656
InnoDB-5635     1908     4265    4405    4631    5705    6529    7216
MyRocks-Jun16   1997     9112    9602    9480    9263    9123    8993
mdcallag commented 7 years ago

Some perf debugging for MySQL 5.6.35 & InnoDB, from the 24-client test

For the "all" test and a 50gb block cache there is contention on rw_lock

      2 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,mtr_s_lock_func,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOI
N*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle
_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,mtr_release_s_latch_at_savepoint,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String
*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(S
tring*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_get_writer,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute
_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_get_writer,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(TH
D*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone

And the flat CPU profile for the "all" test

    34.66%  mysqld   mysqld               [.] btr_cur_search_to_nth_level
    21.06%  mysqld   mysqld               [.] rec_get_offsets_func
    10.72%  mysqld   mysqld               [.] buf_page_get_gen
     8.09%  mysqld   mysqld               [.] row_search_for_mysql
     2.36%  mysqld   mysqld               [.] innobase_release_temporary_latches
     2.23%  mysqld   mysqld               [.] cmp_dtuple_rec_with_match_low
     1.88%  mysqld   mysqld               [.] page_cur_search_with_match
     1.18%  mysqld   mysqld               [.] mtr_commit
     1.09%  mysqld   mysqld               [.] ha_innobase::index_read

rw_lock contention is much worse for the 1in10 variation

      3 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,buf_page_get_gen(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      2 rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      2 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,mtr_s_lock_func,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,buf_page_get_gen(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,buf_page_get_gen(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,buf_page_get_gen(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 pfs_rw_lock_s_unlock_func,buf_page_get_gen(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 pfs_rw_lock_s_lock_func,buf_page_get_gen(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_sel_try_search_shortcut_for_mysql,row_search_for_mysql(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*),Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),pfs_spawn_thread(void*),start_thread,clone

And the flat CPU profile for InnoDB in 5.6.35

    36.33%  mysqld   mysqld               [.] buf_page_get_gen
    30.79%  mysqld   mysqld               [.] btr_cur_search_to_nth_level
    10.94%  mysqld   mysqld               [.] rec_get_offsets_func
     7.39%  mysqld   mysqld               [.] mtr_commit
     2.00%  mysqld   mysqld               [.] cmp_dtuple_rec_with_match_low
     1.85%  mysqld   mysqld               [.] page_cur_search_with_match
     1.72%  mysqld   mysqld               [.] row_search_for_mysql
     0.85%  mysqld   mysqld               [.] buf_page_make_young_if_needed
     0.45%  mysqld   mysqld               [.] ha_innobase::index_read
     0.36%  mysqld   mysqld               [.] bmove_upp
     0.25%  mysqld   mysqld               [.] pfs_rw_lock_s_unlock_func
     0.24%  mysqld   mysqld               [.] my_qsort2
mdcallag commented 7 years ago

For 24 clients, InnoDB in 5.7.17 and the 1in10 test there is less rw_lock contention than in 5.6.35

      3 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func(rw_lock_t*,,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_incr,rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,buf_page_release_latch,mtr_t::release_block_at_savepoint(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_incr,rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,buf_page_release_latch,memo_slot_release,ReleaseAll::operator()(mtr_memo_slot_t*),Iterate<ReleaseAll>::operator()(dyn_buf_t<512ul>::block_t*),dyn_buf_t<512ul>::for_each_block_in_reverse<Iterate<ReleaseAll>,mtr_t::Command::release_all(),mtr_t::commit(),row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_incr,rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 pfs_rw_lock_s_lock_func(rw_lock_t*,,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone

And the flat CPU profile

    19.82%  mysqld   mysqld               [.] buf_page_get_gen
    16.17%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
    10.72%  mysqld   mysqld               [.] mtr_t::release_block_at_savepoint
     7.77%  mysqld   mysqld               [.] btr_cur_search_to_nth_level
     6.44%  mysqld   mysqld               [.] mtr_t::Command::release_all
     5.20%  mysqld   mysqld               [.] pfs_rw_lock_s_unlock_func
     4.91%  mysqld   mysqld               [.] page_cur_search_with_match
     3.48%  mysqld   mysqld               [.] buf_page_hash_get_low
     2.84%  mysqld   mysqld               [.] rec_get_offsets_func
     2.75%  mysqld   mysqld               [.] btr_pcur_move_to_next
     2.72%  mysqld   mysqld               [.] buf_page_make_young_if_needed
     1.87%  mysqld   mysqld               [.] cmp_dtuple_rec_with_match_low
     1.25%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
     0.37%  mysqld   mysqld               [.] btr_pcur_store_position
     0.32%  mysqld   mysqld               [.] cmp_longlong
     0.31%  mysqld   mysqld               [.] row_search_mvcc
     0.29%  mysqld   mysqld               [.] SEL_ARG::insert
     0.25%  mysqld   libc-2.20.so         [.] __memcpy_avx_unaligned
     0.24%  mysqld   mysqld               [.] alloc_root

And then from the "all" test, again at 24 clients:

      2 rw_lock_lock_word_incr,rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func(rw_lock_t*),mtr_t::release_s_latch_at_savepoint(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func(rw_lock_t*,,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),handle_query(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone

And the flat profile, the "all" test and 24 clients

    16.49%  mysqld   mysqld               [.] buf_page_get_gen
    12.03%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
    11.05%  mysqld   mysqld               [.] mtr_t::release_block_at_savepoint
     8.14%  mysqld   mysqld               [.] pfs_rw_lock_s_unlock_func
     7.69%  mysqld   mysqld               [.] rec_get_offsets_func
     5.35%  mysqld   mysqld               [.] btr_cur_search_to_nth_level
     4.14%  mysqld   mysqld               [.] page_cur_search_with_match
     3.72%  mysqld   mysqld               [.] buf_page_hash_get_low
     3.33%  mysqld   mysqld               [.] cmp_dtuple_rec_with_match_low
     2.29%  mysqld   mysqld               [.] buf_page_make_young_if_needed
     2.13%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
     1.00%  mysqld   mysqld               [.] row_search_mvcc
     0.73%  mysqld   mysqld               [.] cmp_longlong
     0.49%  mysqld   libc-2.20.so         [.] __memcpy_avx_unaligned
     0.33%  mysqld   mysqld               [.] SEL_ARG::insert
     0.32%  mysqld   mysqld               [.] free
     0.31%  mysqld   mysqld               [.] my_longlong10_to_str_8bit
     0.29%  mysqld   mysqld               [.] Item_func::fix_func_arg
     0.29%  mysqld   mysqld               [.] alloc_root
     0.29%  mysqld   mysqld               [.] mtr_t::Command::release_all
     0.28%  mysqld   mysqld               [.] get_mm_parts
     0.26%  mysqld   mysqld               [.] std::__introsort_loop<in_longlong::packed_longlong*, long, __gnu_cxx::__ops::_Iter_comp_iter<Cmp_longlong> >
     0.26%  mysqld   mysqld               [.] in_longlong::find_value
     0.25%  mysqld   mysqld               [.] Item_func_in::fix_length_and_dec
     0.25%  mysqld   mysqld               [.] btr_pcur_store_position
mdcallag commented 7 years ago

And for 8.0.1, 24 clients and the 1in10 test. Mutex contention is similar to 5.7.17

      2 rw_lock_lock_word_incr,rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func(rw_lock_t*),mtr_t::release_s_latch_at_savepoint(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      2 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func(rw_lock_t*,,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      2 pfs_rw_lock_s_lock_func(rw_lock_t*,,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_incr,rw_lock_s_unlock_func,pfs_rw_lock_s_unlock_func,buf_page_release_latch,mtr_t::release_block_at_savepoint(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func(rw_lock_t*,,mtr_t::s_lock(rw_lock_t*,,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone

And the flat CPU profile

    19.76%  mysqld   mysqld               [.] buf_page_get_gen
    14.20%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
    10.33%  mysqld   mysqld               [.] mtr_t::release_block_at_savepoint
     9.32%  mysqld   mysqld               [.] mtr_t::Command::release_all
     5.58%  mysqld   mysqld               [.] btr_cur_search_to_nth_level
     5.05%  mysqld   mysqld               [.] page_cur_search_with_match
     4.84%  mysqld   mysqld               [.] pfs_rw_lock_s_unlock_func
     3.79%  mysqld   mysqld               [.] buf_page_hash_get_low
     2.96%  mysqld   mysqld               [.] btr_pcur_move_to_next
     2.91%  mysqld   mysqld               [.] buf_page_make_young_if_needed
     2.12%  mysqld   mysqld               [.] cmp_dtuple_rec_with_match_low
     1.63%  mysqld   mysqld               [.] rec_init_offsets
     1.37%  mysqld   mysqld               [.] rec_get_offsets_func
     1.20%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
     0.56%  mysqld   mysqld               [.] row_search_mvcc
     0.34%  mysqld   mysqld               [.] SEL_ROOT::insert
     0.27%  mysqld   mysqld               [.] alloc_root

And then for the all variation

      3 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func(rw_lock_t*,,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 rw_lock_lock_word_decr,rw_lock_s_lock_low,rw_lock_s_lock_func,pfs_rw_lock_s_lock_func,buf_page_get_gen(page_id_t,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone
      1 pfs_rw_lock_s_unlock_func,buf_page_release_latch,mtr_t::release_block_at_savepoint(unsigned,btr_cur_search_to_nth_level(dict_index_t*,,btr_pcur_open_with_no_init_func,row_search_mvcc(unsigned,ha_innobase::index_read(unsigned,handler::ha_index_read_map(unsigned,handler::read_range_first(st_key_range,handler::multi_range_read_next(char**),handler::ha_multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),Sql_cmd_dml::execute_inner(THD*),Sql_cmd_dml::execute(THD*),mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(THD*,,do_command(THD*),handle_connection(void*),pfs_spawn_thread(void*),start_thread,clone

And the flat profile

    16.96%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
    12.57%  mysqld   mysqld               [.] buf_page_get_gen
    11.47%  mysqld   mysqld               [.] mtr_t::release_block_at_savepoint
    10.29%  mysqld   mysqld               [.] pfs_rw_lock_s_unlock_func
     5.70%  mysqld   mysqld               [.] rec_get_offsets_func
     3.56%  mysqld   mysqld               [.] page_cur_search_with_match
     3.37%  mysqld   mysqld               [.] buf_page_hash_get_low
     3.36%  mysqld   mysqld               [.] cmp_dtuple_rec_with_match_low
     3.06%  mysqld   mysqld               [.] rec_init_offsets
     2.23%  mysqld   mysqld               [.] btr_cur_search_to_nth_level
     1.60%  mysqld   mysqld               [.] pfs_rw_lock_s_lock_func
     1.40%  mysqld   mysqld               [.] buf_page_make_young_if_needed
     1.10%  mysqld   mysqld               [.] row_search_mvcc
     0.48%  mysqld   libc-2.20.so         [.] __memcpy_avx_unaligned
     0.39%  mysqld   mysqld               [.] std::__introsort_loop<in_longlong::packed_longlong*, long, __gnu_cxx::__ops::_Iter_comp_iter<Cmp_longlong> >
     0.38%  mysqld   mysqld               [.] SEL_ROOT::find_range
     0.37%  mysqld   mysqld               [.] mtr_t::Command::release_all
     0.36%  mysqld   mysqld               [.] free
mdcallag commented 7 years ago

Tests above used 1 table with 80M rows. I repeated all tests with 8 tables and 10M rows/table which should reduce hot spots. That helped a lot with the 1in10 tests. That didn't help much with the "all" tests for the cached (50gb block cach) database. 5 of 24 user query threads were stuck on LRU mutexes in one PMP sample and 12 or 24 were stuck in another.

      2 pthread_mutex_unlock,rocksdb::port::Mutex::Unlock(),rocksdb::MutexLock::~MutexLock(),rocksdb::LRUCacheShard::Lookup(rocksdb::Slice,rocksdb::(anonymous,rocksdb::BlockBasedTable::GetDataBlockFromCache(rocksdb::Slice,rocksdb::BlockBasedTable::MaybeLoadDataBlockToCache(rocksdb::BlockBasedTable::Rep*,,rocksdb::BlockBasedTable::NewDataBlockIterator(rocksdb::BlockBasedTable::Rep*,,rocksdb::BlockBasedTable::NewDataBlockIterator(rocksdb::BlockBasedTable::Rep*,,rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
      1 pthread_mutex_unlock,rocksdb::port::Mutex::Unlock(),rocksdb::MutexLock::~MutexLock(),rocksdb::LRUCacheShard::Lookup(rocksdb::Slice,rocksdb::(anonymous,rocksdb::BlockBasedTable::NewIndexIterator(rocksdb::ReadOptions,rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
      1 __lll_unlock_wake,pthread_mutex_unlock,rocksdb::port::Mutex::Unlock(),rocksdb::MutexLock::~MutexLock(),rocksdb::LRUCacheShard::Lookup(rocksdb::Slice,rocksdb::(anonymous,rocksdb::BlockBasedTable::NewIndexIterator(rocksdb::ReadOptions,rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone
      1 __lll_unlock_wake,pthread_mutex_unlock,rocksdb::port::Mutex::Unlock(),rocksdb::MutexLock::~MutexLock(),rocksdb::LRUCacheShard::Lookup(rocksdb::Slice,rocksdb::(anonymous,rocksdb::BlockBasedTable::GetDataBlockFromCache(rocksdb::Slice,rocksdb::BlockBasedTable::MaybeLoadDataBlockToCache(rocksdb::BlockBasedTable::Rep*,,rocksdb::BlockBasedTable::NewDataBlockIterator(rocksdb::BlockBasedTable::Rep*,,rocksdb::BlockBasedTable::NewDataBlockIterator(rocksdb::BlockBasedTable::Rep*,,rocksdb::BlockBasedTable::Get(rocksdb::ReadOptions,rocksdb::TableCache::Get(rocksdb::ReadOptions,rocksdb::Version::Get(rocksdb::ReadOptions,rocksdb::DBImpl::GetImpl(rocksdb::ReadOptions,rocksdb::DBImpl::Get(rocksdb::ReadOptions,rocksdb::DB::Get(rocksdb::ReadOptions,rocksdb::WriteBatchWithIndex::GetFromBatchAndDB(rocksdb::DB*,,rocksdb::TransactionBaseImpl::Get(rocksdb::ReadOptions,myrocks::Rdb_transaction_impl::get(rocksdb::ColumnFamilyHandle*,,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::get_row_by_rowid(unsigned,myrocks::ha_rocksdb::index_read_map_impl(unsigned,myrocks::ha_rocksdb::read_range_first(st_key_range,handler::multi_range_read_next(char**),QUICK_RANGE_SELECT::get_next(),rr_quick(READ_RECORD*),sub_select(JOIN*,,do_select,JOIN::exec(),mysql_execute_select,mysql_select(THD*,,handle_select(THD*,,execute_sqlcom_select(THD*,,mysql_execute_command(THD*,,Prepared_statement::execute(String*,,Prepared_statement::execute_loop(String*,,mysqld_stmt_execute(THD*,,dispatch_command(enum_server_command,,do_command(THD*),do_handle_one_connection(THD*),handle_one_connection(void*),start_thread,clone

And the flat CPU profile from that example:

     5.11%  my-oneconnectio  mysqld               [.] rocksdb::BlockIter::Seek
     4.82%  my-oneconnectio  libpthread-2.20.so   [.] pthread_mutex_unlock
     4.70%  my-oneconnectio  mysqld               [.] rocksdb::BlockIter::BinarySeek
     4.14%  my-oneconnectio  mysqld               [.] rocksdb::ThreadLocalPtr::Get
     3.96%  my-oneconnectio  mysqld               [.] rocksdb::LRUCacheShard::Lookup
     2.64%  my-oneconnectio  libpthread-2.20.so   [.] pthread_mutex_lock
     2.39%  my-oneconnectio  libc-2.20.so         [.] __memcmp_sse4_1
     2.32%  my-oneconnectio  mysqld               [.] rocksdb::InternalKeyComparator::Compare
     2.25%  my-oneconnectio  mysqld               [.] rocksdb::Block::NewIterator
     1.67%  my-oneconnectio  mysqld               [.] rocksdb::Version::Get
     1.61%  my-oneconnectio  mysqld               [.] rocksdb::LRUCacheShard::Release
     1.46%  my-oneconnectio  libc-2.20.so         [.] __memcpy_avx_unaligned
     1.43%  my-oneconnectio  mysqld               [.] rocksdb::StatisticsImpl::recordTick
     1.43%  my-oneconnectio  mysqld               [.] myrocks::Rdb_pk_comparator::Compare
     1.30%  my-oneconnectio  mysqld               [.] my_qsort2
     1.27%  my-oneconnectio  [kernel.kallsyms]    [k] try_to_wake_up
     1.22%  my-oneconnectio  mysqld               [.] rocksdb::get_perf_context
     1.19%  my-oneconnectio  mysqld               [.] bmove_upp
     1.17%  my-oneconnectio  mysqld               [.] rocksdb::(anonymous namespace)::FullFilterBitsReader::MayMatch
     1.14%  my-oneconnectio  mysqld               [.] rocksdb::ShardedCache::Lookup
     1.09%  my-oneconnectio  mysqld               [.] rocksdb::HistogramStat::Add
     0.88%  my-oneconnectio  mysqld               [.] sel_cmp
     0.86%  my-oneconnectio  [kernel.kallsyms]    [k] queued_spin_lock_slowpath
mdcallag commented 7 years ago

QPS for all of the tests repeated with 8 tables and 10M rows/table. The tests above used 1 table and 80M rows/table.

all.2g.8t.10m
                1       8       16      24      32      40      48
InnoDB-801      461     4259     8725   14114   19481   14978   12405
InnoDB-5717     481     4461     7866   13021   18666   19031   17400
InnoDB-5635     186     1767     4411    5774    6135    6210    7004
MyRocks-Jun16   851     6386    12056   16299   18354   20139   21363

1in10.2g.8t.10m
                1       8       16      24      32      40      48
InnoDB-801      2468    16953   30309   39278   42916   46377   49604
InnoDB-5717     2650    17869   31388   40071   43954   47431   50538
InnoDB-5635     1823    10216   10124    9154   10375   11439   12352
MyRocks-Jun16   1969    14853   26940   33539   36517   39321   41498

all.50g.8t.10m
                1       8       16      24      32      40      48
InnoDB-801      1738    13110   24786   33511   38080   41367   44939
InnoDB-5717     1842    13939   25962   34992   40040   43827   47600
InnoDB-5635     2019    12605   12761   12525   13855   14937   16171
MyRocks-Jun16   982      7564   14221   19041   21560   23894   25518

1in10.50g.8t.10m
                1       8       16      24      32      40      48
InnoDB-801      2464    16995   30451   39385   43179   46898   50248
InnoDB-5717     2660    18034   31662   40645   44167   47186   49775
InnoDB-5635     1833    10184    9355    8732   10028   11149   12031
MyRocks-Jun16   1830    13909   25527   31908   34820   37928   39997
mdcallag commented 7 years ago

This is QPS for the hot-points workload on a server with 24 CPU cores & 48 HW-threads.

1       2       4       8       16      24      32      40      48      64      threads
- new
1343    2624    5099    9746    17858   22986   25147   27254   28439   29784   8 tables
1448    2618    4751    7776     9331    9526    9402    9332    9238    9284   1 table

Using:

Example command lines. Note that these take a long time to reach the hot-points workload

# 1 table, 8M rows/table
bash all.sh 1 8000000 180 300 180 rocksdb 1 0 /data/mysql/myrocks/bin/mysql none /data/mysql/sysbench10

# 8 tables, 1M rows/table
bash all.sh 181000000 180 300 180 rocksdb 1 0 /data/mysql/myrocks/bin/mysql none /data/mysql/sysbench10

This might reproduce the problem in less time compared to using all.sh

ntabs=$1
nrows=$2
readsecs=$3
writesecs=$4
insertsecs=$5
engine=$6
setup=$7
cleanup=$8
client=$9
tableoptions=${10}
sysbdir=${11}

concurrency="1 8 24"

echo update-index
bash run.sh $ntabs $nrows $writesecs $engine $setup 0        update-index    100    $client $tableoptions $sysbdir $concurrency

echo point-query
bash run.sh $ntabs $nrows $readsecs  $engine 0      0        point-query     100    $client $tableoptions $sysbdir $concurrency

echo random-points
bash run.sh $ntabs $nrows $readsecs  $engine 0      0        random-points   100    $client $tableoptions $sysbdir $concurrency

echo hot-points
bash run.sh $ntabs $nrows $readsecs  $engine 0      0        hot-points      100    $client $tableoptions $sysbdir $concurrency
yiwu-arbug commented 7 years ago

@mdcallag where can I find the tests script of 1in10 and other tests (hot-points, random-points, etc) that I can try to run? I already have sysbench but don't seems to have these tests in it. Thanks!

mdcallag commented 7 years ago

For anyone else reading this:

On Fri, Aug 25, 2017 at 9:52 AM, yiwu-arbug notifications@github.com wrote:

@mdcallag https://github.com/mdcallag where can I find the tests script of 1in10 and other tests (hot-points, random-points, etc) that I can try to run? Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/mysql-5.6/issues/674#issuecomment-324976794, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkKTbUNl951d59qsHQzw70TuTPlvs1yks5sbvvhgaJpZM4Orxt2 .

-- Mark Callaghan mdcallag@gmail.com

mdcallag commented 3 months ago

I assume the solution is to use the hyperclock block cache in RocksDB