-
Notifications
You must be signed in to change notification settings - Fork 380
copy bftrees from the snapshot location to the save location #783
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1897,8 +1897,28 @@ where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Save vectors and neighbors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.full_vectors.snapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.neighbor_provider.snapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let vectors_snapshot_path = self.full_vectors.snapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let neighbors_snapshot_path = self.neighbor_provider.snapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Copy snapshot files to the target prefix location if they differ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let target_vectors_path = BfTreePaths::vectors_bftree(&saved_params.prefix); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if vectors_snapshot_path != target_vectors_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::fs::copy(&vectors_snapshot_path, &target_vectors_path).map_err(|e| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ANNError::log_index_error(format!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Failed to copy vectors from {:?} to {:?}: {}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vectors_snapshot_path, target_vectors_path, e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1903
to
+1911
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let target_neighbors_path = BfTreePaths::neighbors_bftree(&saved_params.prefix); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if neighbors_snapshot_path != target_neighbors_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::fs::copy(&neighbors_snapshot_path, &target_neighbors_path).map_err(|e| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ANNError::log_index_error(format!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Failed to copy neighbors from {:?} to {:?}: {}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| neighbors_snapshot_path, target_neighbors_path, e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1906
to
+1920
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::fs::copy(&vectors_snapshot_path, &target_vectors_path).map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy vectors from {:?} to {:?}: {}", | |
| vectors_snapshot_path, target_vectors_path, e | |
| )) | |
| })?; | |
| } | |
| let target_neighbors_path = BfTreePaths::neighbors_bftree(&saved_params.prefix); | |
| if neighbors_snapshot_path != target_neighbors_path { | |
| std::fs::copy(&neighbors_snapshot_path, &target_neighbors_path).map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy neighbors from {:?} to {:?}: {}", | |
| neighbors_snapshot_path, target_neighbors_path, e | |
| )) | |
| })?; | |
| let src = vectors_snapshot_path.clone(); | |
| let dst = target_vectors_path.clone(); | |
| tokio::task::spawn_blocking(move || std::fs::copy(&src, &dst)) | |
| .await | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to execute blocking copy for vectors from {:?} to {:?}: {}", | |
| vectors_snapshot_path, target_vectors_path, e | |
| )) | |
| })? | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy vectors from {:?} to {:?}: {}", | |
| vectors_snapshot_path, target_vectors_path, e | |
| )) | |
| })?; | |
| } | |
| let target_neighbors_path = BfTreePaths::neighbors_bftree(&saved_params.prefix); | |
| if neighbors_snapshot_path != target_neighbors_path { | |
| let src = neighbors_snapshot_path.clone(); | |
| let dst = target_neighbors_path.clone(); | |
| tokio::task::spawn_blocking(move || std::fs::copy(&src, &dst)) | |
| .await | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to execute blocking copy for neighbors from {:?} to {:?}: {}", | |
| neighbors_snapshot_path, target_neighbors_path, e | |
| )) | |
| })? | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy neighbors from {:?} to {:?}: {}", | |
| neighbors_snapshot_path, target_neighbors_path, e | |
| )) | |
| })?; |
Copilot
AI
Feb 16, 2026
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.
Same performance concern in the quantized save_with: these std::fs::copy calls can block the async executor and double the amount of IO for large bf-tree files. Consider offloading to a blocking task or using an async copy primitive.
| std::fs::copy(&vectors_snapshot_path, &target_vectors_path).map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy vectors from {:?} to {:?}: {}", | |
| vectors_snapshot_path, target_vectors_path, e | |
| )) | |
| })?; | |
| } | |
| let target_neighbors_path = BfTreePaths::neighbors_bftree(&saved_params.prefix); | |
| if neighbors_snapshot_path != target_neighbors_path { | |
| std::fs::copy(&neighbors_snapshot_path, &target_neighbors_path).map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy neighbors from {:?} to {:?}: {}", | |
| neighbors_snapshot_path, target_neighbors_path, e | |
| )) | |
| })?; | |
| } | |
| let target_quant_path = BfTreePaths::quant_bftree(&saved_params.prefix); | |
| if quant_snapshot_path != target_quant_path { | |
| std::fs::copy(&quant_snapshot_path, &target_quant_path).map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy quant from {:?} to {:?}: {}", | |
| quant_snapshot_path, target_quant_path, e | |
| )) | |
| })?; | |
| tokio::fs::copy(&vectors_snapshot_path, &target_vectors_path) | |
| .await | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy vectors from {:?} to {:?}: {}", | |
| vectors_snapshot_path, target_vectors_path, e | |
| )) | |
| })?; | |
| } | |
| let target_neighbors_path = BfTreePaths::neighbors_bftree(&saved_params.prefix); | |
| if neighbors_snapshot_path != target_neighbors_path { | |
| tokio::fs::copy(&neighbors_snapshot_path, &target_neighbors_path) | |
| .await | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy neighbors from {:?} to {:?}: {}", | |
| neighbors_snapshot_path, target_neighbors_path, e | |
| )) | |
| })?; | |
| } | |
| let target_quant_path = BfTreePaths::quant_bftree(&saved_params.prefix); | |
| if quant_snapshot_path != target_quant_path { | |
| tokio::fs::copy(&quant_snapshot_path, &target_quant_path) | |
| .await | |
| .map_err(|e| { | |
| ANNError::log_index_error(format!( | |
| "Failed to copy quant from {:?} to {:?}: {}", | |
| quant_snapshot_path, target_quant_path, e | |
| )) | |
| })?; |
Copilot
AI
Feb 16, 2026
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.
Same issue as above in the quantized save_with: the .bftree files are copied via std::fs::copy rather than through the provided StorageWriteProvider. This makes the save output dependent on the local filesystem even though other artifacts (params JSON, delete bitmap, PQ pivots) are written via storage.
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.
This new behavior is meant to handle the case where a provider was loaded from one prefix (snapshot location) and then saved to a different prefix, but the existing tests appear to only cover save+load using the same prefix path. Adding a regression test that loads from prefix A, saves to prefix B, and then loads from prefix B would validate the copy logic and prevent future regressions.