[all] Include PubSubMessageHeaders size in ImmutablePubSubMessage heap size estimation #2287
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.
Problem Statement
We estimate the size of pubsubmessage and based on it to compute the aggregate size of drainer buffer queue. A limit is set on the queue to control its occupied heapsize. In a recent OOM heap dump analysis, we found that this estimation can inaccurate e.g. buffer size is about 400MB, whereas the limit setting is only 10MB, and the reason is that we use the sum of key, value, and pubSubPosition to estimate an ImmutablePubSubMessage size. However, when examining the dump, in this particular case, the major contributor was PubSubMessageHeaders which was about 16KB and we don't take it into account today.
Solution
This PR includes the header size inside getHeapSize estimation for ImmutablePubSubMessage.
Code changes
Concurrency-Specific Checks
Both reviewer and PR author to verify
synchronized,RWLock) are used where needed.ConcurrentHashMap,CopyOnWriteArrayList).How was this PR tested?
Does this PR introduce any user-facing or breaking changes?