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: faster take for BitPackedArray and SparseArray #1133

Merged
merged 15 commits into from
Oct 24, 2024

Conversation

lwwmanning
Copy link
Member

@lwwmanning lwwmanning commented Oct 24, 2024

fixes #1039

@lwwmanning
Copy link
Member Author

lwwmanning commented Oct 24, 2024

Generally the same or much faster across the board

Screenshot 2024-10-24 at 16 44 48

@gatesn
Copy link
Contributor

gatesn commented Oct 24, 2024

Is the screenshot meant to have 1.0's and question marks?

Or do we have some float rounding errors?

@lwwmanning lwwmanning enabled auto-merge (squash) October 24, 2024 20:45
@lwwmanning
Copy link
Member Author

Is the screenshot meant to have 1.0's and question marks?

Or do we have some float rounding errors?

the 1.0's are normal for critcmp. not entirely sure what's up with the ?s, but vs develop, this is like a 10-70% speed-up, basically across the board

@lwwmanning
Copy link
Member Author

Per #1041 , I'm hoping after this that we can maybe revert #1032

// if we have a large number of relatively small batches, the overhead isn't worth it, and we're better off with a bulk patch
// roughly, if we have an average of less than 64 elements per batch, we prefer bulk patching
let prefer_bulk_patch = relative_indices.len() * BULK_PATCH_THRESHOLD > indices.len();
// Group indices into 1024-element chunks and relativise them to the beginning of each chunk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment shouldn't say "relativize them" any more as it does not.

@lwwmanning lwwmanning merged commit e2a681a into develop Oct 24, 2024
5 checks passed
@lwwmanning lwwmanning deleted the wm/take-canonical2 branch October 24, 2024 21:22
});
Ok(taken.reinterpret_cast(ptype).into_array())
}
}

fn take_primitive<T: NativePType + BitPacking>(
// array_chunks must use while let so that we can get the remainder
#[allow(clippy::while_let_on_iterator)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct, you can still use the for loop and then access iterator afterwards

///
/// If this sparse array has no indices (i.e. all elements are equal to fill_value)
/// then it returns None.
pub fn max_index(&self) -> Option<usize> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I added min_index but we shouldn't pile more here. The methods you want here is first_non_null and last_non_null and that can be implemented for any array

@@ -22,7 +22,7 @@ impl<'a> TreeDisplayWrapper<'a> {
}
}

impl<'a> fmt::Display for TreeDisplayWrapper<'a> {
impl fmt::Display for TreeDisplayWrapper<'_> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you're going to run nightly clippy we should do it in general in ci?

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.

get rid of relative_indices in BitPackedArray::take
4 participants