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.
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
src: track memory retainer fields #26161
src: track memory retainer fields #26161
Changes from all commits
17b4949
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I am not sure what this is trying to achieve, is there a use case of this API?
Normally the size of the pointer to the retainer should be accounted into the self size of the parent but self size of the retainer should not be accounted, so I can't tell when it's necessary to do a subtraction - maybe there is a misuse of the API?
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.
If this is trying to address the issues that came up from #26099 there are two ways to solve that:
SET_SELF_SIZE(Worker)
, which is merely a convenience macro that implementsWorker::SelfSize()
withsizeof(Worker)
to calculate the self size of the worker - that's where we encounter the first tracking of the inline field. Instead, overrideWorker::SelfSize()
to exclude the size of the non-pointer fields, and track them later inWorker::MemoryInfo()
.SET_SELF_SIZE(Worker)
for the initial calculation, but rename this method into something likeSplitNonPointerField()
(SplitStackAllocatedField()
?), because this does not necessarily add more memory into the tracker - instead it's splitting off existing memory that have already been tracked, and potentially adding more (if theretainer
overridesMemoryInfo()
to add additional fields that are not accounted by asizeof()
)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.
@joyeecheung - thanks.
Probably these many scenarios exists (with a component
cmp
and a containercnt
withcnt
a retainer):cmp
is a normal primitive field: self size ofcnt
covers size ofcmp
cmp
is a composite object (with or without primitive fields): self size ofcnt
covers size ofcmp
cmp
is a pointer to a composite object: self size ofcnt
covers size ofcmp
(size of a pointer)cmp
is a composite object (with pointer type fields): self size ofcnt
covers size ofcmp
, not the dynamic memory [ example: messageport in worker ]cmp
is a composite retainer object (with pointer types): [ current use case ]cmp
is a pointer to a retainer object (with pointer types): [ none at the moment? ]We have
Worker
with 200 bytes excluding 2 inlineAsyncRequest
fields of 72 bytes each. So the question is: should we add those to the worker (because those belongs to worker) or add separately - as they are retainers themselves.If I follow your approach 1, we need to perform that in all such scenarios? in which case arguably the parent retainer (Worker's referencing object if any) could do the same for worker, and potentially render the Retainer abstraction meaningless?
second proposal looks fair to me, but would love to hear from @addaleax as well. Can
SplitStackAllocatedField
be somewhat misleading, as there is no memory that is stack-allocated here?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.
I’m not sure, but I don’t really see this as a issue/as not “tracking” these fields? Then again, re-naming is not a big deal, so I’m okay with anything.
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.
That depends on whether we want to display AsyncRequest separately as a Node referenced by the Worker node, and any other fields referenced by those AsyncRequests recursively.
The abstraction helps adding nodes recursively instead of tracking everything from the root, allowing the MemoryRetainer implementations define how they want their fields to be tracked.
Right, the fields are not really stack allocated if the whole thing is not stack allocated.
I am fine with the current naming if the comments are changed to reflect when this method should be used and what issue it is trying to address.
Use when a retainer is embedded in another.
andReduce the size of memory from the container so that retentions are accounted properly.
is too ambiguous IMO, the core of the issue this method is trying to solve arise from that the parent does not implement itsSelfSize()
correctly to exclude the memory that is supposed to be tracked as the self size of another node.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.
@joyeecheung - thanks, I will amend the comments, aligning with above conversation.
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.
@joyeecheung - amended the comment, ptal!