From: Liudongyun <liu.dongyun@h3c.com>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Cc: "libc-locales@sourceware.org" <libc-locales@sourceware.org>,
"libc-maintainers@gnu.org" <libc-maintainers@gnu.org>,
Denghongjie <deng.hongjie@h3c.com>,
Daixianjun <dai.xianjun@h3c.com>
Subject: 答复: [PATCH] release all idle heaps in the non-main-arena
Date: Fri, 18 Jun 2021 08:02:40 +0000 [thread overview]
Message-ID: <770da5e93dd14f1eb0a2ddaf85b27378@h3c.com> (raw)
In-Reply-To: <06d6723d-3209-c957-b855-8cc9b0bdbbe4@gotplt.org>
> Does that cause any actual performance degradation or any other issues though? heap_shrink() calls madvise (MADV_DONTNEED) on the free parts of the heap to tell the kernel that the blocks are not needed, so a fully freed heap ought to not have any performance impact. The RSS footprint will depend on when the kernel
> reclaims those pages, which may not be immediate since madvise is just a hint.
> Alternatively, if you disable memory overcommit by setting /proc/sys/vm/overcommit_memory to 2, heap_shrink() will drop all permissions on the heap with mprotect(PROT_NONE) instead of doing madvise. This has a more immediate effect on RSS usage unlike madvise.
We released the heap, these virtual memory will be reused in new_heap function. No potential problems have been found yet. The practice in PATCH will definitely lead to an increase in system calls. Since glibc is used in many scenarios, the patch we submitted did not modify the size of the heap to be cautious.
Compared with the current mechanism in GLIBC,the probability of a large amount of physical memory resident is very high, just holding any piece of memory in TOP TUNK will cause all the memory before TOP TUNK to reside. I think it is worth it.
These days, we coordinate with colleagues to test the performance of the patch.Our amendment is as follows.
1. Set the size of heap to 512KB (the submitted patch is 64M by default);
2. Release the unused heap (consistent with the submitted patch)
In the same test environment(Intel(R) Xeon(R) CPU @ 2.00GHz, 12 processors, 32G RAM), we try to simulate using the maximum specification of business data.
There is little performance degradation. The test results are as follows.
Package(Bytes) Not patched Patched
128 24.88Mpps 24.10Mpps
256 24.60Mpps 24.18Mpps
512 15.51Mpps 15.51Mpps
1024 7.14Mpps 7.48Mpps
1280 5.52Mpps 5.52Mpps
1400 4.89Mpps 4.89Mpps
1518 4.51Mpps 4.51Mpps
Thank you very much for your advice.
1, I have thought about this method before, but I gave up due to it's just a hint.
2, As the problem has been solved, I can't coordinate to the classmate test again for your suggestion. I'll test it myself.
-----邮件原件-----
发件人: Siddhesh Poyarekar [mailto:siddhesh@gotplt.org]
发送时间: 2021年6月11日 14:42
收件人: liudongyun (RD) <liu.dongyun@h3c.com>; libc-alpha@sourceware.org
抄送: libc-locales@sourceware.org; libc-maintainers@gnu.org; denghongjie (RD) <deng.hongjie@h3c.com>; daixianjun (RD) <dai.xianjun@h3c.com>
主题: Re: [PATCH] release all idle heaps in the non-main-arena
On 6/11/21 9:38 AM, liudongyun wrote:
> liu.dongyun@h3c.com report this question in follow:
> The system has a total of 32G memory and 12 core cpu.
> After frequent malloc and free memory by multiple threads, we found
> that many physical memory that should have been released have not been
> released.We observe that the maximum free memory can reach 15G.
>
> deng.hongjie@h3c.com recommend reducing the heap size of the
> non-main-arena, but it doesn't work. liu.dongyun@h3c.com found When
> the last heap in the user process into the non-main-area has memory in
> use, the previous heap will not be released, even if the previous heap is already free. This mechanism resulting in the memory cache reaching 15G.
Does that cause any actual performance degradation or any other issues though? heap_shrink() calls madvise (MADV_DONTNEED) on the free parts of the heap to tell the kernel that the blocks are not needed, so a fully freed heap ought to not have any performance impact. The RSS footprint will depend on when the kernel reclaims those pages, which may not be immediate since madvise is just a hint.
Alternatively, if you disable memory overcommit by setting /proc/sys/vm/overcommit_memory to 2, heap_shrink() will drop all permissions on the heap with mprotect(PROT_NONE) instead of doing madvise. This has a more immediate effect on RSS usage unlike madvise.
Siddhesh
prev parent reply other threads:[~2021-06-18 8:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-11 4:08 liudongyun
2021-06-11 6:41 ` Siddhesh Poyarekar
2021-06-18 8:02 ` Liudongyun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=770da5e93dd14f1eb0a2ddaf85b27378@h3c.com \
--to=liu.dongyun@h3c.com \
--cc=dai.xianjun@h3c.com \
--cc=deng.hongjie@h3c.com \
--cc=libc-alpha@sourceware.org \
--cc=libc-locales@sourceware.org \
--cc=libc-maintainers@gnu.org \
--cc=siddhesh@gotplt.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).