Skip to content
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

gc/default/default.c: don't call malloc_usable_size when hint is present #12490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

byroot
Copy link
Member

@byroot byroot commented Dec 30, 2024

Depending on the allocator, malloc_usable_size may be very cheap or quite expensive. On macOS for instance, it's about as expensive as malloc.

In many case we call objspace_malloc_size with as size we initially requested as hint. The real usable size may be a few bytes bigger, but since we only use that data to feed GC heuristics, I don't think it's very important to be perfectly accurate.

It would make sense to call malloc_usable_size after growing a String or Array to use the extra capacity, but here we don't do that, so the call isn't worth its cost.

References:

…esent

Depending on the allocator, `malloc_usable_size` may be very cheap or quite
expensive. On `macOS` for instance, it's about as expensive as `malloc`.

In many case we call `objspace_malloc_size` with as size we initially
requested as `hint`. The real usable size may be a few bytes bigger,
but since we only use that data to feed GC heuristics, I don't think
it's very important to be perfectly accurate.

It would make sense to call `malloc_usable_size` after growing a String
or Array to use the extra capacity, but here we don't do that, so
the call isn't worth its cost.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant