Skip to content

Commit 1d68fcb

Browse files
authored
reduce size of TypeType from 32bytes to 16bytes (vercel#4650)
### Description saving some memory
1 parent 7322073 commit 1d68fcb

File tree

1 file changed

+6
-5
lines changed
  • crates/turbo-tasks-memory/src

1 file changed

+6
-5
lines changed

crates/turbo-tasks-memory/src/task.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,19 @@ struct ReadScopeCollectiblesTaskType {
7979

8080
/// Different Task types
8181
enum TaskType {
82+
// Note: double boxed to reduce TaskType size
8283
/// A root task that will track dependencies and re-execute when
8384
/// dependencies change. Task will eventually settle to the correct
8485
/// execution.
85-
Root(NativeTaskFn),
86+
Root(Box<NativeTaskFn>),
8687

87-
// TODO implement these strongly consistency
88+
// Note: double boxed to reduce TaskType size
8889
/// A single root task execution. It won't track dependencies.
8990
/// Task will definitely include all invalidations that happened before the
9091
/// start of the task. It may or may not include invalidations that
9192
/// happened after that. It may see these invalidations partially
9293
/// applied.
93-
Once(OnceTaskFn),
94+
Once(Box<OnceTaskFn>),
9495

9596
/// A task that reads all collectibles of a certain trait from a
9697
/// [TaskScope]. It will do that by recursively calling
@@ -540,7 +541,7 @@ impl Task {
540541
functor: impl Fn() -> NativeTaskFuture + Sync + Send + 'static,
541542
stats_type: StatsType,
542543
) -> Self {
543-
let ty = TaskType::Root(Box::new(functor));
544+
let ty = TaskType::Root(Box::new(Box::new(functor)));
544545
let description = Self::get_event_description_static(id, &ty);
545546
Self {
546547
id,
@@ -559,7 +560,7 @@ impl Task {
559560
functor: impl Future<Output = Result<RawVc>> + Send + 'static,
560561
stats_type: StatsType,
561562
) -> Self {
562-
let ty = TaskType::Once(Mutex::new(Some(Box::pin(functor))));
563+
let ty = TaskType::Once(Box::new(Mutex::new(Some(Box::pin(functor)))));
563564
let description = Self::get_event_description_static(id, &ty);
564565
Self {
565566
id,

0 commit comments

Comments
 (0)