-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8299915: Remove ArrayAllocatorMallocLimit and associated code #11931
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
Signed-off-by: Justin King <jcking@google.com>
Signed-off-by: Justin King <jcking@google.com>
👋 Welcome back jcking! A progress list of the required criteria for merging this PR into |
Webrevs
|
Signed-off-by: Justin King <jcking@google.com>
Signed-off-by: Justin King <jcking@google.com>
Signed-off-by: Justin King <jcking@google.com>
I'm happy to see this flag getting removed. I'm less happy about seeing usages of the array allocators being replaced by macros. I'd rather see an effort towards getting rid of these macros. Could we limit this patch to only remove the ArrayAllocatorMallocLimit flag and ArrayAllocator class, and defer the discussion around what API to use for array allocations? |
As far as APIs, the majority of the codebase uses the macros. IMO consistency would be better and having two ways of doing things doesn't help. But if you feel strongly about it, we can punt and just surgically remove the bare minimum, assuming you clarify your expectation (see above). |
Curious, I always thought we do ArrayAllocator - using mmap for larger allocations - to prevent memory retention for libc variants whose allocators are "grabby", i.e. which don't promptly return memory to the OS on free(). E.g. because they only use sbrk (Solaris, AIX), or are just cautious about returning memory (glibc). Glibc's retention problem is only relevant for fine-grained allocations, so for glibc this is probably fine. This leaves at least AIX as a potential problem. @backwaterred, does the AIX libc malloc() still exclusively use the data segment ? Does free'd memory still stick to the process? (While writing this, I remember that we at SAP even rewrote Arena allocation to use mmap for AIX, because large compile arenas caused lasting RSS increase, so it has definitely been a problem in the past) |
Yes, that was what I wanted.
I agree about the argument about consistency, so I retract my objection. We can deal with these macros as a separate RFE (if we ever get to it). I would like to retain the usage of mmapped memory for ZGC to minimize the risk of any surprises for us. ZGC code also tend to initialize as much as possible in the initialization list, so the extra memset that comes after initialization lists sticks out a bit. Could you create a private
Or if you like, I can provide a patch on top of your branch to do that. |
Signed-off-by: Justin King <jcking@google.com>
The extra memset is due to Done. Restored mmap as suggested for zGranuleMap. |
Correct, glibc always mmap's allocations above a certain limit and always unmaps them on free. I believe most implementations do that, either immediately unmapping or using madvise. AIX still uses sbrk, based on their documentation that I could find. Though AIX does have something called malloc disclaim. |
Signed-off-by: Justin King <jcking@google.com>
To follow up on @tstuefe comment - and the one that I tried to say in the bug was that we added this MmapArrayAllocate feature for some G1 marking bits that used so much memory that hit the Solaris _sbrk issue. Maybe @stefank and @tschatzl remember this issue. Maybe it's ok for AIX, then removing this code is a good change. Maybe the G1 usages need a mmap implementation though. |
Signed-off-by: Justin King <jcking@google.com>
The padding.inline.hpp usage seems to have one caller which is called once. The other mmap usage in G1 we can convert to mmap using a similar approach to zGranuleMap if that is preferred. That would then be equivalent behavior, it looks like the G1 code uses the page allocation granularity anyway so maybe keeping it mmap is the better way to go here anyway? |
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.
Thanks for the ZGC update. I have a request to slightly modify the style a bit. Would you mind taking this patch:
https://github.com/stefank/jdk/tree/pr_11931
There's a FIXME about that allocation.inline.hpp file is now empty. Will you remove it in this patch? I'd prefer if you did. Alternatively, remove the FIXME from this patch and then immediately clean this up as a separate patch.
My uninformed opinion (I'm not the G1 code owner) is that it would be fine to use explicit mmap. I'd love the complexity reduction this patch brings. |
Signed-off-by: Justin King <jcking@google.com>
/contributor add @stefank |
Applied your patch @stefank |
@jcking |
Signed-off-by: Justin King <jcking@google.com>
Signed-off-by: Justin King <jcking@google.com>
Restored |
Signed-off-by: Justin King <jcking@google.com>
Yeah, separate patch immediately after is probably best. Trying to avoid having to mass update includes and enter merge conflict hell for this patch. After is easier. |
I agree with @coleenp that AIX seems to still use the data segment and sbrk for dynamic memory allocation according to the documentation. [Edit: With these changes I see several of the gtests failing on AIX.
I can experiment with the disclaim option as well. [1] https://www.ibm.com/docs/en/aix/7.2?topic=concepts-system-memory-allocation-using-malloc-subsystem |
@jcking this pull request can not be integrated into git checkout remove-array-allocator
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
@jcking 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! |
@jcking 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 |
@tstuefe @backwaterred I'd like to see this RFE revived. Do we know if anyone is using the It seems unlikely to me, as you'd need to explicitly specify And, if this option had been useful (for the AIX port, for example), it would have been changed to a non-experimental (with proper |
|
||
template <typename T> | ||
size_t ZGranuleMap<T>::size_for_array(size_t count) { | ||
return align_up(count * sizeof(T), os::vm_allocation_granularity()); |
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.
assert ag. overflow?
|
||
void* const addr = os::reserve_memory(size, !ExecMem, mtGC); | ||
if (addr == nullptr) { | ||
return nullptr; |
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.
reserve fails, we return null, commit fails, we exit? Why the inconsistency?
@@ -126,6 +123,33 @@ bool G1CMMarkStack::resize(size_t new_capacity) { | |||
return true; | |||
} | |||
|
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.
Here, and in ZGC: we are cool with small allocations being rounded up to page size now?
} | ||
|
||
size_t G1CMMarkStack::size_for_array(size_t count) { | ||
return align_up(count * sizeof(TaskQueueEntryChunk), os::vm_allocation_granularity()); |
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.
assert against overflow
// Clear the allocated memory. | ||
memset(chunk, '\0', total_size); | ||
|
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.
Old code, when doing the malloc path, did not initialize. Why here?
@@ -35,7 +35,7 @@ | |||
import jdk.test.lib.Platform; | |||
|
|||
public class SizeTTest { | |||
private static final String FLAG_NAME = "ArrayAllocatorMallocLimit"; | |||
private static final String FLAG_NAME = "StringDeduplicationCleanupDeadMinimum"; |
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.
Small comment here that the flag itself, does not matter, just the fact that it is of type size_t?
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.
Cursory review
@iklam I'm fine with removing the ArrayAllocator. |
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.
Could we create a simpler version of this PR? One that only removes ArrayAllocator and ArrayAllocatorMallocLimit, but keeps MallocArrayAllocator and MmapArrayAllocator? That way we can figure out later, in a separate RFE, if we want to remove MmapArrayAllocator.
Remove abstraction that is a holdover from Solaris. Direct usages of
MmapArrayAllocator
have been switched to normalmalloc
. The justification is that none of the code paths are called from signal handlers, so usingmmap
directly does not make sense and is potentially slower than going throughmalloc
which can potentially re-use memory without making any system calls. The remaining usages ofArrayAllocator
andMallocArrayAllocator
are equivalent.Progress
Issue
Contributors
<stefank@openjdk.org>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/11931/head:pull/11931
$ git checkout pull/11931
Update a local copy of the PR:
$ git checkout pull/11931
$ git pull https://git.openjdk.org/jdk.git pull/11931/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11931
View PR using the GUI difftool:
$ git pr show -t 11931
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11931.diff
Webrev
Link to Webrev Comment