-
Notifications
You must be signed in to change notification settings - Fork 5
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] support alloc contiguous at given index, fix bug related with … #7
base: main
Are you sure you want to change the base?
Conversation
src/lib.rs
Outdated
size: usize, | ||
align_log2: usize, | ||
) -> Option<usize> { | ||
if check_contiguous(self, base, Self::CAP, size, align_log2) { |
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.
Maybe it can use check_contiguous(self, base, Self::CAP, size, align_log2).then
?
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.
holy shit, ur amazing
src/lib.rs
Outdated
|
||
fn dealloc_contiguous(&mut self, base: usize, size: usize) -> bool { | ||
let mut success = true; | ||
for key in base..base + size { |
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.
Is there any more efficient method to dealloc contiguous area? Like remove
in the alloc_contiguous
?
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.
yep, the final operation can be done through self.insert(range)
however, I think we need to traverse this range bit by bit to check if this range is allocated contiguously,
why not just use the dealloc
which is also completed bit-by-bit
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.
Because I think use dealloc
bit-by-bit needs to iterate from the upper layer to the lower layer for each bit, and this iterative process feels like a repetitive operation that will bring performance overhead
src/lib.rs
Outdated
size: usize, | ||
align_log2: usize, | ||
) -> Option<usize> { | ||
if base % (1 << align_log2) == 0 |
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.
Maybe use then
as above?
@@ -226,6 +301,34 @@ fn find_contiguous( | |||
None | |||
} | |||
|
|||
fn check_contiguous( |
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.
Should we check whether the base is aligned to the align_log2
?
The CI may need to update. Warnings from here should be removed. |
…base alignment