Malloc improvements

Message ID 20160714104116.23d8d4eb@kryten
State Committed
Headers

Commit Message

Anton Blanchard July 14, 2016, 12:41 a.m. UTC
  Hi DJ,

> Fixed and pushed.  Thanks!
> 
> Time for 1B iterations:
> 
>  8.51s  dj/malloc
> 15.56s  glibc
>  9.58s  tcmalloc
> 12.09s  jemalloc

Fantastic! I verified the fix on POWER8:

baseline    473%
jemalloc    149%
dj/malloc   106%
tcmalloc    100%

I noticed a 32bit sign extension issue when using the updated trace
facility:

71128 ftruncate(3, 2080374784)          = 0
...
71128 ftruncate(3, 18446744071562067968) = -1 EINVAL (Invalid argument)

One way of fixing this is below.

Anton

--
  

Patch

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 70e7dc8..3b4781c 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1163,7 +1163,7 @@  __mtb_trace_entry (uint32_t type, size_t size, void *ptr1)
   my_num = TRACE_COUNT_TO_MAPPING_NUM (my_trace_count);
   if (my_num != __malloc_trace_last_num)
     {
-      int new_window;
+      long new_window;
       int new_ref_count;
 
       /* START W: Switch window.  */