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

Remove async cache provider #1720

Merged
merged 5 commits into from
Jan 17, 2024
Merged

Remove async cache provider #1720

merged 5 commits into from
Jan 17, 2024

Conversation

javitonino
Copy link
Contributor

@javitonino javitonino commented Jan 12, 2024

Description

  • Removes async cache, unified into a single implementation of cache (sync).
  • Copied safe-deletion logic from async to sync cache.
  • Changed grpc servers and replication to use the sync cache, obtaining the shards from inside a blocking task (spawn_blocking).

How was this PR tested?

Tests and basic tinkering. Will probably require some performance testing in stage.

Copy link

This pull request has been linked to Shortcut Story #8277: Simplify shard cache layer.

Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5483d32) 82.16% compared to head (b0cc329) 82.21%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1720      +/-   ##
==========================================
+ Coverage   82.16%   82.21%   +0.05%     
==========================================
  Files         334      334              
  Lines       19537    19537              
==========================================
+ Hits        16052    16062      +10     
+ Misses       3485     3475      -10     
Flag Coverage Δ
ingest 69.11% <ø> (ø)
node-sidecar 95.39% <ø> (+1.38%) ⬆️
nucliadb 70.46% <ø> (+0.04%) ⬆️
reader 79.02% <ø> (ø)
sdk 40.58% <ø> (ø)
search 79.09% <ø> (ø)
standalone 88.27% <ø> (ø)
train 63.76% <ø> (ø)
utils 81.25% <ø> (ø)
writer 85.15% <ø> (ø)

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.

@javitonino javitonino force-pushed the sc-8277-simplify-shard-cache branch 2 times, most recently from 4bb9d81 to 581b429 Compare January 12, 2024 09:45
@@ -79,19 +85,20 @@ impl ShardReaderProvider for UnboundedShardReaderCache {
fn load_all(&self) -> NodeResult<()> {
let mut cache = self.write();
let shards_path = self.shards_path.clone();
debug!("Recovering shards from {shards_path:?}...");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

⚠️ Behaviour for load_all differed between the sync & async version:

  • The async version loaded all shards and then grabbed the lock to insert all shards into cache.
  • The sync version held the lock while loading all shards.

This version behaves like the sync version and thus blocks the cache until everything is loaded. It seems safer but potentially a long block. The async version could be prone to race-conditions if a shard is opened while load_all is running. A third alternative would be to grab a write lock for each iteration of the loop, so other consumers get the chance to interact with the cache (albeit with high contention).

@javitonino javitonino merged commit 8e42cb2 into main Jan 17, 2024
105 checks passed
@javitonino javitonino deleted the sc-8277-simplify-shard-cache branch January 17, 2024 09:42
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.

2 participants