-
Notifications
You must be signed in to change notification settings - Fork 30k
Turbopack: use block in place for db writes #82380
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -413,9 +413,12 @@ impl<K: StoreKey + Send + Sync, S: ParallelScheduler, const FAMILIES: usize> | |
| let seq = self.current_sequence_number.fetch_add(1, Ordering::SeqCst) + 1; | ||
|
|
||
| let path = self.db_path.join(format!("{seq:08}.sst")); | ||
| let (meta, file) = | ||
| write_static_stored_file(entries, total_key_size, total_value_size, &path) | ||
| .with_context(|| format!("Unable to write SST file {seq:08}.sst"))?; | ||
| let (meta, file) = self | ||
| .parallel_scheduler | ||
| .block_in_place(|| { | ||
| write_static_stored_file(entries, total_key_size, total_value_size, &path) | ||
| }) | ||
| .with_context(|| format!("Unable to write SST file {seq:08}.sst"))?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The View Details📝 Patch Detailsdiff --git a/turbopack/crates/turbo-persistence/src/write_batch.rs b/turbopack/crates/turbo-persistence/src/write_batch.rs
index f6cbd44acc..6365e37cfc 100644
--- a/turbopack/crates/turbo-persistence/src/write_batch.rs
+++ b/turbopack/crates/turbo-persistence/src/write_batch.rs
@@ -434,7 +434,9 @@ impl<K: StoreKey + Send + Sync, S: ParallelScheduler, const FAMILIES: usize>
static_sorted_file_builder::Entry,
};
- file.sync_all()?;
+ self.parallel_scheduler.block_in_place(|| {
+ file.sync_all()
+ })?;
let sst = StaticSortedFile::open(
&self.db_path,
StaticSortedFileMetaData {
AnalysisIn the The function already wraps the This is particularly important because RecommendationWrap the self.parallel_scheduler.block_in_place(|| {
file.sync_all()
})?;This maintains consistency with the other blocking I/O operations in the same function and across the codebase. |
||
|
|
||
| #[cfg(feature = "verify_sst_content")] | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
create_blobfunction contains multiple blocking I/O operations (File::create,write_all,flush) that should be wrapped withblock_in_placefor consistency with the pattern established in this changeset.View Details
📝 Patch Details
Analysis
The
create_blobfunction performs several blocking I/O operations:File::create(&file)on line 397file.write_all(&buffer)on line 398file.flush()on line 400These are all synchronous file system operations that can block the current thread, but they're not wrapped with
self.parallel_scheduler.block_in_place(). This is inconsistent with the pattern established throughout this changeset where blocking I/O operations are being wrapped to properly inform the async scheduler.This inconsistency could lead to issues in async contexts where the scheduler expects to be notified about blocking work so it can allocate additional threads to maintain throughput.
Recommendation
Wrap all the blocking I/O operations in the
create_blobfunction withself.parallel_scheduler.block_in_place():