-
Notifications
You must be signed in to change notification settings - Fork 6
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
Make the keys smaller #23
base: main
Are you sure you want to change the base?
Conversation
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.
Please update the README to specify that users can use a u7
for their index, please?
And I am very worried about the x2 on the query time. Can you measure that just to understand the reason why? We can't double the query time to gain 10% of indexing time...
dimensions: usize, | ||
) -> Result<Writer<D>> { | ||
if index > 0b0111_1111 { |
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.
Can we use a function for that, instead?
let node = lazy_node.decode().unwrap(); | ||
writeln!(f, "Tree {}: {node:?}", key.item)?; | ||
} | ||
_ => unreachable!("Impossiburuu"), |
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.
_ => unreachable!("Impossiburuu"), | |
_ => unreachable!(), |
database: heed::Database<KeyCodec, U>, | ||
) -> Result<Reader<'t, D>> { | ||
if index > 0b0111_1111 { |
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.
Can we use a non_meta
function here, please?
@@ -28,9 +28,15 @@ pub struct Reader<'t, D: Distance> { | |||
impl<'t, D: Distance> Reader<'t, D> { | |||
pub fn open<U>( | |||
rtxn: &'t RoTxn, | |||
index: u16, | |||
index: u8, |
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.
Can you add an infromation on what's the limit of this u8
, please? Just a single doc line, we will refine that later.
let item_bytes = self.item.to_be_bytes(); | ||
debug_assert_eq!(item_bytes.len(), output.len() - 1); | ||
|
||
output[1..].copy_from_slice(&item_bytes); |
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.
let item_bytes = self.item.to_be_bytes(); | |
debug_assert_eq!(item_bytes.len(), output.len() - 1); | |
output[1..].copy_from_slice(&item_bytes); | |
let item_bytes = self.item.to_be_bytes(); | |
output[1..].copy_from_slice(&item_bytes); |
This function will panic if the two slices have different lengths.
https://doc.rust-lang.org/stable/std/primitive.slice.html#method.copy_from_slice
Make the keys as small as possible by:
Performances results:
baseline / main branch:
smol_keys:
And even though the query time is pretty small, the 3.8ms vs 6.4ms seems pretty consistent