-
Notifications
You must be signed in to change notification settings - Fork 186
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: expose index cache size #1587
Conversation
d2499c0
to
f94addd
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.
Correct me if I'm wrong @eddyxu, but I think you mean expose setting index cache size, right? This is just reading.
@wjones127 is right. This is for users from |
Got it. Would we still want the read interface? |
I don't think it's critical, but it could be useful for testing. |
I'll leave it in for testing for now. |
Lets reduce the API interface to put it behind |
b3ad2cc
to
3f3c5a8
Compare
@eddyxu moved the |
pub(crate) fn get_size(&self) -> usize { | ||
self.scalar_cache.sync(); | ||
self.vector_cache.sync(); | ||
self.scalar_cache.entry_count() as usize + self.vector_cache.entry_count() as usize |
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.
@wjones127 do you feel just summing this is ok?
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.
TBH, I’m not sure I care about the entry count. As a user, I would much rather set the limit in terms of bytes and get the total bytes consumed in the statistics. So this is fine for now but long term I think we ought to consider switching to evicting based on in-memory 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.
IIUC we can use weighted_size
and with weigher to do that. (I hope moka is better at cache invaliation than naming).
I can give that a quick try.
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.
Actually let's make that a separate issue to not stall this one.
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.
I hope moka is better at cache invaliation than naming
🤣
Actually let's make that a separate issue to not stall this one.
Sounds good!
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.
Opened #1613
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.
I think summing is fine. We might just merge these into one field someday.
However, I think there is one potential problem. The user might set the index cache size to X and then, if they have both scalar and vector indices, they might see an entry count of 2 * X
. Still, the best long term solution is probably to do bytes so let's stick with summing for now.
4c81b7d
to
e598332
Compare
@wjones127 any other comments here? |
6758931
to
bc53b9b
Compare
b44691a
to
a41104f
Compare
a41104f
to
c47de30
Compare
c47de30
to
effed41
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.
Some questions but nothing blocking, looks good.
@@ -89,7 +89,13 @@ def dataset( | |||
Approximately, ``n = Total Rows / number of IVF partitions``. | |||
``pq = number of PQ sub-vectors``. | |||
""" | |||
ds = LanceDataset(uri, version, block_size, commit_lock=commit_lock) | |||
ds = LanceDataset( |
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.
Does the index cache have a TTL (I'm looking at the comment above which, to be fair, looks like it isn't part of this PR)? I don't think it does.
@@ -839,6 +839,7 @@ def create_index( | |||
ivf_centroids: Optional[Union[np.ndarray, pa.FixedSizeListArray]] = None, | |||
num_sub_vectors: Optional[int] = None, | |||
accelerator: Optional[Union[str, "torch.Device"]] = None, | |||
index_cache_size: Optional[int] = None, |
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.
I wonder if it would be better to change create_index
so that it modifies the dataset in-place instead of returning a new dataset. Though that would be a breaking change so perhaps that ship has sailed.
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.
I was intending to do that at some point. I had done this on the Rust side earlier since it was a source of bugs: #1118
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.
That does seem like the better design to me.
pub(crate) fn get_size(&self) -> usize { | ||
self.scalar_cache.sync(); | ||
self.vector_cache.sync(); | ||
self.scalar_cache.entry_count() as usize + self.vector_cache.entry_count() as usize |
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.
I think summing is fine. We might just merge these into one field someday.
However, I think there is one potential problem. The user might set the index cache size to X and then, if they have both scalar and vector indices, they might see an entry count of 2 * X
. Still, the best long term solution is probably to do bytes so let's stick with summing for now.
This is to enable lancedb/lancedb#641.
This is to enable lancedb/lancedb#641.
This is to enable #641. Should be merged after lancedb/lance#1587 is released.
This is to enable lancedb#641. Should be merged after lancedb/lance#1587 is released.
This is to enable #641. Should be merged after lancedb/lance#1587 is released.
This is to enable lancedb/lancedb#641.