1. 21 Jun, 2020 6 commits
  2. 19 Jun, 2020 27 commits
  3. 18 Jun, 2020 7 commits
    • Vladislav Vaintroub's avatar
    • Vladislav Vaintroub's avatar
    • Daniel Black's avatar
    • Marko Mäkelä's avatar
      MDEV-22871: Reduce InnoDB buf_pool.page_hash contention · 5155a300
      Marko Mäkelä authored
      The rw_lock_s_lock() calls for the buf_pool.page_hash became a
      clear bottleneck after MDEV-15053 reduced the contention on
      buf_pool.mutex. We will replace that use of rw_lock_t with a
      special implementation that is optimized for memory bus traffic.
      
      The hash_table_locks instrumentation will be removed.
      
      buf_pool_t::page_hash: Use a special implementation whose API is
      compatible with hash_table_t, and store the custom rw-locks
      directly in buf_pool.page_hash.array, intentionally sharing
      cache lines with the hash table pointers.
      
      rw_lock: A low-level rw-lock implementation based on std::atomic<uint32_t>
      where read_trylock() becomes a simple fetch_add(1).
      
      buf_pool_t::page_hash_latch: The special of rw_lock for the page_hash.
      
      buf_pool_t::page_hash_latch::read_lock(): Assert that buf_pool.mutex
      is not being held by the caller.
      
      buf_pool_t::page_hash_latch::write_lock() may be called while not holding
      buf_pool.mutex. buf_pool_t::watch_set() is such a caller.
      
      buf_pool_t::page_hash_latch::read_lock_wait(),
      page_hash_latch::write_lock_wait(): The spin loops.
      These will obey the global parameters innodb_sync_spin_loops and
      innodb_sync_spin_wait_delay.
      
      buf_pool_t::freed_page_hash: A singly linked list of copies of
      buf_pool.page_hash that ever existed. The fact that we never
      free any buf_pool.page_hash.array guarantees that all
      page_hash_latch that ever existed will remain valid until shutdown.
      
      buf_pool_t::resize_hash(): Replaces buf_pool_resize_hash().
      Prepend a shallow copy of the old page_hash to freed_page_hash.
      
      buf_pool_t::page_hash_table::n_cells: Declare as Atomic_relaxed.
      
      buf_pool_t::page_hash_table::lock(): Explain what prevents a
      race condition with buf_pool_t::resize_hash().
      5155a300
    • Marko Mäkelä's avatar
      MDEV-22871: Remove pointer indirection for InnoDB hash_table_t · cfd3d70c
      Marko Mäkelä authored
      hash_get_n_cells(): Remove. Access n_cells directly.
      
      hash_get_nth_cell(): Remove. Access array directly.
      
      hash_table_clear(): Replaced with hash_table_t::clear().
      
      hash_table_create(), hash_table_free(): Remove.
      
      hash0hash.cc: Remove.
      cfd3d70c
    • Marko Mäkelä's avatar
      MDEV-22871: Clean up btr_search_sys · bf3c862f
      Marko Mäkelä authored
      btr_search_sys::parts[]: A single structure for the partitions of
      the adaptive hash index. Replaces the 3 separate arrays:
      btr_search_latches[], btr_search_sys->hash_tables,
      btr_search_sys->hash_tables[i]->heap.
      
      hash_table_t::heap, hash_table_t::adaptive: Remove.
      
      ha0ha.cc: Remove. Move all code to btr0sea.cc.
      bf3c862f
    • Marko Mäkelä's avatar
      MDEV-22871: Clean up hash_table_t · 9159b897
      Marko Mäkelä authored
      HASH_TABLE_SYNC_MUTEX was kind-of used for the adaptive hash index,
      even though that hash table is already protected by btr_search_latches[].
      
      HASH_TABLE_SYNC_RWLOCK was only being used for buf_pool.page_hash.
      It is cleaner to decouple that synchronization from hash_table_t,
      and move it to the actual user.
      
      buf_pool_t::page_hash_latches[]: Synchronization for buf_pool.page_hash.
      
      LATCH_ID_HASH_TABLE_MUTEX: Remove.
      
      hash_table_t::sync_obj, hash_table_t::n_sync_obj: Remove.
      
      hash_table_t::type, hash_table_sync_t: Remove.
      
      HASH_ASSERT_OWN(), hash_get_mutex(), hash_get_nth_mutex(): Remove.
      
      ib_recreate(): Merge to the only caller, buf_pool_resize_hash().
      
      ib_create(): Merge to the callers.
      
      ha_clear(): Merge to the only caller buf_pool_t::close().
      
      buf_pool_t::create(): Merge the ib_create() and
      hash_create_sync_obj() invocations.
      
      ha_insert_for_fold_func(): Clarify an assertion.
      
      buf_pool_t::page_hash_lock(): Simplify the logic.
      
      hash_assert_can_search(), hash_assert_can_modify(): Remove.
      These predicates were only being invoked for the adaptive hash index,
      while they only are effective for buf_pool.page_hash.
      
      HASH_DELETE_AND_COMPACT(): Merge to ha_delete_hash_node().
      
      hash_get_sync_obj_index(): Remove.
      
      hash_table_t::heaps[], hash_get_nth_heap(): Remove. It was actually unused!
      
      hash_get_heap(): Remove. It was only used in ha_delete_hash_node(),
      where we always use hash_table_t::heap.
      
      hash_table_t::calc_hash(): Replaces hash_calc_hash().
      9159b897