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

implement deletion vector handling in index scan #958

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

chebbyChefNEQ
Copy link
Contributor

@chebbyChefNEQ chebbyChefNEQ commented Jun 9, 2023

closes #916

Implement deletion vector handling in PQIndex, where all vector index are stored.

TODO:

  • add tests
  • add TODO comments in places we could have potential performance gains

Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

Looking fine so far. But definitely seems like we'll want to be benchmarking this. Let me get a PR up for that.

@chebbyChefNEQ
Copy link
Contributor Author

TL;DR:

  • Seems to have very little latency impact
  • We should also test query throughput than just latency.

after picking in #960 the difference of index scan performance pre/post this PR is negligible. Any perf impact introduced is smaller in magnitude than noise.

The impact maybe become more pronunciated in a environment where IO latency is high, say, EC2 instance with EBS, which is a remote disk.

Since this change introduces more IO, I'd hypothesis that there could be a hit to the query throughput

@eddyxu
Copy link
Contributor

eddyxu commented Jun 11, 2023

Seems to have very little latency impact

is this for scanning or the ANN search?

@chebbyChefNEQ
Copy link
Contributor Author

is this for scanning or the ANN search?
ann search. The bench mark uses nearest.

@chebbyChefNEQ chebbyChefNEQ force-pushed the rmeng/deletion-index-scan branch 3 times, most recently from 9c85d52 to eb32e03 Compare June 12, 2023 22:36
Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

I think we still need to handle the diskann implementation.

rust/src/index/vector/pq.rs Show resolved Hide resolved
Comment on lines 279 to 280
// Precollecting everything to a hash map requires async closure. This way we avoid that
let mut deletion_vec_cache: HashMap<u64, DeletionVector> = HashMap::new();
Copy link
Contributor

Choose a reason for hiding this comment

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

If we need to duplicate this for other indices, should we encapsulate this into it's own struct? I think that also let's us not bring the manifest and object store down into here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this cache is only valid within each look up. Let me add deletion handling in diskANN. What you think about adding session caching for deletion vector in the next PR.

Copy link
Contributor Author

@chebbyChefNEQ chebbyChefNEQ Jun 13, 2023

Choose a reason for hiding this comment

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

ignore the last comment. it's actually easier to just add a DeletionLookup in the session than modify two index

Comment on lines 306 to 314
if dvec.is_err() {
return Err(Error::Index {
message: format!(
"Failed to read deletion file for fragment {}",
frag_id
),
});
}
dvec.unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic masks the underlying error.

Could we just do:

Suggested change
if dvec.is_err() {
return Err(Error::Index {
message: format!(
"Failed to read deletion file for fragment {}",
frag_id
),
});
}
dvec.unwrap()
dvec?

@chebbyChefNEQ chebbyChefNEQ force-pushed the rmeng/deletion-index-scan branch 3 times, most recently from 28f66b9 to f53d98b Compare June 13, 2023 16:05
rust/src/index/vector/pq.rs Outdated Show resolved Hide resolved
@@ -341,6 +343,74 @@ pub(crate) async fn read_deletion_file(
}
}

pub struct LruDeletionVectorStore {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good. In the future, we might have the reads make concurrent queries on is_deleted(), in which case we might change this to:

  1. Use Rwlock instead of Mutex (unless we find writer starvation is an issue)
  2. Make the IO happen separately, to prevent the situation where two concurrent calls are making the same IO call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed. I tried to use RWLock but LruCache requires mut ref for getting items too (updating the recently used state probably)

I need to find a way to go around that

@chebbyChefNEQ chebbyChefNEQ force-pushed the rmeng/deletion-index-scan branch from f53d98b to def6183 Compare June 13, 2023 16:38
@chebbyChefNEQ chebbyChefNEQ merged commit 9b88373 into main Jun 13, 2023
@chebbyChefNEQ chebbyChefNEQ deleted the rmeng/deletion-index-scan branch June 13, 2023 16:54
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.

Make scanner work with deletion (read path)
3 participants