DragonFly-126.96.36.1990.g8ff09 master lib/libc/stdlib nmalloc.c
dillon at crater.dragonflybsd.org
Wed Apr 29 20:18:23 PDT 2009
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Wed Apr 29 20:07:07 2009 -0700
nmalloc - Further optimize posix_memalign()
Align the requested size to the nearest alignment to improve our chances
of coming up with a power-of-2.
Greatly improve the fitting algorithm for oddly sized requests, e.g.
(1) 32 byte alignment on a 1026 size. In this case the zone for 1026
already has a chunking (128) that exceeds the requested alignment,
so we just do a _slaballoc().
(2) A 256 byte alignment on a 513 byte size. In this case the zone
for 513 has a chunking of 64, which is not sufficient, so we
find the nearest power-of-2 >= 513 and allocate that. In our
case we would find 1024. Since _slaballoc() guarantees that
power-of-2 allocations within the zone limit will be on the
same-sized boundary, we then just allocate the nearest power of 2.
Summary of changes:
lib/libc/stdlib/nmalloc.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 4 deletions(-)
DragonFly BSD source repository
More information about the Commits