-
Notifications
You must be signed in to change notification settings - Fork 223
8292989: Avoid dynamic memory in AsyncLogWriter #1630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
👋 Welcome back xliu! A progress list of the required criteria for merging this PR into |
This backport pull request has now been updated with issue from the original commit. |
Webrevs
|
@navyxliu This change is no longer ready for integration - check the PR body for details. |
windows-aarch64 build failure running adlc appears unrelated. |
Before I review the change, should https://bugs.openjdk.org/browse/JDK-8294075 be backported as well? Is JDK-8294075 caused by this change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked through the code, I have comments.
using AsyncLogMap = ResourceHashtable<LogFileStreamOutput*, uint32_t, primitive_hash<LogFileStreamOutput*>, | ||
primitive_equals<LogFileStreamOutput*>, 17, | ||
ResourceObj::C_HEAP, mtLogging>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arguments should be on the new lines each, I think? This would match the upstream code better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, @shipilev
Do we have linter rules for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even in tip of jdk, I still can find code like this:
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/classfile/classLoaderStats.hpp#L114
@@ -184,11 +184,20 @@ class ResourceHashtable : public ResourceObj { | |||
// the iteration is cancelled. | |||
template<class ITER> | |||
void iterate(ITER* iter) const { | |||
auto function = [&] (K& k, V& v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid doing this by making a named struct
implementing do_entry
for every use? I realize that would deviate the uses from the upstream, but we would not be changing the shared code, which would be safer for generic code that does not use any of async logging and uses older toolchains.
This hunk effectively backports https://bugs.openjdk.org/browse/JDK-8276789, which seems to imply the need to check this works well with different toolchains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I can rewrite lambdas using old-style functor.
to backport JDK-8276789, we also need to backport bucket_at(), table()/table_size() beforehand. I take your advice. my approach skips more verification and it's not good. I will use functor.
we found that it doesn't work. we still have intermittent failure. |
Is it necessary to downport this patch? On its own, it does not sound that important, especially if we downport the glibc autotrimmer. |
Hi, Thomas, Thanks you for the comments. I was told that it is better reducing memory footprint of UL in jdk17u, a LTS Java. May I learn more about glibc autotrim? Is it a glibc feature or a new feature of hotspot? I found JDK-8268893 on JBS. It itself is a very useful feature! It is not an automatic trimmer, is it? |
Hi Xin :)
Interesting, I'm curious about the effectiveness of your patch. Do you see good results? I would have thought that a lot of these interleaving memory requests are just taken from and handed back into fastbins or tcache, and therefore don't make the arena grow. Also, the glibc attempts to reclaim memory automatically are quite limited (see PR description openjdk/jdk#14781 (comment))
Its https://bugs.openjdk.org/browse/JDK-8293114. You have to manually enable it, it is still marked as experimental. Also not in 17 yet, but Aleksey is preparing things to get it down quickly once it has baked in head a bit. Essentially, what the trimmer does is run periodically a malloc_trim() operation. malloc_trim() will reclaim memory that has been free'd and that is in page granularity (so, it will also reclaim memory in the middle of an arena). Cheers, Thomas |
I think that autotrimmer is a mitigation strategy for oversubscription, rather than a fix. it also does not resolve fragmentation issues, if there are surviving mallocs between temporarly async logging mallocs. In other words, it is more compelling to avoid the issue instead of relying on auto-trimmer. We use a lot of |
hi, @tstuefe, I think we need both of them. This patch refrains from using any malloc/free in the first place. It also helps avoid the fragmentation issue. Autotrimmer is a general solution for glibc overprovision. Should we still consider to include this patch in jdk17u? |
I don't want to block this patch, so sure. I just would have liked to know what the strategy brings in terms of RSS. Plain curiousity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this looks good, but I think we should fix/backport these two before backporting this one to 17u:
https://bugs.openjdk.org/browse/JDK-8297302 (fixed, should be backported)
https://bugs.openjdk.org/browse/JDK-8309067 (not fixed, should be dealt with first)
okay. I will work on JDK-8309067 |
@navyxliu This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@navyxliu This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
This patch is NOT a clean backport. The logic part is exactly the same, but I have to adjust code in the following parts:
Testing:
jdk-test1 tests including gtest.
Manually check there's no malloc/free in runtime.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/1630/head:pull/1630
$ git checkout pull/1630
Update a local copy of the PR:
$ git checkout pull/1630
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/1630/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1630
View PR using the GUI difftool:
$ git pr show -t 1630
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/1630.diff
Webrev
Link to Webrev Comment