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

LocalAllocator: add alloc_hinted #487

Closed
wants to merge 1 commit into from
Closed

LocalAllocator: add alloc_hinted #487

wants to merge 1 commit into from

Commits on Mar 21, 2022

  1. LocalAllocator: add alloc_hinted

    In current implementation, `alloc` expects small allocations are more
    likely, which is likely true for most cases, and puts small allocations
    in the fast path. However, in some scenario, the allocator users may know
    an approximate alloc size in compile time. For example, they may be
    allocating a certein type of objects that may have a typical size, but
    the actual size in runtime may vary; or they may know the least size of
    some objects.
    
    By introducing a method `add_hinted`, we can let users to hint the
    allocator. It accepts a compile-time size hint, based on which a hinted
    fast path is chosen, instead of always favoring small allocations.
    
    Currently, we use the size hint to adjust the fast path only in
    LocalAllocator. Further we can use hint to do more optimizations, like,
    adding `add_range_hinted` for backends, pass the hint from
    LocalAllocator to them, and adjust their fast path to passing the
    allocation to their parent or allocating by their own.
    ruihe774 committed Mar 21, 2022
    Configuration menu
    Copy the full SHA
    1ae7897 View commit details
    Browse the repository at this point in the history