-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Add and use over-allocation metric to decide when to defragment #1000
Conversation
Another approach might be to keep a separate table of allocations, and map chunks to allocations. That should allow us to track memory overhead precisely by comparing buffered data to net allocation size, but is substantially more complex, so I'm not sure it'd be worthwhile. |
be0b110
to
3bbe101
Compare
Rebased my changes on current main. |
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.
This implementation looks solid to me! Some minor issues below:
@Matthias247 would you have a chance to review the current iteration of these changes? (Otherwise we'll probably just merge them; we can always improve on them later, of course.) |
Will definitely take a look. However it's a bit of a busy week at the moment, so it might be start of next week. |
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.
The buffered/allocated strategy in the chunks, and taking the defragment decision based on it seem good to me.
However I think defragment migh have a bug and some wrong assumptions (size >= allocation_size
) which don't make it as efficient as it could be.
While efficiency can further be improved in follow-ups, the data ordering bug should be checked and fixed.
da6e5e8
to
fee1e5f
Compare
One more general realization I had: The old mechanism covered the case where a client sent lots of overlapping ranges, and thereby caused excessive memory usage despite having a limited receive buffer. This change as it is won't do that anymore, since all chunks could still have good utilization. Nevertheless I think the current approach is good too. Maybe deduplication should happen on |
Hmm, that definitely seems like an issue. I think we should still cover that scenario. |
I added two new commits. The first fixes #1009 by adding a There is still one flaw that might be abused by a malicious peer: After calling |
@geieredgar please take the opportunity to basically add comments for all of Matthias' questions. Would be good to get the documentation in there since this is obviously a tricky topic and it would be nice to make the explanations easier to access if we ever need to iterate more on this. Plus, it will help make my review easier. |
1353940
to
01ceb65
Compare
@djc Some of Matthias' questions became obsolete after my latest refactor, for the others I added comments. |
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 hard work of doing all the changes! This looks a lot simpler now. I just pointed out some style nits and added some questions, but I'm fine with merging as is.
15455dd
to
caf5856
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.
Looks great to me now!
Thanks for all the changes
c00ed23
to
71af9f7
Compare
f59b23c
to
c93eaf4
Compare
Alright, thanks for seeing this through! |
Previous discussion: #996