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

Switch RcStr from std::sync::Arc to triomphe::Arc #8715

Merged
merged 2 commits into from
Jul 11, 2024
Merged

Conversation

bgw
Copy link
Member

@bgw bgw commented Jul 10, 2024

Description

This removes the weakref from each Arc, which we weren't using, saving 64 bits per unique RcStr.

https://docs.rs/triomphe/latest/triomphe/struct.Arc.html

The difference in memory is too small to easily measure with heaptrack, but it should be a small win regardless, and it's a drop-in replacement that doesn't make the code any more complicated.

Testing Instructions

Built using

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

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

cd ~/ui/apps/www
RUST_LOG=next_build_test=info 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 -100

Heaptrack Before PR

total runtime: 135.14s.
calls to allocation functions: 49700807 (367770/s)
temporary memory allocations: 4126130 (30532/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.93M
suppressed leaks: 7.24K
total runtime: 138.50s.
calls to allocation functions: 49771465 (359355/s)
temporary memory allocations: 4410274 (31842/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 12.09M
suppressed leaks: 7.24K

Heaptrack After PR

total runtime: 145.38s.
calls to allocation functions: 49714711 (341966/s)
temporary memory allocations: 4164393 (28645/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 11.67M
suppressed leaks: 7.24K
total runtime: 128.03s.
calls to allocation functions: 49739679 (388515/s)
temporary memory allocations: 4111893 (32117/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.88M
suppressed leaks: 7.24K

Copy link

vercel bot commented Jul 10, 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 10, 2024 10:41pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 10, 2024 10:41pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jul 10, 2024 10:41pm

Copy link
Member Author

bgw commented Jul 10, 2024

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 10, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

✅ This change can build next-swc

@bgw bgw marked this pull request as ready for review July 10, 2024 22:29
@bgw bgw requested a review from a team as a code owner July 10, 2024 22:29
Copy link
Contributor

github-actions bot commented Jul 10, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

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

See workflow summary for details

This saves a weakref count on each Arc
@bgw bgw merged commit aa2b8fc into main Jul 11, 2024
55 of 57 checks passed
Copy link
Member Author

bgw commented Jul 11, 2024

Merge activity

  • Jul 10, 10:52 PM EDT: @bgw merged this pull request with Graphite.

@bgw bgw deleted the bgw/rcstr-triomphe branch July 11, 2024 02:52
kdy1 added a commit to vercel/next.js that referenced this pull request Jul 12, 2024
# Turbopack
* vercel/turborepo#8686 <!-- Tobias Koppers -
improve performance of the graph aggregation -->
* vercel/turborepo#8694 <!-- Benjamin Woodruff -
Replace `unreachable` with `bail` in `finalize_css` -->
* vercel/turborepo#8661 <!-- Benjamin Woodruff -
Create a minimum viable `ResolvedVc` type -->
* vercel/turborepo#8662 <!-- Benjamin Woodruff - Add
a minimum viable ResolvedValue marker trait -->
* vercel/turborepo#8678 <!-- Benjamin Woodruff - Add
derive macro for ResolvedValue -->
* vercel/turborepo#8715 <!-- Benjamin Woodruff -
Switch RcStr from std::sync::Arc to triomphe::Arc -->
* vercel/turborepo#8699 <!-- Donny/강동윤 - perf: Merge
multiple `EsmBinding` -->
* vercel/turborepo#8720 <!-- Benjamin Woodruff - Add
support for `#[turbo_tasks::value(resolved)]` and
`#[turbo_tasks::value_trait(resolved)]` -->
* vercel/turborepo#8706 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.96.9` -->

### What?

Update SWC crates to
swc-project/swc@226617e
and
swc-project/plugins@b7658c3

### Why?

To keep in sync

### How?

 - Closes #64890
 - Closes #63104
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
)

# Description

This removes the weakref from each `Arc`, which we weren't using, saving
64 bits per unique `RcStr`.

https://docs.rs/triomphe/latest/triomphe/struct.Arc.html

The difference in memory is too small to easily measure with heaptrack,
but it should be a small win regardless, and it's a drop-in replacement
that doesn't make the code any more complicated.

# Testing Instructions

Built using

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

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

```
cd ~/ui/apps/www
RUST_LOG=next_build_test=info 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 -100
```

## Heaptrack Before PR

```
total runtime: 135.14s.
calls to allocation functions: 49700807 (367770/s)
temporary memory allocations: 4126130 (30532/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.93M
suppressed leaks: 7.24K
```

```
total runtime: 138.50s.
calls to allocation functions: 49771465 (359355/s)
temporary memory allocations: 4410274 (31842/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 12.09M
suppressed leaks: 7.24K
```

## Heaptrack After PR

```
total runtime: 145.38s.
calls to allocation functions: 49714711 (341966/s)
temporary memory allocations: 4164393 (28645/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 11.67M
suppressed leaks: 7.24K
```

```
total runtime: 128.03s.
calls to allocation functions: 49739679 (388515/s)
temporary memory allocations: 4111893 (32117/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.88M
suppressed leaks: 7.24K
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
)

# Description

This removes the weakref from each `Arc`, which we weren't using, saving
64 bits per unique `RcStr`.

https://docs.rs/triomphe/latest/triomphe/struct.Arc.html

The difference in memory is too small to easily measure with heaptrack,
but it should be a small win regardless, and it's a drop-in replacement
that doesn't make the code any more complicated.

# Testing Instructions

Built using

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

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

```
cd ~/ui/apps/www
RUST_LOG=next_build_test=info 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 -100
```

## Heaptrack Before PR

```
total runtime: 135.14s.
calls to allocation functions: 49700807 (367770/s)
temporary memory allocations: 4126130 (30532/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.93M
suppressed leaks: 7.24K
```

```
total runtime: 138.50s.
calls to allocation functions: 49771465 (359355/s)
temporary memory allocations: 4410274 (31842/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 12.09M
suppressed leaks: 7.24K
```

## Heaptrack After PR

```
total runtime: 145.38s.
calls to allocation functions: 49714711 (341966/s)
temporary memory allocations: 4164393 (28645/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 11.67M
suppressed leaks: 7.24K
```

```
total runtime: 128.03s.
calls to allocation functions: 49739679 (388515/s)
temporary memory allocations: 4111893 (32117/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.88M
suppressed leaks: 7.24K
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
)

# Description

This removes the weakref from each `Arc`, which we weren't using, saving
64 bits per unique `RcStr`.

https://docs.rs/triomphe/latest/triomphe/struct.Arc.html

The difference in memory is too small to easily measure with heaptrack,
but it should be a small win regardless, and it's a drop-in replacement
that doesn't make the code any more complicated.

# Testing Instructions

Built using

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

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

```
cd ~/ui/apps/www
RUST_LOG=next_build_test=info 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 -100
```

## Heaptrack Before PR

```
total runtime: 135.14s.
calls to allocation functions: 49700807 (367770/s)
temporary memory allocations: 4126130 (30532/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.93M
suppressed leaks: 7.24K
```

```
total runtime: 138.50s.
calls to allocation functions: 49771465 (359355/s)
temporary memory allocations: 4410274 (31842/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 12.09M
suppressed leaks: 7.24K
```

## Heaptrack After PR

```
total runtime: 145.38s.
calls to allocation functions: 49714711 (341966/s)
temporary memory allocations: 4164393 (28645/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 11.67M
suppressed leaks: 7.24K
```

```
total runtime: 128.03s.
calls to allocation functions: 49739679 (388515/s)
temporary memory allocations: 4111893 (32117/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.88M
suppressed leaks: 7.24K
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
)

# Description

This removes the weakref from each `Arc`, which we weren't using, saving
64 bits per unique `RcStr`.

https://docs.rs/triomphe/latest/triomphe/struct.Arc.html

The difference in memory is too small to easily measure with heaptrack,
but it should be a small win regardless, and it's a drop-in replacement
that doesn't make the code any more complicated.

# Testing Instructions

Built using

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

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

```
cd ~/ui/apps/www
RUST_LOG=next_build_test=info 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 -100
```

## Heaptrack Before PR

```
total runtime: 135.14s.
calls to allocation functions: 49700807 (367770/s)
temporary memory allocations: 4126130 (30532/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.93M
suppressed leaks: 7.24K
```

```
total runtime: 138.50s.
calls to allocation functions: 49771465 (359355/s)
temporary memory allocations: 4410274 (31842/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 12.09M
suppressed leaks: 7.24K
```

## Heaptrack After PR

```
total runtime: 145.38s.
calls to allocation functions: 49714711 (341966/s)
temporary memory allocations: 4164393 (28645/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.75G
total memory leaked: 11.67M
suppressed leaks: 7.24K
```

```
total runtime: 128.03s.
calls to allocation functions: 49739679 (388515/s)
temporary memory allocations: 4111893 (32117/s)
peak heap memory consumption: 1.18G
peak RSS (including heaptrack overhead): 2.76G
total memory leaked: 11.88M
suppressed leaks: 7.24K
```
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 14, 2024
* vercel/turborepo#8686 <!-- Tobias Koppers -
improve performance of the graph aggregation -->
* vercel/turborepo#8694 <!-- Benjamin Woodruff -
Replace `unreachable` with `bail` in `finalize_css` -->
* vercel/turborepo#8661 <!-- Benjamin Woodruff -
Create a minimum viable `ResolvedVc` type -->
* vercel/turborepo#8662 <!-- Benjamin Woodruff - Add
a minimum viable ResolvedValue marker trait -->
* vercel/turborepo#8678 <!-- Benjamin Woodruff - Add
derive macro for ResolvedValue -->
* vercel/turborepo#8715 <!-- Benjamin Woodruff -
Switch RcStr from std::sync::Arc to triomphe::Arc -->
* vercel/turborepo#8699 <!-- Donny/강동윤 - perf: Merge
multiple `EsmBinding` -->
* vercel/turborepo#8720 <!-- Benjamin Woodruff - Add
support for `#[turbo_tasks::value(resolved)]` and
`#[turbo_tasks::value_trait(resolved)]` -->
* vercel/turborepo#8706 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.96.9` -->

Update SWC crates to
swc-project/swc@226617e
and
swc-project/plugins@b7658c3

To keep in sync

 - Closes #64890
 - Closes #63104
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 15, 2024
* vercel/turborepo#8686 <!-- Tobias Koppers -
improve performance of the graph aggregation -->
* vercel/turborepo#8694 <!-- Benjamin Woodruff -
Replace `unreachable` with `bail` in `finalize_css` -->
* vercel/turborepo#8661 <!-- Benjamin Woodruff -
Create a minimum viable `ResolvedVc` type -->
* vercel/turborepo#8662 <!-- Benjamin Woodruff - Add
a minimum viable ResolvedValue marker trait -->
* vercel/turborepo#8678 <!-- Benjamin Woodruff - Add
derive macro for ResolvedValue -->
* vercel/turborepo#8715 <!-- Benjamin Woodruff -
Switch RcStr from std::sync::Arc to triomphe::Arc -->
* vercel/turborepo#8699 <!-- Donny/강동윤 - perf: Merge
multiple `EsmBinding` -->
* vercel/turborepo#8720 <!-- Benjamin Woodruff - Add
support for `#[turbo_tasks::value(resolved)]` and
`#[turbo_tasks::value_trait(resolved)]` -->
* vercel/turborepo#8706 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.96.9` -->

Update SWC crates to
swc-project/swc@226617e
and
swc-project/plugins@b7658c3

To keep in sync

 - Closes #64890
 - Closes #63104
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 16, 2024
* vercel/turborepo#8686 <!-- Tobias Koppers -
improve performance of the graph aggregation -->
* vercel/turborepo#8694 <!-- Benjamin Woodruff -
Replace `unreachable` with `bail` in `finalize_css` -->
* vercel/turborepo#8661 <!-- Benjamin Woodruff -
Create a minimum viable `ResolvedVc` type -->
* vercel/turborepo#8662 <!-- Benjamin Woodruff - Add
a minimum viable ResolvedValue marker trait -->
* vercel/turborepo#8678 <!-- Benjamin Woodruff - Add
derive macro for ResolvedValue -->
* vercel/turborepo#8715 <!-- Benjamin Woodruff -
Switch RcStr from std::sync::Arc to triomphe::Arc -->
* vercel/turborepo#8699 <!-- Donny/강동윤 - perf: Merge
multiple `EsmBinding` -->
* vercel/turborepo#8720 <!-- Benjamin Woodruff - Add
support for `#[turbo_tasks::value(resolved)]` and
`#[turbo_tasks::value_trait(resolved)]` -->
* vercel/turborepo#8706 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.96.9` -->

Update SWC crates to
swc-project/swc@226617e
and
swc-project/plugins@b7658c3

To keep in sync

 - Closes #64890
 - Closes #63104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants