[PATCH 0/9] malloc: Remove fastbins
Dev Jain
dev.jain@arm.com
Fri Oct 17 09:06:58 GMT 2025
The small tcache data structure is similar to the fastbin layer - we have
size classes in which we store same size chunks. After the tcache was
introduced in malloc, the tcache precedes the fastbin when we try to
find a victim to allocate. Similarly, the tcache precedes the fastbin
when we free a chunk, in that we first try to push the chunk into the
tcache and only on failure do we try the fastbins. It is, therefore,
easy to observe that post the introduction of the tcache, the fastbin
layer has become redundant because it serves exactly the same functionality
as the tcache, with the extra overhead of arena locks. Therefore, it makes
sense to completely remove this allocation layer.
We leave do_set_mxfast for back-compat, and just unconditionally return 1.
Upon just disabling fastbins, we get a very minor regression (~0.5%).
Upon setting the default TCACHE_FILL_COUNT to 16, we get almost the
same performance. Thus, experimental data also proves that removing
the fastbin layer is a good move. We have the additional benefit of also
making the code less complex.
I have broken down this removal into patches to make life easier
(for me and the reviewers :) )
Tested on Aarch64. All patches build sequentially. All malloc tests pass
on each patch.
Dev Jain (9):
malloc: remove fastbin tests
malloc: remove malloc_consolidate
malloc: remove allocation from fastbin, and trim_fastbins
malloc: remove mallopt fastbin stats
malloc: remove fastbin code from do_check_malloc_state
malloc: remove fastbin code from malloc_info
malloc: Remove fastbin infrastructure
malloc: remove fastbin comments
malloc: set default tcache fill count to 16
benchtests/bench-malloc-simple.c | 2 +-
malloc/Makefile | 6 -
malloc/malloc.c | 617 ++-----------------------------
malloc/malloc.h | 4 -
malloc/tst-mallinfo2.c | 2 -
malloc/tst-mxfast.c | 57 ---
malloc/tst-safe-linking.c | 135 -------
7 files changed, 31 insertions(+), 792 deletions(-)
delete mode 100644 malloc/tst-mxfast.c
--
2.43.0
More information about the Libc-alpha
mailing list