Skip to content

Optimize Allocator::grow and Allocator::shrink for the last allocation in ngx_pool_t. #169

Open
@bavshin-f5

Description

@bavshin-f5

Does ngx_pool_t do non-noop frees if done in LIFO order? If so, then it would also make sense for it to support in-place reallocs for the last allocation, and override the provided default methods for Allocator::grow and Allocator::shrink here as well.

Allowing the last allocation to grow in-place, even in bump allocators, is particularly nice when building Vecs of an unknown number of elements and which end up resizing and growing their underlying storage.

Originally posted by @fitzgen in #164 (comment)

The approach has been used in ngx_array_push since nginx 0.1, and the underlying structures are quite stable. The optimization would be quite beneficial for building arrays and strings on pool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions