Skip to content

[backport 3.2] read view closing performance improvement#12123

Merged
sergepetrenko merged 1 commit intorelease/3.2from
backport/release/3.2/12019
Dec 9, 2025
Merged

[backport 3.2] read view closing performance improvement#12123
sergepetrenko merged 1 commit intorelease/3.2from
backport/release/3.2/12019

Conversation

@TarantoolBot
Copy link
Collaborator

@TarantoolBot TarantoolBot commented Dec 9, 2025

(This PR is a backport of #12019 to release/3.2 to a future 3.2.4 release.)


Inside tuple_dictionary_delete_hash, there was a loop that, on each iteration, searched for the first non-deleted element using mh_first, which has a complexity of O(n), and deleted it using mh_strnu32_del. After the loop finished executing, tuple_dictionary_delete_hash immediately called mh_strnu32_delete.
All elements are stored in the hashmap inplace, so del doesn't invoke any memory deallocation functions. del also doesn't call destructors for the elements; it merely sets a specific bit in the bitmap to 0. Immediately after the loop, mh_strnu32_delete(hash) will delete the hashmap hash along with the array hash->p containing all elements inplace.

This PR simply removes this useless loop, which was causing significant performance issues when closing a read view.

Closes tarantool/tarantool-ee#1043, #12115

NO_DOC=performance improvement
NO_TEST=performance improvement

Inside `tuple_dictionary_delete_hash`, there was a loop that, on each
iteration, searched for the first non-deleted element using `mh_first`,
which has a complexity of `O(n)`, and deleted it using `mh_strnu32_del`.
After the loop finished executing, `tuple_dictionary_delete_hash`
immediately called `mh_strnu32_delete`.
All elements are stored in the hashmap inplace, so `del` doesn't invoke
any memory deallocation functions. `del` also doesn't call destructors for
the elements; it merely sets a specific bit in the bitmap to 0.
Immediately after the loop, `mh_strnu32_delete(hash)` will delete the
hashmap `hash` along with the array `hash->p` containing all elements
inplace.

This commit simply removes this useless loop, which was causing
significant performance issues when closing a read view.

Closes tarantool/tarantool-ee#1043, #12115

NO_DOC=performance improvement
NO_TEST=performance improvement

(cherry picked from commit 4b72007)
@TarantoolBot TarantoolBot requested a review from a team as a code owner December 9, 2025 09:37
@TarantoolBot TarantoolBot changed the title [Backport release/3.2] read view closing performance improvement [backport 3.2] read view closing performance improvement Dec 9, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.453% (+0.04%) from 87.414%
when pulling 4353254 on backport/release/3.2/12019
into 31e9046
on release/3.2
.

@sergepetrenko sergepetrenko merged commit 46fa5e2 into release/3.2 Dec 9, 2025
23 checks passed
@sergepetrenko sergepetrenko deleted the backport/release/3.2/12019 branch December 9, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants