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

Chunking Context Refactor pt. 3: Address PR comments from pt. 2 #4546

Merged

Conversation

alexkirsz
Copy link
Contributor

@alexkirsz alexkirsz commented Apr 12, 2023

Description

This PR does two things, addressing related comments from #4450:

  1. Replace ChunkReferenceVc and ParallelChunkReferenceVc with Chunk::parallel_chunks.
  2. Moves all non-generic optimization logic out of turbopack-core and into turbopack-dev. These optimization methods are very specific to a development environment, and turbopack-build will have different ones.

Testing Instructions

Snapshots
link WEB-891

@vercel
Copy link

vercel bot commented Apr 12, 2023

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

Name Status Preview Comments Updated (UTC)
examples-cra-web 🔄 Building (Inspect) Apr 14, 2023 2:55pm
examples-tailwind-web 🔄 Building (Inspect) Apr 14, 2023 2:55pm
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 14, 2023 2:55pm
8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-gatsby-web ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-native-web ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-nonmonorepo ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-svelte-web ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm
examples-vite-web ⬜️ Ignored (Inspect) Apr 14, 2023 2:55pm

@github-actions
Copy link
Contributor

✅ This changes can build next-swc

@github-actions
Copy link
Contributor

github-actions bot commented Apr 12, 2023

🟢 CI successful 🟢

Thanks

@alexkirsz alexkirsz force-pushed the alexkirsz/web-891-step-3-address-pr-comments-from-step-2 branch 2 times, most recently from 2ed14e8 to e8830f3 Compare April 12, 2023 13:33
optimize_ecmascript_chunks(EcmascriptChunksVc::cell(ecmascript_chunks)).await?;
let css_chunks = optimize_css_chunks(CssChunksVc::cell(css_chunks)).await?;

let chunks = ecmascript_chunks
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This creates an explicit order between JS and CSS chunks in the output asset list, which causes the changes in snapshots.

#[turbo_tasks::value_trait]
pub trait OptimizableChunk: Chunk + Asset {
fn get_optimizer(&self) -> ChunkOptimizerVc;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer relevant, as the chunking context has to know about all the different chunk types it can handle anyway. So instead of the chunks themselves implementing this trait, it's the chunking context which resolves chunks to particular types, and optimizes them accordingly.

@alexkirsz alexkirsz marked this pull request as ready for review April 12, 2023 13:37
@alexkirsz alexkirsz requested a review from a team as a code owner April 12, 2023 13:37
}

