From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31108 invoked by alias); 24 Jul 2014 11:04:57 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 31079 invoked by uid 48); 24 Jul 2014 11:04:54 -0000 From: "jtaylor.debian at googlemail dot com" To: glibc-bugs@sourceware.org Subject: [Bug malloc/17195] New: excessive heap trimming in threaded programs Date: Thu, 24 Jul 2014 11:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: malloc X-Bugzilla-Version: 2.19 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jtaylor.debian at googlemail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00668.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=17195 Bug ID: 17195 Summary: excessive heap trimming in threaded programs Product: glibc Version: 2.19 Status: NEW Severity: normal Priority: P2 Component: malloc Assignee: unassigned at sourceware dot org Reporter: jtaylor.debian at googlemail dot com using glibc 2.19 from ubuntu 14.04 amd64 the following simple program causes a huge amount of page faults due to the heap being trimmed on every second free() even though heap trimming was disabled and the mmap threshold is set to the maximum: #include #include #include #include int main(int argc, const char *argv[]) { mallopt (M_TRIM_THRESHOLD, -1); mallopt (M_MMAP_THRESHOLD, 1024*1024*32); #pragma omp parallel for num_threads(2) for (size_t i = 0; i < 1000; i++) { size_t n = 1024*1024*16; double * m = malloc(n); memset(m, 1, n); free(m); } return 0; } gcc test.c -std=c99 -g -O2 -fopenmp perf stat -e page-faults ./a.out 2,036,312 page-faults strace -f -e madvise ./a.out 2>&1 | grep MADV_DONTNEED | wc -l 500 when setting the number of threads to 1 it reuses the memory as expected: perf stat -e page-faults ./a.out 4,271 page-faults -- You are receiving this mail because: You are on the CC list for the bug.