MDEV-35190 HASH_SEARCH duplicates effort before HASH_INSERT or HASH_DELETE - #3627
Merged
Conversation
|
|
5 tasks
dr-m
force-pushed
the
10.6-MDEV-35190
branch
from
November 12, 2024 14:17
742991a to
d8f502e
Compare
dr-m
commented
Nov 13, 2024
dr-m
force-pushed
the
10.6-MDEV-35190
branch
3 times, most recently
from
November 14, 2024 07:01
13d590e to
d4b37ae
Compare
5 tasks
mariadb-DebarunBanerjee
approved these changes
Nov 20, 2024
mariadb-DebarunBanerjee
left a comment
Contributor
There was a problem hiding this comment.
Thanks @dr-m for keeping the hash table abstraction and still keeping the refactoring scope limited. Looks good to me.
…ELETE The HASH_ macros are unnecessarily obfuscating the logic, so we had better replace them. hash_cell_t::search(): Implement most of the HASH_DELETE logic, for a subsequent insert or remove(). hash_cell_t::remove(): Remove an element. hash_cell_t::find(): Implement the HASH_SEARCH logic. xb_filter_hash_free(): Avoid any hash table lookup; just traverse the hash bucket chains and free each element. xb_register_filter_entry(): Search databases_hash only once. rm_if_not_found(): Make use of find_filter_in_hashtable(). dict_sys_t::acquire_temporary_table(), dict_sys_t::find_table(): Define non-inline to avoid unnecessary code duplication. dict_sys_t::add(dict_table_t *table), dict_table_rename_in_cache(): Look for duplicate while finding the insert position. dict_table_change_id_in_cache(): Merged to the only caller row_discard_tablespace(). hash_insert(): Helper function of dict_sys_t::resize(). fil_space_t::create(): Look for a duplicate (and crash if found) when searching for the insert position. lock_rec_discard(): Take the hash array cell as a parameter to avoid a duplicated lookup. lock_rec_free_all_from_discard_page(): Remove a parameter. Reviewed by: Debarun Banerjee
ut_fold_ull(): For SIZEOF_SIZE_T < 8, we simulate universal hashing (Carter and Wegman, 1977) by pretending that SIZE_T_MAX + 1 is a prime. In other words, we implement a Rabin–Karp rolling hash algorithm similar to java.lang.String.hashCode(). This is used for representing 64-bit dict_index_t::id or dict_table_t::id in the native word size. For SIZEOF_SIZE_T >= 8, we just use an identity mapping. Reviewed by: Debarun Banerjee
ut_hash_ulint(): Remove. The exclusive OR before a modulus operation does not serve any useful purpose; it is only obfuscating code and wasting some CPU cycles. Reviewed by: Debarun Banerjee
dr-m
force-pushed
the
10.6-MDEV-35190
branch
from
November 21, 2024 07:00
d4b37ae to
df3855a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This supercedes #3593, which was accidentally closed and can’t be resurrected.
Description
The
HASH_macros are unnecessarily obfuscating the logic, so we had better replace them.hash_cell_t::remove(): Implement most of theHASH_DELETElogic. This is based onbuf_pool_t::page_hash_table::remove().xb_filter_hash_free(): Avoid any hash table lookup; just traverse the hash bucket chains and free each element.rm_if_not_found(): Make use offind_filter_in_hashtable().dict_sys_t::acquire_temporary_table(),dict_sys_t::find_table(): Define non-inline to avoid unnecessary code duplication.dict_sys_t::add(dict_table_t *table),dict_table_rename_in_cache(): Look for duplicate while finding the insert position.dict_table_change_id_in_cache(): Merged to the only callerrow_discard_tablespace().hash_insert(): Helper function ofdict_sys_t::resize().fil_space_t::create(): Look for a duplicate (and crash if found) when searching for the insert position.lock_rec_discard(): Take the hash array cell as a parameter to avoid a duplicated lookup.lock_rec_free_all_from_discard_page(): Remove a parameter.ut_fold_ull(): ForSIZEOF_SIZE_T < 8, we simulate universal hashing (Carter and Wegman, 1977) by pretending thatSIZE_T_MAX + 1is a prime. In other words, we implement a Rabin–Karp rolling hash algorithm similar tojava.lang.String.hashCode(). This is used for representing 64-bitdict_index_t::idordict_table_t::idin the native word size.If
SIZEOF_SIZE_T >= 8, we just use an identity mapping instead ofut_fold_ull().ut_hash_ulint(): Remove. The exclusive OR before a modulus operation does not serve any useful purpose; it is only obfuscating and wasting some code. mysql/mysql-server@b11a175 included a similar change.Release Notes
Some InnoDB hash table operations were simplified to slightly improve performance.
How can this PR be tested?
This low level code should be well covered by the regression test suite. Some additional performance and stress testing would be helpful.
Basing the PR against the correct MariaDB version
mainbranch.This depends on #3584 which was merged to 10.6.
PR quality check