[libc-commits] [libc] [libc] Cache the most recently used slot for a chunk size (PR #149751)

Matt Arsenault via libc-commits libc-commits at lists.llvm.org
Mon Jul 21 00:51:31 PDT 2025


================
@@ -451,66 +454,65 @@ struct GuardPtr {
 // The global array used to search for a valid slab to allocate from.
 static GuardPtr slots[ARRAY_SIZE] = {};
 
+// Keep a cache of the last successful slot for each chunk size. Initialize it
+// to an even spread of the total size. Must be updated if the chunking scheme
+// changes.
+#define S(X) (impl::start_index(X))
+static cpp::Atomic<uint32_t> indicies[] = {
----------------
arsenm wrote:

```suggestion
static cpp::Atomic<uint32_t> indices[] = {
```

https://github.com/llvm/llvm-project/pull/149751


More information about the libc-commits mailing list