Skip to content

Commit c9f66b6

Browse files
committed
Turbopack: use block_in_place for db reads
1 parent 6feb098 commit c9f66b6

File tree

1 file changed

+12
-2
lines changed
  • turbopack/crates/turbo-persistence/src

1 file changed

+12
-2
lines changed

turbopack/crates/turbo-persistence/src/db.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,12 +1151,22 @@ impl<S: ParallelScheduler> TurboPersistence<S> {
11511151

11521152
/// Get a value from the database. Returns None if the key is not found. The returned value
11531153
/// might hold onto a block of the database and it should not be hold long-term.
1154-
pub fn get<K: QueryKey>(&self, family: usize, key: &K) -> Result<Option<ArcSlice<u8>>> {
1154+
pub fn get<K: QueryKey + Sync>(&self, family: usize, key: &K) -> Result<Option<ArcSlice<u8>>> {
11551155
let hash = hash_key(key);
1156+
self.parallel_scheduler
1157+
.block_in_place(|| self.get_inner(family as u32, hash, key))
1158+
}
1159+
1160+
fn get_inner<K: QueryKey>(
1161+
&self,
1162+
family: u32,
1163+
hash: u64,
1164+
key: &K,
1165+
) -> Result<Option<ArcSlice<u8>>> {
11561166
let inner = self.inner.read();
11571167
for meta in inner.meta_files.iter().rev() {
11581168
match meta.lookup(
1159-
family as u32,
1169+
family,
11601170
hash,
11611171
key,
11621172
&self.amqf_cache,

0 commit comments

Comments
 (0)