Skip to content

service: reduce fscache blob init lock scope - #1992

Open
Park-Jiyeonn wants to merge 1 commit into
dragonflyoss:masterfrom
Park-Jiyeonn:fix/fscache-lock-scope
Open

service: reduce fscache blob init lock scope#1992
Park-Jiyeonn wants to merge 1 commit into
dragonflyoss:masterfrom
Park-Jiyeonn:fix/fscache-lock-scope

Conversation

@Park-Jiyeonn

@Park-Jiyeonn Park-Jiyeonn commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Overview

Move blob initialization and prefetch work out of the fscache blob lock. Wait for initialization only when read or close needs the blob, so concurrent requests do not block on long I/O.

Change Type

Please select the type of change your pull request relates to:

  • Bug Fix
  • Feature Addition
  • Documentation Update
  • Code Refactoring
  • Performance Improvement
  • Other (please describe)

Move blob initialization and prefetch work out of the fscache
blob lock. Wait for initialization only when read or close needs
the blob, so concurrent requests do not block on long I/O.

Signed-off-by: Park.Jiyeon <jiyeonnn2@icloud.com>
Copilot AI review requested due to automatic review settings July 22, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors FsCacheHandler’s fscache data-blob initialization flow to reduce the time spent holding the per-blob lock, aiming to improve concurrency by letting other requests proceed while blob creation/prefetch setup occurs in the background.

Changes:

  • Introduced an init synchronization state (FsCacheBlobInitState + guard) to coordinate when blob initialization is considered complete.
  • Moved blob creation and prefetch planning out of the RwLock write-lock critical section; only the cache assignment takes the write lock.
  • Updated read/close paths to wait for initialization completion only when the blob is actually needed.

Comment thread service/src/fs_cache.rs
Comment on lines +250 to +255
fn wait(&self) {
let mut done = self.done.lock().unwrap();
while !*done {
done = self.condvar.wait(done).unwrap();
}
}
Comment thread service/src/fs_cache.rs
Comment on lines +223 to +227
#[derive(Default)]
struct FsCacheBlobInitState {
done: Mutex<bool>,
condvar: Condvar,
}
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