Garbage collect on allocation exceeding max memory pool size #9846
+7
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Garbage collection is currently done on the allocation slow path after the max eden size was already exceeded by a previous allocation. For example, if new TLAB allocationA causes the max size to be exceeded, the pool max size will remain exceeded until new TLAB allocationB happens. It would be better to do GC when the allocation that actually causes the threshold to be exceeded happens.
This is because, on the slow path,
maybeCollectOnAllocation
is called too early.maybeCollectOnAllocation
callsshouldCollectOnAllocation
which checks whether the eden size threshold is exceeded.The problem is that
maybeCollectOnAllocation
is called beforeincreaseEdenUsedBytes
is called, soshouldCollectOnAllocation
doesn't take into account the size of the current allocation. Is there a reason for this, or is this a bug?I've just made a small change so that
shouldCollectOnAllocation
takes into account the size of the current allocation that is requiring a new TLAB (and potentially causing the memory pool max to be exceeded).See #6930 for more context.