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

fix: avoid multiple threads loading same index partition #2559

Merged
merged 4 commits into from
Jul 4, 2024

Conversation

albertlockett
Copy link
Contributor

Adds locks for loading of index partitions. This voids multiple threads querying concurrently from both allocating memory to load the partition, which can cause memory issues during application startup.

@github-actions github-actions bot added the bug Something isn't working label Jul 3, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.99%. Comparing base (b3ad008) to head (243f61e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2559      +/-   ##
==========================================
- Coverage   80.00%   79.99%   -0.02%     
==========================================
  Files         209      209              
  Lines       59847    59864      +17     
  Branches    59847    59864      +17     
==========================================
+ Hits        47880    47887       +7     
- Misses       9143     9148       +5     
- Partials     2824     2829       +5     
Flag Coverage Δ
unittests 79.99% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -65,3 +70,53 @@ pub async fn maybe_sample_training_data(
})?;
Ok(array.as_fixed_size_list().clone())
}

#[derive(Debug)]
pub struct PartitionLoadLock {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this pub(crate). Just wanted to make sure this is not public API

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 is in a private module, so it won't be part of public API


#[derive(Debug)]
pub struct PartitionLoadLock {
partition_locks: RwLock<HashMap<String, Arc<Mutex<()>>>>,
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 make this vec![Arc<Mutex()] with pre-allocated mutex, we dont need RWlock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@albertlockett albertlockett changed the title fix: void multiple threads loading same index partition fix: avoid multiple threads loading same index partition Jul 4, 2024
@github-actions github-actions bot added the python label Jul 4, 2024
@eddyxu eddyxu merged commit 685fe43 into main Jul 4, 2024
22 checks passed
@eddyxu eddyxu deleted the index-load-lock branch July 4, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants