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

Minimal implementation of local Vcs #8780

Closed
wants to merge 1 commit into from
Closed

Conversation

bgw
Copy link
Member

@bgw bgw commented Jul 18, 2024

Description

Local Vcs store task-local values inside of the current task's state. The SharedReference holding onto their values is dropped when the task exits.

The contents of a local Vc must still use a refcounted SharedReference/triomphe::Arc because they can be turned into ReadRef objects (https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html), which require a 'static lifetime. We can experiment with adding a lifetime to ReadRef in a future iteration, but there's little advantage to doing this until we have local tasks.

Limitations

This implements just enough to create and read local Vcs (with a test!). There are many things that are still unimplemented with todo!(). Most notably:

  • We can't resolve a local Vc to a ResolvedVc.
  • There's no way to return or pass a local Vc as an argument yet.
  • For safety, we should only allow construction of local Vcs in functions where we know that the return value is a ResolvedValue.

Grand plan: https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

Memory Usage

  • This increases the size of Vc/RawVc from 96 bits to 128 bits. With clever packing this could (in theory) be solved. However, that it increase the number of machine words (2x 64bit), so it might not have any real impact after alignment happens.

  • This increase the size of CurrentTaskState. I suspect this isn't too bad as there should be a smallish number of tasks active at any given time.

I was not able to measure any change to peak memory/heap usage.

Built using

cargo build --release -p next-build-test

Ran heaptrack on a single page (/sink) in shadcn/ui with:

cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'

And analyzed the results with

heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20

Before

total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K

After

total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K

Testing Instructions

cargo nextest r -p turbo-tasks -p turbo-tasks-memory

Copy link

vercel bot commented Jul 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 9:05pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 9:05pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jul 29, 2024 9:05pm

Copy link
Member Author

bgw commented Jul 18, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bgw and the rest of your teammates on Graphite Graphite

Copy link
Contributor

github-actions bot commented Jul 18, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

✅ This change can build next-swc

@bgw bgw changed the title Minimal implementation of local cells Minimal implementation of local Vcs Jul 18, 2024
Copy link
Contributor

github-actions bot commented Jul 18, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@bgw bgw force-pushed the bgw/local-cell branch from 9fadf1a to 7b2f510 Compare July 18, 2024 00:27
@bgw bgw force-pushed the bgw/local-cell branch from 7b2f510 to eeeda38 Compare July 24, 2024 05:02
@bgw bgw force-pushed the bgw/local-cell branch from eeeda38 to 4cabdf1 Compare July 26, 2024 19:57
@bgw bgw changed the base branch from main to bgw/cell-mode-raw July 26, 2024 19:57
@bgw bgw force-pushed the bgw/local-cell branch from 4cabdf1 to 10b9aa5 Compare July 26, 2024 22:07
@bgw bgw marked this pull request as ready for review July 26, 2024 22:08
@bgw bgw requested a review from a team as a code owner July 26, 2024 22:08
@bgw bgw force-pushed the bgw/local-cell branch from 10b9aa5 to 02b6fb4 Compare July 26, 2024 23:47
return false;
}
.scope(
RefCell::new(CurrentTaskState::new(this.execution_id_factory.get())),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe to make this diff a little clearer you can move this into a var?

@@ -282,6 +304,13 @@ where
pub fn cell(inner: Inner) -> Self {
<T::CellMode as VcCellMode<T>>::cell(inner)
}

pub fn local_cell(inner: Inner) -> Self {
// `T::CellMode` isn't applicable here, we always create new local cells. Local
Copy link
Contributor

@arlyon arlyon Jul 31, 2024

Choose a reason for hiding this comment

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

Bit of a random question but just want to challenge my understanding. We have a few ways of interacting 'up the chain' so to speak. At the top level you have the global 'arena' with any number of 'subarenas' for local tasks. Presumably you can interleave local and global tasks at will. Do we intend on having local areanas further down the call graph be able to read / access from Vcs in their 'superarenas' and global state?

#[turbo::function]
fn a(path: Vc<Path>) -> Vc<CompiledCode> {
  let is_dir = path.is_directory().await;
  if (is_dir) {
    return b(path);
  }
  // do stuff
}

#[turbo::function(local)]
fn b(path: Vc<Path>) -> Vc<CompiledCode> {
  // is Path::is_directory resolved here or do we recompute?
}

Path::is_directory is already resolved in the global cache.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we intend on having local areanas further down the call graph be able to read / access from Vcs in their 'superarenas' and global state?

This is a good question.

Global state: Yes. Local tasks will create local Vcs by default, but they will be able to both create and read resolved Vcs that use global cells. When creating global cells, those cells will be assigned to nearest non-local parent task.

In your example, Path::is_directory would not need to be re-executed because it's in the global cache.

"Superarenas" of calling tasks: No, at least for right now. Local Vcs must be resolved before being passed as an argument into another task.

One of the unintuitive challenges with reading from local "superarenas" is that (currently) every task is tokio::spawned and never canceled/aborted. This means that a child called task can outlive it's parent caller. This isn't common as most calling tasks await all their children, but can happen in the case of panics in the parent/calling task or with use of APIs like tokio::select!.

For memory safety we either need a mechanism for canceling tasks (triggering a drop at the await point) if they try to read from an expired caller's "superarena", or (more likely) we need to defer the cleanup of local arenas until all of their child spawned tasks exit.

@bgw
Copy link
Member Author

bgw commented Aug 2, 2024

Migrated to the next.js repo: vercel/next.js#68469

@bgw bgw closed this Aug 2, 2024
@bgw bgw deleted the bgw/local-cell branch August 4, 2024 19:50
bgw added a commit to vercel/next.js that referenced this pull request Aug 5, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
samcx pushed a commit to vercel/next.js that referenced this pull request Aug 5, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 14, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 15, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 16, 2024
*This is a migrated PR. This was in the turbo repository before the
next.js merge.*
**Migrated From:** vercel/turborepo#8780

# Description

Local Vcs store task-local values inside of the current task's state.
The `SharedReference` holding onto their values is dropped when the task
exits.

The contents of a local Vc must still use a refcounted
`SharedReference`/`triomphe::Arc` because they can be turned into
`ReadRef` objects
(https://turbopack-rust-docs.vercel.sh/rustdoc/turbo_tasks/struct.ReadRef.html),
which require a `'static` lifetime. We can experiment with adding a
lifetime to `ReadRef` in a future iteration, but there's little
advantage to doing this until we have local tasks.

# Limitations

This implements *just enough* to create and read local Vcs (with a
test!). There are many things that are still unimplemented with
`todo!()`. Most notably:

- We can't resolve a local `Vc` to a `ResolvedVc`.
- There's no way to return or pass a local `Vc` as an argument yet.
- For safety, we should only allow construction of local `Vc`s in
functions where we know that the return value is a `ResolvedValue`.

Grand plan:
https://www.notion.so/vercel/Resolved-Vcs-Vc-Lifetimes-Local-Vcs-and-Vc-Refcounts-49d666d3f9594017b5b312b87ddc5bff

# Memory Usage

- This increases the size of `Vc`/`RawVc` from 96 bits to 128 bits. With
clever packing this could (in theory) be solved. However, that it
increase the number of machine words (2x 64bit), so it might not have
any real impact after alignment happens.

- This increase the size of `CurrentTaskState`. I suspect this isn't too
bad as there should be a smallish number of tasks active at any given
time.

**I was not able to measure any change to peak memory/heap usage.**

Built using

```
cargo build --release -p next-build-test
```

Ran heaptrack on a single page (`/sink`) in `shadcn/ui` with:

```
cd ~/ui/apps/www
heaptrack ~/nextpack/target/release/next-build-test run sequential 1 1 '/sink'
```

And analyzed the results with

```
heaptrack --analyze /home/bgw.linux/ui/apps/www/heaptrack.next-build-test.3066837.zst | tail -20
```

### Before

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

```
total runtime: 135.48s.
calls to allocation functions: 48619554 (358863/s)
temporary memory allocations: 3883888 (28667/s)
peak heap memory consumption: 1.12G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.71M
suppressed leaks: 7.24K
```

### After

```
total runtime: 157.20s.
calls to allocation functions: 48509638 (308579/s)
temporary memory allocations: 3902883 (24827/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.70G
total memory leaked: 4.86M
suppressed leaks: 7.24K
```

```
total runtime: 130.25s.
calls to allocation functions: 48553541 (372786/s)
temporary memory allocations: 3863919 (29666/s)
peak heap memory consumption: 1.13G
peak RSS (including heaptrack overhead): 2.69G
total memory leaked: 4.96M
suppressed leaks: 7.24K
```

# Testing Instructions

```
cargo nextest r -p turbo-tasks -p turbo-tasks-memory
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants