Open the8472 opened 2 months ago
Can you give examples of how generic code (e.g. Vec
) could make use of these properties?
support for alignment-changing realloc
Would allow the in-place collect code in vec to apply in more cases. Currently GlobaAlloc does this: https://doc.rust-lang.org/nightly/src/alloc/alloc.rs.html#302-321 which means shrinking efficiency depends on the layouts, but some allocators can do better than that
does realloc try to avoid memcpy
can help picking between new-allocation-and-grow vs. reuse-allocation-and-shrink strategies. I.e. when shrinking incurs memcpy costs then it's better to use a fresh allocation from the beginning.
It would also let us pick between realloc vs. alloc-manually-copy-dealloc when there's a huge discrepancy between capacity and length.
do realloc/dealloc care about the layout information being correct
lets in-place-collect skip some realloc calls
whether deallocation does anything
for non-drop T we can turn Container
And that's just examples. The list should be extensible of course. Flags would need to have conservative defaults.
It would be useful if allocators had an associated constant of flags describing their properties, such as
allocate
Containers can then choose to optimize their behavior based on those properties.
(from https://github.com/rust-lang/wg-allocators/issues/120#issuecomment-1999418118)