mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 19:00:07 +00:00
malloc: Consistently apply trim_threshold to all heaps (Bug 17195)
In the per-thread arenas we apply trim_threshold-based checks to the extra space between the pad and the top_area. This isn't quite accurate and instead we should be harmonizing with the way in which trim_treshold is applied everywhere else like sysrtim and _int_free. The trimming check should be based on the size of the top chunk and only the size of the top chunk. The following patch harmonizes the trimming and make it consistent for the main arena and thread arenas. In the old code a large padding request might have meant that trimming was not triggered. Now trimming is considered first based on the chunk, then the pad is subtracted, and the remainder trimmed. This is how all the other trimmings operate. I didn't measure the performance difference of this change because it corrects what I consider to be a behavioural anomaly. We'll need some profile driven optimization to make this code better, and even there Ondrej and others have better ideas on how to speedup malloc. Tested on x86_64 with no regressions. Already reviewed by Siddhesh Poyarekar and Mel Gorman here and discussed here: https://sourceware.org/ml/libc-alpha/2015-05/msg00002.html
This commit is contained in:
parent
58a3a98d8f
commit
e4bc326dbb
@ -1,3 +1,9 @@
|
|||||||
|
2015-10-07 Carlos O'Donell <carlos@redhat.com>
|
||||||
|
|
||||||
|
[BZ #17195]
|
||||||
|
* malloc/arena.c (heap_trim): Apply trim_treshold to top_chunck size,
|
||||||
|
as is similarly done in systrim and _int_free already.
|
||||||
|
|
||||||
2015-10-08 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
2015-10-08 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||||
|
|
||||||
* sysdeps/mach/configure.ac (mach_interface_list): Add task_notify.
|
* sysdeps/mach/configure.ac (mach_interface_list): Add task_notify.
|
||||||
|
@ -696,14 +696,20 @@ heap_trim (heap_info *heap, size_t pad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Uses similar logic for per-thread arenas as the main arena with systrim
|
/* Uses similar logic for per-thread arenas as the main arena with systrim
|
||||||
by preserving the top pad and at least a page. */
|
and _int_free by preserving the top pad and rounding down to the nearest
|
||||||
|
page. */
|
||||||
top_size = chunksize (top_chunk);
|
top_size = chunksize (top_chunk);
|
||||||
|
if ((unsigned long)(top_size) <
|
||||||
|
(unsigned long)(mp_.trim_threshold))
|
||||||
|
return 0;
|
||||||
|
|
||||||
top_area = top_size - MINSIZE - 1;
|
top_area = top_size - MINSIZE - 1;
|
||||||
if (top_area < 0 || (size_t) top_area <= pad)
|
if (top_area < 0 || (size_t) top_area <= pad)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Release in pagesize units and round down to the nearest page. */
|
||||||
extra = ALIGN_DOWN(top_area - pad, pagesz);
|
extra = ALIGN_DOWN(top_area - pad, pagesz);
|
||||||
if ((unsigned long) extra < mp_.trim_threshold)
|
if (extra == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Try to shrink. */
|
/* Try to shrink. */
|
||||||
|
Loading…
Reference in New Issue
Block a user