This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] change default malloc thresholds of PPC64
- From: Steve Munroe <sjmunroe at us dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com, Dwayne McConnell <dgm69 at us dot ibm dot com>
- Date: Tue, 22 Mar 2005 17:08:03 -0600
- Subject: [PATCH] change default malloc thresholds of PPC64
- Organization: IBM LTC
- Reply-to: sjmunroe at vnet dot ibm dot com
The current DEFAULT_TRIM_THRESHOLD and DEFAULT_MMAP_THRESHOLD setting of
128K are too small for most applications targeting powerpc64.
Applications that need the 64-bit address space also tend to allocate
large arrays and data structions. If these are dynamic (via new or
malloc) the use of mmap vs brk storage can have significant performance
impact. This especially true for threaded applications where the
sequenctial allocation and zeroing of mmap pages for a large allocation
will bottleneck in the kernel.
In my case a threaded malloc test case (which randomizes the malloc size
over an interval and touches every page thus allocated) shows
significant (45%) performance degradation as the occational (<5%)
allocation approaches the threshold. And becomes 20+ times worse as the
average allocation exceeds the threshold.
So for these applications it is better for malloc to keep most
allocations in brk storage where the page zero overhead only ocurrs
once. But we need to increate the DEFAULT_TRIM_THRESHOLD and
DEFAULT_MMAP_THRESHOLD to do this.
The attached paches (for nptl and linuxthreads) use
powerpc64/malloc-machine.h to overide generic DEFAULT_TRIM_THRESHOLD and
DEFAULT_MMAP_THRESHOLD setting of 128KB to a more appropriate 16MB.
2005-03-22 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h: New file
diff -urN libc24-cvstip-20050310/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h libc24/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h
--- libc24-cvstip-20050310/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h Wed Dec 31 18:00:00 1969
+++ libc24/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h Tue Mar 22 10:18:53 2005
@@ -0,0 +1,37 @@
+/* Powerpc64 macro definitions for mutexes,
+ thread-specific data and parameters for malloc.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _PPC64_MALLOC_MACHINE_H
+#define _PPC64_MALLOC_MACHINE_H
+
+/* adjust MMAP and TRIM thresholds to be more appropriate for
+ applications that need a 64-bit address space. */
+
+#ifndef DEFAULT_TRIM_THRESHOLD
+#define DEFAULT_TRIM_THRESHOLD (16 * 1024 * 1024)
+#endif
+
+#ifndef DEFAULT_MMAP_THRESHOLD
+#define DEFAULT_MMAP_THRESHOLD (16 * 1024 * 1024)
+#endif
+
+#include_next <malloc-machine.h>
+
+#endif /* !defined(_PPC64_MALLOC_MACHINE_H) */
2005-03-22 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h: New file
diff -urN libc24-cvstip-20050310/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h libc24/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h
--- libc24-cvstip-20050310/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h Wed Dec 31 18:00:00 1969
+++ libc24/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/malloc-machine.h Tue Mar 22 12:52:05 2005
@@ -0,0 +1,37 @@
+/* Powerpc64 macro definitions for mutexes,
+ thread-specific data and parameters for malloc.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _PPC64_MALLOC_MACHINE_H
+#define _PPC64_MALLOC_MACHINE_H
+
+/* adjust MMAP and TRIM thresholds to be more appropriate for
+ applications that need a 64-bit address space. */
+
+#ifndef DEFAULT_TRIM_THRESHOLD
+#define DEFAULT_TRIM_THRESHOLD (16 * 1024 * 1024)
+#endif
+
+#ifndef DEFAULT_MMAP_THRESHOLD
+#define DEFAULT_MMAP_THRESHOLD (16 * 1024 * 1024)
+#endif
+
+#include_next <malloc-machine.h>
+
+#endif /* !defined(_PPC64_MALLOC_MACHINE_H) */