Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* malloc/malloc.c: Use all small bin slots on 64-bit archs.
	* malloc/malloc.c (largebin_index): Really have 32 buckets with 64
	sizes.
  • Loading branch information
Ulrich Drepper committed May 15, 2007
1 parent 1a31b58 commit 1d47e92
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
@@ -1,6 +1,9 @@
2007-05-14 Ulrich Drepper <drepper@redhat.com>

* malloc/malloc.c (largebin_index): Really have 32 buckets with 64 sizes.
* malloc/malloc.c: Use all small bin slots on 64-bit archs.

* malloc/malloc.c (largebin_index): Really have 32 buckets with 64
sizes.

2007-05-13 Ulrich Drepper <drepper@redhat.com>
* malloc/malloc.c [MALLOC_DEBUG]: Keep track of current maximum
Expand Down
23 changes: 19 additions & 4 deletions malloc/malloc.c
Expand Up @@ -2125,22 +2125,37 @@ typedef struct malloc_chunk* mbinptr;

#define NBINS 128
#define NSMALLBINS 64
#define SMALLBIN_WIDTH 8
#define MIN_LARGE_SIZE 512
#define SMALLBIN_WIDTH MALLOC_ALIGNMENT
#define MIN_LARGE_SIZE (NSMALLBINS * SMALLBIN_WIDTH)

#define in_smallbin_range(sz) \
((unsigned long)(sz) < (unsigned long)MIN_LARGE_SIZE)

#define smallbin_index(sz) (((unsigned)(sz)) >> 3)
#define smallbin_index(sz) \
(SMALLBIN_WIDTH == 16 ? (((unsigned)(sz)) >> 4) : (((unsigned)(sz)) >> 3))

#define largebin_index(sz) \
#define largebin_index_32(sz) \
(((((unsigned long)(sz)) >> 6) <= 38)? 56 + (((unsigned long)(sz)) >> 6): \
((((unsigned long)(sz)) >> 9) <= 20)? 91 + (((unsigned long)(sz)) >> 9): \
((((unsigned long)(sz)) >> 12) <= 10)? 110 + (((unsigned long)(sz)) >> 12): \
((((unsigned long)(sz)) >> 15) <= 4)? 119 + (((unsigned long)(sz)) >> 15): \
((((unsigned long)(sz)) >> 18) <= 2)? 124 + (((unsigned long)(sz)) >> 18): \
126)

// XXX It remains to be seen whether it is good to keep the widths of
// XXX the buckets the same or whether it should be scaled by a factor
// XXX of two as well.
#define largebin_index_64(sz) \
(((((unsigned long)(sz)) >> 6) <= 48)? 48 + (((unsigned long)(sz)) >> 6): \
((((unsigned long)(sz)) >> 9) <= 20)? 91 + (((unsigned long)(sz)) >> 9): \
((((unsigned long)(sz)) >> 12) <= 10)? 110 + (((unsigned long)(sz)) >> 12): \
((((unsigned long)(sz)) >> 15) <= 4)? 119 + (((unsigned long)(sz)) >> 15): \
((((unsigned long)(sz)) >> 18) <= 2)? 124 + (((unsigned long)(sz)) >> 18): \
126)

#define largebin_index(sz) \
(SIZE_SZ == 8 ? largebin_index_64 (sz) : largebin_index_32 (sz))

#define bin_index(sz) \
((in_smallbin_range(sz)) ? smallbin_index(sz) : largebin_index(sz))

Expand Down

0 comments on commit 1d47e92

Please sign in to comment.