Skip to content

fix(pack): script external export compitable#2828

Merged
fireairforce merged 1 commit intonextfrom
fix-script-externals-export
Apr 27, 2026
Merged

fix(pack): script external export compitable#2828
fireairforce merged 1 commit intonextfrom
fix-script-externals-export

Conversation

@fireairforce
Copy link
Copy Markdown
Member

Summary

update from: utooland/next.js#141

Test Plan

updated

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the runtime logic for external modules to use namespace objects and modifies script loading to use an unconditional cross-origin assignment. It also adds jszip as an external dependency and updates the next.js subproject. Feedback suggests that the unconditional cross-origin assignment could lead to incorrect CORS behavior and that for...in loops used for module property copying should be replaced with safer alternatives like Object.keys to avoid prototype pollution.

Comment thread crates/pack-tests/tests/snapshot/public_path/basic/output/main.js
@fireairforce fireairforce requested a review from yuzheng14 April 27, 2026 05:26
@github-actions
Copy link
Copy Markdown

📊 Performance Benchmark Report (with-antd)

Utoopack Performance Report

Report ID: utoopack_performance_report_20260427_053515
Generated: 2026-04-27 05:35:15
Trace File: trace_antd.json (0.6GB, 1.62M spans)
Test Project: examples/with-antd


Executive Summary

Metric Value Assessment
Total Wall Time 11,271.9 ms Baseline
Total Thread Work (de-duped) 36,052.3 ms Non-overlapping busy time
Effective Parallelism 3.2x thread_work / wall_time
Working Threads 5 Threads with actual spans
Thread Utilization 64.0% 🆗 Average
Total Spans 1,624,923 All B/E + X events
Meaningful Spans (>= 10us) 381,165 (23.5% of total)
Tracing Noise (< 10us) 1,243,758 (76.5% of total)

Build Phase Timeline

Shows when each build phase is active and how much CPU it consumes.
Self-Time is the time spent exclusively in that phase (excluding children).

Phase Spans Inclusive (ms) Self-Time (ms) Wall Range (ms)
Resolve 84,053 5,845.3 4,768.0 8,386.6
Parse 10,224 2,827.2 2,321.4 11,136.6
Analyze 224,572 25,211.7 18,238.9 10,886.9
Chunk 22,898 2,202.8 2,056.6 8,713.2
Codegen 30,123 4,433.8 3,278.2 8,796.2
Emit 38 42.9 21.3 8,708.6
Other 9,257 1,417.9 1,140.6 11,271.9

Workload Distribution by Diagnostic Tier

Category Spans Inclusive (ms) % Work Self-Time (ms) % Self
P0: Scheduling & Resolution 315,308 31,939.4 88.6% 23,629.2 65.5%
P1: I/O & Heavy Tasks 3,051 327.4 0.9% 305.8 0.8%
P2: Architecture (Locks/Memory) 0 0.0 0.0% 0.0 0.0%
P3: Asset Pipeline 61,719 9,241.7 25.6% 7,434.1 20.6%
P4: Bridge/Interop 0 0.0 0.0% 0.0 0.0%
Other 1,087 473.1 1.3% 455.8 1.3%

Top 20 Tasks by Self-Time

Self-time is the exclusive duration: time spent in the task itself, not in sub-tasks.
This is the most accurate indicator of where CPU cycles are actually spent.

Self (ms) Inclusive (ms) Count Avg Self (us) P95 Self (ms) Max Self (ms) % Work Task Name Top Caller
10,674.2 12,514.1 121,575 87.8 0.1 43.0 29.6% module write all entrypoints to disk (1%)
4,246.8 5,724.3 36,356 116.8 0.2 175.2 11.8% analyze ecmascript module process module (79%)
2,666.6 2,847.4 46,069 57.9 0.0 17.5 7.4% internal resolving resolving (29%)
2,491.1 6,120.6 57,059 43.7 0.0 17.4 6.9% process module module (10%)
2,088.1 2,984.7 37,315 56.0 0.0 25.9 5.8% resolving module (15%)
1,857.2 3,012.8 17,913 103.7 0.4 50.8 5.2% code generation chunking (2%)
1,708.9 1,968.0 7,154 238.9 0.7 58.3 4.7% parse ecmascript analyze ecmascript module (31%)
1,550.5 1,672.8 12,995 119.3 0.3 148.1 4.3% chunking write all entrypoints to disk (0%)
1,065.5 1,065.5 10,127 105.2 0.3 10.3 3.0% precompute code generation code generation (56%)
733.5 733.5 6,924 105.9 0.4 71.0 2.0% compute async module info chunking (0%)
657.9 914.5 7,632 86.2 0.0 118.8 1.8% write all entrypoints to disk None (0%)
484.3 484.8 9,797 49.4 0.0 35.1 1.3% compute async chunks webpack loader (0%)
412.7 423.4 979 421.5 1.8 22.1 1.1% webpack loader parse css (13%)
355.5 355.5 2,083 170.7 0.5 18.5 1.0% generate source map code generation (96%)
341.2 588.0 726 470.0 2.4 32.1 0.9% parse css module (7%)
271.2 271.2 2,338 116.0 0.2 15.1 0.8% read file parse ecmascript (91%)
49.2 49.2 818 60.1 0.0 8.4 0.1% compute binding usage info write all entrypoints to disk (0%)
27.9 27.9 1,810 15.4 0.0 6.2 0.1% collect mergeable modules compute merged modules (0%)
26.8 30.3 538 49.9 0.1 5.2 0.1% async reference write all entrypoints to disk (1%)
21.8 45.2 106 205.3 0.5 13.9 0.1% make production chunks chunking (4%)

Critical Path Analysis

The longest sequential dependency chains that determine wall-clock time.
Focus on reducing the depth of these chains to improve parallelism.

Rank Self-Time (ms) Depth Path
1 175.2 2 process module → analyze ecmascript module
2 87.1 2 process module → analyze ecmascript module
3 69.3 2 code generation → generate source map
4 58.3 2 analyze ecmascript module → parse ecmascript
5 46.5 2 process module → analyze ecmascript module

Batching Candidates

High-volume tasks dominated by a single parent. If the parent can batch them,
it drastically reduces scheduler overhead.

Task Name Count Top Caller (Attribution) Avg Self P95 Self Total Self
analyze ecmascript module 36,356 process module (79%) 116.8 us 0.16 ms 4,246.8 ms

Duration Distribution

Range Count Percentage
<10us 1,243,758 76.5%
10us-100us 355,642 21.9%
100us-1ms 18,890 1.2%
1ms-10ms 6,194 0.4%
10ms-100ms 434 0.0%
>100ms 5 0.0%

Action Items

  1. [P0] Focus on tasks with the highest Self-Time — these are where CPU cycles are actually spent.
  2. [P0] Use Batching Candidates to identify callers that should use try_join or reduce #[turbo_tasks::function] granularity.
  3. [P1] Check Build Phase Timeline for phases with disproportionate wall range vs. self-time (= serialization).
  4. [P1] Inspect P95 Self (ms) for heavy monolith tasks. Focus on long-tail outliers, not averages.
  5. [P1] Review Critical Paths — reducing the longest chain depth directly improves wall-clock time.
  6. [P2] If Thread Utilization < 60%, investigate scheduling gaps (lock contention or deep dependency chains).

Report generated by Utoopack Performance Analysis Agent

@fireairforce fireairforce merged commit 9e67a0c into next Apr 27, 2026
33 checks passed
@fireairforce fireairforce deleted the fix-script-externals-export branch April 27, 2026 06:13
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