merge blob & key storage locking scopes in content layer - keep both blob & key cache updates 'atomic'

This commit is contained in:
Ryan Fleury
2025-09-30 15:25:15 -07:00
parent 5b00aaadaf
commit d5ea64a72d
+8 -4
View File
@@ -188,7 +188,12 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx]; C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx];
//- rjf: commit data to cache - if already there, just bump key refcount //- rjf: commit data to cache - if already there, just bump key refcount
ProfScope("commit data to cache - if already there, just bump key refcount") MutexScopeW(stripe->rw_mutex) U128 key_expired_hash = {0};
ProfScope("commit data to cache - if already there, just bump key refcount")
MutexScopeW(stripe->rw_mutex)
MutexScopeW(key_stripe->rw_mutex)
{
//- rjf: commit data to (hash -> data) cache
{ {
C_BlobNode *existing_node = 0; C_BlobNode *existing_node = 0;
for(C_BlobNode *n = slot->first; n != 0; n = n->next) for(C_BlobNode *n = slot->first; n != 0; n = n->next)
@@ -234,9 +239,7 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
} }
} }
//- rjf: commit this hash to key cache //- rjf: commit hash to key cache
U128 key_expired_hash = {0};
ProfScope("commit this hash to key cache") MutexScopeW(key_stripe->rw_mutex)
{ {
// rjf: find existing key // rjf: find existing key
B32 key_is_new = 0; B32 key_is_new = 0;
@@ -310,6 +313,7 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
} }
} }
} }
}
//- rjf: decrement key ref count of expired hash //- rjf: decrement key ref count of expired hash
ProfScope("decrement key ref count of expired hash") ProfScope("decrement key ref count of expired hash")