Unverified Commit 76117ccd authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Tune Node server chunking for require overhead (#99120)

### What?

Tune production Node.js server JavaScript chunking to use a lower
estimated cost for loading a chunk, a smaller soft minimum chunk size,
and no per-group chunk-count target. Client, CSS, Edge, and development
chunking remain unchanged.

### Why?

Server chunks are loaded with Node.js `require()`, not network requests.
Measurements across synthetic JavaScript chunks found roughly 0.1 ms of
fixed load overhead, equivalent to approximately 2.5–25 KB of parsing
work depending on code density. The existing 200 KB estimate overweights
each server-side load and encourages unnecessary merging.

### How?

Apply the server-specific tuning to both Node production chunking
contexts while keeping the existing maximum merge size. The values are
an initial estimate from the benchmark; representative application
builds and cold-start measurements can refine them.

### Verification

- `cargo fmt --manifest-path crates/next-core/Cargo.toml -- --check` —
passed.
- `git diff --check` and checks of both Node contexts and unchanged Edge
values — passed.
- `cargo check -p next-core --offline` — blocked before compilation by
an uncached `bgw/bincode` Git dependency.

<!-- NEXT_JS_LLM -->


<!-- fleet 8b0bc78c-72fb-424d-a85e-c5a5b87ff5f4 -->
Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 5ca62ef4
......@@ -1118,9 +1118,11 @@ pub async fn get_server_chunking_context_with_client_assets(
.chunking_config(
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
ChunkingConfig {
min_chunk_size: 20_000,
max_chunk_count_per_group: 100,
// Server chunks are loaded with require(), not fetched over the network.
min_chunk_size: 4_000,
max_chunk_count_per_group: 0,
max_merge_chunk_size: 100_000,
request_cost: Some(10_000),
..Default::default()
},
)
......@@ -1227,9 +1229,11 @@ pub async fn get_server_chunking_context(
.chunking_config(
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
ChunkingConfig {
min_chunk_size: 20_000,
max_chunk_count_per_group: 100,
// Server chunks are loaded with require(), not fetched over the network.
min_chunk_size: 4_000,
max_chunk_count_per_group: 0,
max_merge_chunk_size: 100_000,
request_cost: Some(10_000),
..Default::default()
},
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment