Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hky1999
Copy link

@hky1999 hky1999 commented Nov 28, 2024

…base alignment

src/lib.rs Outdated
size: usize,
align_log2: usize,
) -> Option<usize> {
if check_contiguous(self, base, Self::CAP, size, align_log2) {

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?

Copy link
Author

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 {

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?

Copy link
Author

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

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

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(

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?

@Azure-stars
Copy link

The CI may need to update. Warnings from here should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants