[PATCH v4] benchtest: malloc tcache hotpath benchtest.
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Mon May 12 10:09:16 GMT 2025
Hi Cupertino,
> I noticed that there was an unexpected performance loss when alloc_size
> was 1024.
> While exploring I notice that for alloc_size 1016 I get:
> "time_per_iteration": 14.3453
> and for 1017:
> "time_per_iteration": 16.3697.
> Could this be related to CPU cache effects? No idea!
Quite likely, especially since you're still measuring latency. You might get bank
conflicts depending on the addresses used, and that can increase latency.
+++ b/benchtests/Makefile
@@ -329,8 +329,10 @@ ifeq (${BENCHSET},)
bench-malloc := \
calloc-simple \
calloc-thread \
+ calloc-tcache \
Not in alphabetic order, so it fails tests...
+/* Allocate and free blocks in a random order. */
+static size_t
+malloc_benchmark_loop (void *elem)
+{
+ size_t iters = 0;
+ while (!timeout)
+ {
+ elem = TEST_FUNC (alloc_size);
+ free (elem);
+ iters++;
+ }
This still measures latency rather than throughput.
+ /* Preload tcache not to measure non tcache allocation time. */
+ elem = TEST_FUNC (alloc_size);
+ free (elem);
I don't believe this makes any difference on the timescales we're using.
+ TIMING_NOW (start);
+ *iters = malloc_benchmark_loop (elem);
+ TIMING_NOW (stop);
This gives a use after free compilation error...
Cheers,
Wilco
More information about the Libc-alpha
mailing list