Skip to content

feat(pack): support externalType: promise#2857

Merged
fireairforce merged 2 commits into
nextfrom
support-external-promise
Apr 28, 2026
Merged

feat(pack): support externalType: promise#2857
fireairforce merged 2 commits into
nextfrom
support-external-promise

Conversation

@fireairforce
Copy link
Copy Markdown
Member

Summary

ref: utooland/next.js#142

For business support:

image

Test Plan

add snapshot test.

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 introduces support for "promise" type externals across the core Rust logic, configuration schemas, and TypeScript compatibility layers. Key changes include adding the "promise" variant to external type enums, updating resolution logic to handle the "promise" prefix, and implementing a new snapshot test. Feedback suggests using the matches! macro in tests for better conciseness and refactoring duplicated logic in the Webpack compatibility module to improve maintainability.

Comment thread crates/pack-core/src/config.rs
Comment thread packages/pack-shared/src/webpackCompat.ts
@github-actions
Copy link
Copy Markdown

📊 Performance Benchmark Report (with-antd)

Utoopack Performance Report

Report ID: utoopack_performance_report_20260428_081754
Generated: 2026-04-28 08:17:54
Trace File: trace_antd.json (0.5GB, 1.57M spans)
Test Project: examples/with-antd


Executive Summary

Metric Value Assessment
Total Wall Time 11,392.5 ms Baseline
Total Thread Work (de-duped) 21,462.3 ms Non-overlapping busy time
Effective Parallelism 1.9x thread_work / wall_time
Working Threads 5 Threads with actual spans
Thread Utilization 37.7% ⚠️ Suboptimal
Total Spans 1,567,470 All B/E + X events
Meaningful Spans (>= 10us) 361,094 (23.0% of total)
Tracing Noise (< 10us) 1,206,376 (77.0% 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 79,671 2,178.1 1,754.2 8,317.7
Parse 9,861 1,823.3 1,535.4 11,266.4
Analyze 213,986 12,872.8 8,686.8 11,022.9
Chunk 19,812 1,690.2 1,559.2 8,337.6
Codegen 28,596 3,804.3 2,819.2 8,485.8
Emit 39 42.6 21.2 7,571.4
Other 9,129 1,194.5 1,040.4 11,392.5

Workload Distribution by Diagnostic Tier

Category Spans Inclusive (ms) % Work Self-Time (ms) % Self
P0: Scheduling & Resolution 300,177 15,829.2 73.8% 11,082.7 51.6%
P1: I/O & Heavy Tasks 3,045 165.3 0.8% 144.0 0.7%
P2: Architecture (Locks/Memory) 0 0.0 0.0% 0.0 0.0%
P3: Asset Pipeline 56,764 7,258.0 33.8% 5,854.0 27.3%
P4: Bridge/Interop 0 0.0 0.0% 0.0 0.0%
Other 1,108 353.2 1.6% 335.7 1.6%

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
4,413.5 5,234.9 114,015 38.7 0.1 11.1 20.6% module write all entrypoints to disk (1%)
2,474.8 3,494.8 35,595 69.5 0.1 178.5 11.5% analyze ecmascript module process module (80%)
1,618.9 2,604.0 16,820 96.2 0.4 44.6 7.5% code generation chunking (1%)
1,134.3 1,249.4 6,959 163.0 0.6 36.3 5.3% parse ecmascript analyze ecmascript module (32%)
1,036.0 3,354.7 55,751 18.6 0.0 6.2 4.8% process module module (9%)
1,022.9 1,100.3 44,550 23.0 0.0 8.0 4.8% internal resolving resolving (29%)
991.5 1,100.8 11,679 84.9 0.2 21.5 4.6% chunking write all entrypoints to disk (0%)
841.5 841.5 9,694 86.8 0.3 7.4 3.9% precompute code generation code generation (58%)
724.0 1,070.4 34,461 21.0 0.0 6.0 3.4% resolving module (11%)
669.6 801.9 7,453 89.8 0.0 108.5 3.1% write all entrypoints to disk None (0%)
667.1 667.1 6,783 98.4 0.4 57.4 3.1% compute async module info chunking (0%)
547.1 547.4 8,044 68.0 0.0 32.3 2.5% compute async chunks write all entrypoints to disk (0%)
358.8 358.8 2,082 172.3 0.4 16.8 1.7% generate source map code generation (96%)
296.1 306.3 1,010 293.2 1.4 14.0 1.4% webpack loader parse css (11%)
285.7 458.4 556 513.8 2.4 61.5 1.3% parse css module (8%)
115.4 115.4 2,341 49.3 0.2 3.1 0.5% read file parse ecmascript (91%)
55.6 55.6 841 66.2 0.0 11.2 0.3% compute binding usage info write all entrypoints to disk (0%)
35.1 39.4 568 61.7 0.1 6.2 0.2% async reference write all entrypoints to disk (1%)
24.3 24.3 979 24.8 0.0 6.3 0.1% collect mergeable modules compute merged modules (0%)
20.8 20.8 36 578.1 3.1 6.6 0.1% write file apply effects (100%)

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 178.6 2 process module → analyze ecmascript module
2 97.4 2 process module → analyze ecmascript module
3 64.2 2 module → parse css
4 61.4 2 code generation → generate source map
5 41.0 2 code generation → generate source map

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 35,595 process module (80%) 69.5 us 0.14 ms 2,474.8 ms

Duration Distribution

Range Count Percentage
<10us 1,206,376 77.0%
10us-100us 338,803 21.6%
100us-1ms 18,478 1.2%
1ms-10ms 3,712 0.2%
10ms-100ms 97 0.0%
>100ms 4 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 2075e32 into next Apr 28, 2026
33 checks passed
@fireairforce fireairforce deleted the support-external-promise branch April 28, 2026 08:47
elrrrrrrr added a commit that referenced this pull request Apr 29, 2026
Resolves overlap with merged upstream PRs:
- #2856 rustls + aws-lc-rs (gated to macOS only, prevents Linux regression)
- #2862 single-flight manifest fetches via OnceMap (full Result-aware variant)
- #2824 pm-e2e-bench unified workflow + phase-isolated bench infrastructure
- #2858 mdx option, #2857 externalType: promise, #2829 sync next.js

Resolution choices:
- Cargo.toml: keep next's macOS-only aws-lc-rs gating (validated by #2856 to
  avoid Linux/x86_64 CI regression). Add crossbeam-queue for the worker-pool
  SegQueue. Keep rt-multi-thread test feature for worker-pool tests.
- util/oncemap.rs + util/mod.rs: take next's superset (adds get_or_try_init,
  Debug impl, refined failure semantics).
- service/* + model/manifest.rs + traits/registry.rs: keep PR's worker-pool
  API surface — its preload.rs depends on these shapes for the FuturesUnordered
  -> worker-pool migration.
- Drop redundant `use utoo_ruborist::util::oncemap::OnceMap;` lines in
  pm/util/{cloner,downloader}.rs after import-path consolidation.

cargo clippy --all-targets -- -D warnings clean for utoo-pm + utoo-ruborist
cargo test passes: 245 pm + 167 ruborist + 10 doctests
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