Skip to content

small: improve real_size calculation in small_alloc_info #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Gumix
Copy link
Contributor

@Gumix Gumix commented Jun 5, 2025

Currently real_size is calculated as the size of a memory block that would be allocated for the requested number of bytes. However, this calculation is non-idempotent. For details see commit df7ba1f ("small: implement new allocator strategy").

This patch switches small_alloc_info() to slab_from_ptr() that returns the actual slab that contains the requested ptr, so now real_size is always correct.

Needed for tarantool/tarantool#10217

Merge only together with tarantool/tarantool#11652

This patch removes the following ancient declarations:
 - `size_t small_ptr_compress();`
 - `void *small_ptr_decompress();`
@Gumix Gumix marked this pull request as draft June 5, 2025 15:46
@Gumix Gumix marked this pull request as ready for review July 10, 2025 17:26
@Gumix Gumix added the do not merge Not ready to be merged label Jul 10, 2025
@Gumix Gumix requested review from locker and nshy July 10, 2025 19:34
@Gumix Gumix assigned locker and nshy Jul 10, 2025
@nshy nshy assigned Gumix and unassigned nshy Jul 11, 2025
@locker locker removed their assignment Jul 11, 2025
Currently `real_size` is calculated as the size of a memory block that
would be allocated for the requested number of bytes. However, this
calculation is non-idempotent. For details see commit df7ba1f
("small: implement new allocator strategy").

This patch switches `small_alloc_info()` to `slab_from_ptr()` that
returns the actual slab that contains the requested `ptr`, so now
`real_size` is always correct.

Needed for tarantool/tarantool#10217
@Gumix Gumix force-pushed the iverbin/improve-real_size-calculation-in-small_alloc_info branch from 26345ba to 216b33d Compare July 11, 2025 14:43
@Gumix Gumix requested a review from nshy July 11, 2025 14:46
@Gumix Gumix assigned nshy and unassigned Gumix Jul 11, 2025
@nshy nshy assigned Gumix and unassigned nshy Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Not ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants