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

refactor: parallel write buffer writing for large object disk cache #619

Merged
merged 3 commits into from
Jul 20, 2024

Conversation

MrCroxx
Copy link
Collaborator

@MrCroxx MrCroxx commented Jul 18, 2024

What's changed and what's your intention?

Please explain IN DETAIL what the changes are in this PR and why they are needed. :D

This PR refined the write model of the large object disk cache.

With the previous design, entries submitted to the same flusher will be serialized in the flusher runner thread (tokio task), whose throughput is limited by the 1 CPU core. With the new design, every entry is serialized in its submit thread, and the serialization between entries can be paralleled.

The parallelism is achieved by allocating with a mutex and waiting withWaitGroup #615.

Checklist

  • I have written the necessary rustdoc comments
  • I have added the necessary unit tests and integration tests
  • I have passed make all (or make fast instead if the old tests are not modified) in my local environment.

Related issues or PRs (optional)

#596 #615
close #581

@MrCroxx MrCroxx added feature New feature or request refactor perf Performance optimization labels Jul 18, 2024
@MrCroxx MrCroxx added this to the v0.11 milestone Jul 18, 2024
@MrCroxx MrCroxx self-assigned this Jul 18, 2024
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 60 lines in your changes missing coverage. Please review.

Project coverage is 81.77%. Comparing base (f927f34) to head (7629c6b).

Files Patch % Lines
foyer-storage/src/large/batch.rs 83.96% 38 Missing ⚠️
foyer-storage/src/device/bytes.rs 58.97% 16 Missing ⚠️
foyer-storage/src/large/flusher.rs 95.41% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #619      +/-   ##
==========================================
+ Coverage   81.70%   81.77%   +0.06%     
==========================================
  Files          66       67       +1     
  Lines        8425     8522      +97     
==========================================
+ Hits         6884     6969      +85     
- Misses       1541     1553      +12     

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

.map(|group| {
// TODO(MrCroxx): Refine to logic.
// Do not filter empty group here.
// An empty group can be used to trigger makring evictable region in flusher.
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo makring

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sharper sight than typos 🥵.


rx: mpsc::UnboundedReceiver<Submission<K, V, S>>,
notify: Arc<Notify>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replace Notify with CondationVariable later, for the implementation of Notify also includes a mutex.

Comment on lines +303 to +311
let mut indices = group.indices;
for haddr in indices.iter_mut() {
haddr.address.region = region.id();
}
};
try_join(try_join_all(futures), future).await?;
if let Some(init_time) = batch.init_time.as_ref() {
metrics.storage_queue_rotate.increment(1);
metrics.storage_queue_rotate_duration.record(init_time.elapsed());
indexer.insert_batch(indices);
for tx in group.txs {
let _ = tx.send(Ok(true));
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Move notification to a dedicated thread to increase the throughput.

Signed-off-by: MrCroxx <[email protected]>
@MrCroxx MrCroxx enabled auto-merge (squash) July 20, 2024 14:59
@MrCroxx MrCroxx merged commit 3f98d0d into main Jul 20, 2024
13 checks passed
@MrCroxx MrCroxx deleted the xx/batch branch July 20, 2024 15:04
@MrCroxx MrCroxx mentioned this pull request Jul 20, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request perf Performance optimization refactor
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

perf: move disk cache buffer writing out of lock section
2 participants