Skip to content

Commit 111f334

Browse files
authored
[Turbopack] box InnerStorage to avoid overallocation (#75287)
### What? This reduces the overallocated memory by InnerStorage instances in the DashMap capacity
1 parent 1ab8837 commit 111f334

File tree

1 file changed

+4
-4
lines changed
  • turbopack/crates/turbo-tasks-backend/src/backend

1 file changed

+4
-4
lines changed

turbopack/crates/turbo-tasks-backend/src/backend/storage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl InnerStorage {
296296
}
297297

298298
pub struct Storage {
299-
map: DashMap<TaskId, InnerStorage, BuildHasherDefault<FxHasher>>,
299+
map: DashMap<TaskId, Box<InnerStorage>, BuildHasherDefault<FxHasher>>,
300300
}
301301

302302
impl Storage {
@@ -315,7 +315,7 @@ impl Storage {
315315
pub fn access_mut(&self, key: TaskId) -> StorageWriteGuard<'_> {
316316
let inner = match self.map.entry(key) {
317317
dashmap::mapref::entry::Entry::Occupied(e) => e.into_ref(),
318-
dashmap::mapref::entry::Entry::Vacant(e) => e.insert(InnerStorage::new()),
318+
dashmap::mapref::entry::Entry::Vacant(e) => e.insert(Box::new(InnerStorage::new())),
319319
};
320320
StorageWriteGuard {
321321
inner: inner.into(),
@@ -327,7 +327,7 @@ impl Storage {
327327
key1: TaskId,
328328
key2: TaskId,
329329
) -> (StorageWriteGuard<'_>, StorageWriteGuard<'_>) {
330-
let (a, b) = get_multiple_mut(&self.map, key1, key2, InnerStorage::new);
330+
let (a, b) = get_multiple_mut(&self.map, key1, key2, || Box::new(InnerStorage::new()));
331331
(
332332
StorageWriteGuard { inner: a },
333333
StorageWriteGuard { inner: b },
@@ -336,7 +336,7 @@ impl Storage {
336336
}
337337

338338
pub struct StorageWriteGuard<'a> {
339-
inner: RefMut<'a, TaskId, InnerStorage>,
339+
inner: RefMut<'a, TaskId, Box<InnerStorage>>,
340340
}
341341

342342
impl Deref for StorageWriteGuard<'_> {

0 commit comments

Comments
 (0)