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

Refactor how CowData manages its allocations #74582

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

Commits on Aug 26, 2023

  1. Refactor how CowData manages its allocations

    - Use an explicit type for the data prefix to enable easier changes.
    - Explicitly store the capacity instead of using the next power of two.
    - If resizing to a significantly larger size (more 2x the current
      capacity), assume that the caller has just resized to their final
      size and don't allocate any excess capacity.
    - Trim the capacity less aggressively to fix edge cases when repeatedly
      adding and removing elements causing extreme performance issues.
    - Do not rely on overflow checked operations to determine the maximum
      size, to avoid crashes with some compilers when using too large sizes.
    - On 64-bit system increase the the maximum size to 0x7ffffff0,
      generally by a factor of the size of the elements.
    - On 32-bit system the maximum size remains limited by the size of the
      address space / memory, but in some cases it may still be possible to
      allocate larger arrays compared to before.
    - Add a minimum capacity to remove some unnecessary reallocation for
      small arrays.
    - Remove a few unnecessary potential copies when resizing, adding or
      removing elements.
    RedworkDE committed Aug 26, 2023
    Configuration menu
    Copy the full SHA
    c2c6fb3 View commit details
    Browse the repository at this point in the history