-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: track memory consumers for GreedyMemoryPoolState #9015
feat: track memory consumers for GreedyMemoryPoolState #9015
Conversation
This looks very cool! |
c39dc03
to
a68c353
Compare
a68c353
to
76ce658
Compare
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.
Thank you for this contribution @asimsedhain -- this is a great start. I am slightly worried it will cause a performance regression
I am running some benchmarks now and will report results here
let free = self.pool_size.saturating_sub(used); | ||
|
||
let mut allocations = state.pool_members.iter().collect::<Vec<_>>(); | ||
allocations.sort_by(|(_, a), (_, b)| a.cmp(b).reverse()); |
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.
💯
Benchmark results (I don't really see any noticeable change). Not sure why it looks like this branch is faster in some cases. I'll rerun to double check
|
I am also surprised this branch is faster. Thank you for the review! Will address the comments shortly. |
I reran the benchmarks and basically they showed similar results: performance differences that were likely mostly noise |
Marking as a draft so it is clear this PR is not waiting on reviews for now. I am trying to keep our review backlog down. Please mark this as ready for review when it is ready for another look |
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 @asimsedhain 🙏
@alamb a soft bump on this PR for another review. |
Thansk @asimsedhain -- sorry I was out last week. I will put this on my review queue for tomorrow |
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 @asimsedhain -- this looks great. My only concern is about using saturating_sub
rather than checked_sub
as it could potentially mask bugs, but otherwise I think this PR looks good to go.
Sorry again for the delay in review
|
||
assert_eq!( | ||
format!("{}", greedy_pool), | ||
"GreedyPool 2 allocations, 421 used, 579 free, 1000 capacity.\nConsumers:\n321: r2\n100: r1\n" |
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 consumer.can_spill { | ||
let mut state = self.state.lock(); | ||
state.num_spill = state.num_spill.checked_sub(1).unwrap(); | ||
state.num_spill = state.num_spill.saturating_sub(1); |
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 wonder if there is a reason to use saturating_sub
rather than checked_sub
?
True, I didn't consider that it could mask potential bugs. Replaced it with checked add. The CI failed. Will check on it in the morning. |
Thanks @asimsedhain |
I believe I found the reason why the CI is failing after adding the
On line 5 and 6, two consumers register themselves with the same name (these 2 aggregation happen here]. Seems like assuming each consumer to have a unique name is not correct. @alamb could you let me know if you have any suggestion on how to proceed forward? |
Hi @asimsedhain - I have this PR on my list to review, but I sadly have limited bandwidth this week |
No worries @alamb. Whenever you get the free time. |
CI is having trouble, let's sort that out first
Introduce an ID field to the memory consumer, track memory usage with consumer ID, and do ID -> Name conversion at the time of usage dump? |
I am sorry @asimsedhain -- I am struggling to find the contiguous time needed to review this PR as it makes changes that look potentially disruptive in a very important subsustem (the memory manager) I actually think it is a really important debugging feature (e.g. @westonpace was just asking me the other day about where the memory was going when a query hit the greedy pool's memory limit) |
Yes, I'll chime in a bit as I did end up finding the root issue. My plan had both Also, we have some customers that want to know, in great detail, why various operations need RAM and what the limits of that RAM will be. I think this could be just a start into greater RAM observability. |
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days. |
Converting to draft -- I am sorry this one never quite made it in. |
Note that the need for some tracking of memory consumers has been raised again. Not sure if we plan on reviving/reusing some of the work done already here by @asimsedhain as a first step. |
My concern with this PR was that I could not quite convince myself / find the time to ensure the complexity was necessary... I feel bad we didn't find time to get it over the line. Maybe we can revive it |
Which issue does this PR close?
Closes #6934
Rationale for this change
What changes are included in this PR?
Modified GreedyMemoryPool and FairMemoryPool to keep track of all it's consumer such that they can be dumped for debugging.
The output for the debug looks as follows:
Are these changes tested?
Are there any user-facing changes?