Make goodMallocSize always use nallocx
Summary: `goodMallocSize` is used extensively in `folly` data structures, especially for containers optimized for small contents, such as `fbstring` and `small_vector`. However, it makes the design decision to align the allocation size to a x86 cache line, forcing a minimum allocation size of `64` bytes, despite jemalloc can provide smaller size classes (8, 16, 32, 48). This causes a large discontinuity between small contents that can be inlined and heap-allocated contents: - For `fbstring`, a string of 23 bytes (including terminator) occupies 24 bytes (`sizeof(fbstring)`), a string of 24 bytes occupies 24 + 64 + allocation overhead when it could be 24 + 32 + allocation overhead. The waste is more than 50%. - For `small_vector<uint32_t, 1, uint32_t>`, for instance, a vector with 1 element occupies 12 bytes, a vector with 2 elements occupies 12 + 64 + allocation overhead when it could be 12 + 8 + allocation overhead. The waste is more than 250%. With this diff we just trust jemalloc and always use `nallocx`. If a data structure need cache-line alignment it should be implemented at its level. Reviewed By: elsteveogrande Differential Revision: D2688156 fb-gh-sync-id: 46548d4a91952e7c673d4f0997c4c067e03c190d
Showing
Please register or sign in to comment