fn skip_unnessary_nodes<T>(trees: &mut IndexMap<FileSystemPathVc, Rc<RefCell<Node<T>>>>) {
for tree in trees.values_mut() {
Copy link
Member

Choose a reason for hiding this comment

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

values_mut is a bit confusing.

Copy link
Member

Choose a reason for hiding this comment

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

I was checking if let mut tree = tree.get_mut() will work at the line below

@@ -0,0 +1,220 @@
use std::{cell::RefCell, mem::take, rc::Rc};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was extracted from turbopack_core::chunk::optimize. The only difference is that the tree now operates on a generic T type instead of ChunkVc.

@alexkirsz alexkirsz force-pushed the alexkirsz/web-891-step-3-address-pr-comments-from-step-2 branch from e8830f3 to 92f5e52 Compare April 14, 2023 14:54
@alexkirsz alexkirsz added the pr: automerge Kodiak will merge these automatically after checks pass label Apr 14, 2023
@github-actions
Copy link
Contributor

Benchmark for 33edc64

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9768.03µs ± 36.35µs 9654.87µs ± 43.69µs -1.16%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8641.49µs ± 58.18µs 8817.10µs ± 86.18µs +2.03%
bench_startup/Turbopack CSR/1000 modules 901.11ms ± 2.37ms 893.15ms ± 3.91ms -0.88%

@kodiakhq kodiakhq bot merged commit c604be7 into main Apr 14, 2023
@kodiakhq kodiakhq bot deleted the alexkirsz/web-891-step-3-address-pr-comments-from-step-2 branch April 14, 2023 15:31
sokra added a commit that referenced this pull request Apr 14, 2023
sokra added a commit that referenced this pull request Apr 14, 2023
sokra added a commit to vercel/next.js that referenced this pull request Apr 14, 2023
### What?

gives user code access to `process.env.PORT` as current server port
avoid injecting env vars into code on server

### Why?

it might need construct an addr to fetch from api routes

fixes WEB-868

### Turbopack changes

* vercel/turborepo#4565 <!-- Tobias Koppers - Bind
to IPv6 and IPv4 -->
* vercel/turborepo#4570 <!-- Tobias Koppers - review
follow ups -->
* vercel/turborepo#4585 <!-- Tobias Koppers - fixup
bind v6 PR: add missing listen call -->
* ~vercel/turborepo#4546 <!-- Alex Kirszenberg -
Chunking Context Refactor pt. 3: Address PR comments from pt. 2 -->
* vercel/turborepo#4580 <!-- Tobias Koppers - remove
circular dependency -->
* vercel/turborepo#4582 <!-- Tobias Koppers - ignore
internal and server-relative url() in CSS -->
* vercel/turborepo#4579 <!-- Tobias Koppers - make
node bootstrap asset lazy -->
* vercel/turborepo#4581 <!-- Tobias Koppers - allow
to create stress test for client components -->
* vercel/turborepo#4584 <!-- Tobias Koppers -
improve node.js receive timeout -->
* vercel/turborepo#4583 <!-- Tobias Koppers - remove
panic since this might happen due to eventual consistency -->

fixes WEB-871
kodiakhq bot pushed a commit that referenced this pull request Apr 18, 2023
See #4546 for the first attempt.

This causes Next.js tests to fail. ~~Currently figuring out what's
wrong.~~

This surfaced an existing issue in our chunk optimization logic, where
chunks of different chunking contexts (SSR and RSC) would be merged
together, leading to invalid module ids.

link WEB-891
NicholasLYang pushed a commit to NicholasLYang/turbo that referenced this pull request Apr 21, 2023
…el#4546)

### Description

This PR does two things, addressing related comments from
vercel#4450:
1. Replace `ChunkReferenceVc` and `ParallelChunkReferenceVc` with
`Chunk::parallel_chunks`.
2. Moves all non-generic optimization logic out of `turbopack-core` and
into `turbopack-dev`. These optimization methods are very specific to a
development environment, and `turbopack-build` will have different ones.

### Testing Instructions

Snapshots
link WEB-891
NicholasLYang pushed a commit to NicholasLYang/turbo that referenced this pull request Apr 21, 2023
NicholasLYang pushed a commit to NicholasLYang/turbo that referenced this pull request Apr 21, 2023
…el#4601)

See vercel#4546 for the first attempt.

This causes Next.js tests to fail. ~~Currently figuring out what's
wrong.~~

This surfaced an existing issue in our chunk optimization logic, where
chunks of different chunking contexts (SSR and RSC) would be merged
together, leading to invalid module ids.

link WEB-891
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
…el/turborepo#4546)

### Description

This PR does two things, addressing related comments from
vercel/turborepo#4450:
1. Replace `ChunkReferenceVc` and `ParallelChunkReferenceVc` with
`Chunk::parallel_chunks`.
2. Moves all non-generic optimization logic out of `turbopack-core` and
into `turbopack-dev`. These optimization methods are very specific to a
development environment, and `turbopack-build` will have different ones.

### Testing Instructions

Snapshots
link WEB-891
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
…el/turborepo#4601)

See vercel/turborepo#4546 for the first attempt.

This causes Next.js tests to fail. ~~Currently figuring out what's
wrong.~~

This surfaced an existing issue in our chunk optimization logic, where
chunks of different chunking contexts (SSR and RSC) would be merged
together, leading to invalid module ids.

link WEB-891
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
…el/turborepo#4546)

### Description

This PR does two things, addressing related comments from
vercel/turborepo#4450:
1. Replace `ChunkReferenceVc` and `ParallelChunkReferenceVc` with
`Chunk::parallel_chunks`.
2. Moves all non-generic optimization logic out of `turbopack-core` and
into `turbopack-dev`. These optimization methods are very specific to a
development environment, and `turbopack-build` will have different ones.

### Testing Instructions

Snapshots
link WEB-891
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
…el/turborepo#4601)

See vercel/turborepo#4546 for the first attempt.

This causes Next.js tests to fail. ~~Currently figuring out what's
wrong.~~

This surfaced an existing issue in our chunk optimization logic, where
chunks of different chunking contexts (SSR and RSC) would be merged
together, leading to invalid module ids.

link WEB-891
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
…el/turborepo#4546)

### Description

This PR does two things, addressing related comments from
vercel/turborepo#4450:
1. Replace `ChunkReferenceVc` and `ParallelChunkReferenceVc` with
`Chunk::parallel_chunks`.
2. Moves all non-generic optimization logic out of `turbopack-core` and
into `turbopack-dev`. These optimization methods are very specific to a
development environment, and `turbopack-build` will have different ones.

### Testing Instructions

Snapshots
link WEB-891
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
…el/turborepo#4601)

See vercel/turborepo#4546 for the first attempt.

This causes Next.js tests to fail. ~~Currently figuring out what's
wrong.~~

This surfaced an existing issue in our chunk optimization logic, where
chunks of different chunking contexts (SSR and RSC) would be merged
together, leading to invalid module ids.

link WEB-891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants