[libc-commits] [libc] [libc] Use best-fit binary trie to make malloc logarithmic (PR #106259)
Daniel Thornburgh via libc-commits
libc-commits at lists.llvm.org
Thu Oct 10 16:03:43 PDT 2024
================
@@ -28,23 +28,16 @@ extern "C" cpp::byte __llvm_libc_heap_limit;
using cpp::optional;
using cpp::span;
-inline constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
+LIBC_INLINE constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
-static constexpr cpp::array<size_t, 6> DEFAULT_BUCKETS{16, 32, 64,
- 128, 256, 512};
-
-template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
+class FreeListHeap {
----------------
mysterymath wrote:
That's true, but I was struggling to come up with an alternative. The general name for this kind of allocator is a boundary tag allocator, as opposed to a "big bag of pages" (BIBOP) allocator. (I've heard a lot of different phrases for the latter.) But BoundaryTagHeap sounds overly technical, and BlockHeap doesn't specify enough about what the semantics of the blocks are (i.e, pages of fixed-size objects are also commonly called "blocks"). KnuthHeap and DLHeap have people names in them...
EmbeddedHeap is the best I've come up with so far, but I'm still not in love with it. We could also just call it "Heap". The name is also fairly important; it will form a part of the user-facing CMake language used to specify whether to build it.
Any ideas?
https://github.com/llvm/llvm-project/pull/106259
More information about the libc-commits
mailing list