Skip to content

feat(pack): support mdx option#2858

Merged
fireairforce merged 4 commits intonextfrom
support-mdx-rs
Apr 28, 2026
Merged

feat(pack): support mdx option#2858
fireairforce merged 4 commits intonextfrom
support-mdx-rs

Conversation

@fireairforce
Copy link
Copy Markdown
Member

Summary

Align with umi's: https://github.com/umijs/umi/blob/master/packages/bundler-webpack/src/config/javaScriptRules.ts#L200-L207

And mako's: https://makojs.dev/docs/config#mdx

Default is false, not enable.

Test Plan

add snapshot test case

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 Rust-based MDX transformations across the codebase. Key changes include updating the core configuration structures, integrating MDX options into both client and server module contexts, and expanding the public schema in Rust, TypeScript, and JSON formats to support MDX settings. Additionally, a new snapshot test has been added to verify basic MDX compilation. Feedback focuses on critical serialization issues in the Config struct; specifically, the mdx field requires serde_self_describing for bincode compatibility, and the MdxOptions enum needs to derive Serialize instead of Encode/Decode to prevent compilation failures.

Comment thread crates/pack-core/src/config.rs
Comment thread crates/pack-core/src/config.rs
fireairforce and others added 4 commits April 28, 2026 18:09
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

📊 Performance Benchmark Report (with-antd)

Utoopack Performance Report

Report ID: utoopack_performance_report_20260428_103442
Generated: 2026-04-28 10:34:42
Trace File: trace_antd.json (0.5GB, 1.57M spans)
Test Project: examples/with-antd


Executive Summary

Metric Value Assessment
Total Wall Time 11,274.6 ms Baseline
Total Thread Work (de-duped) 33,560.2 ms Non-overlapping busy time
Effective Parallelism 3.0x thread_work / wall_time
Working Threads 5 Threads with actual spans
Thread Utilization 59.5% ⚠️ Suboptimal
Total Spans 1,570,063 All B/E + X events
Meaningful Spans (>= 10us) 375,306 (23.9% of total)
Tracing Noise (< 10us) 1,194,757 (76.1% 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 82,833 5,377.8 4,248.6 7,757.5
Parse 10,367 3,696.2 2,756.9 11,129.6
Analyze 221,462 22,991.0 16,512.1 10,790.5
Chunk 22,136 1,817.2 1,696.7 8,563.7
Codegen 29,598 3,921.5 2,911.2 8,739.8
Emit 38 30.6 15.2 8,650.1
Other 8,872 1,486.5 1,200.7 11,274.5

Workload Distribution by Diagnostic Tier

Category Spans Inclusive (ms) % Work Self-Time (ms) % Self
P0: Scheduling & Resolution 310,668 29,338.2 87.4% 21,458.8 63.9%
P1: I/O & Heavy Tasks 2,936 799.1 2.4% 783.7 2.3%
P2: Architecture (Locks/Memory) 0 0.0 0.0% 0.0 0.0%
P3: Asset Pipeline 60,583 8,748.3 26.1% 6,678.1 19.9%
P4: Bridge/Interop 0 0.0 0.0% 0.0 0.0%
Other 1,119 435.3 1.3% 420.7 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
9,768.2 11,451.4 118,829 82.2 0.1 28.0 29.1% module write all entrypoints to disk (2%)
3,765.1 5,295.5 35,341 106.5 0.2 186.4 11.2% analyze ecmascript module process module (79%)
2,298.7 2,493.7 45,489 50.5 0.0 20.8 6.8% internal resolving resolving (30%)
2,134.9 5,376.7 57,379 37.2 0.0 20.8 6.4% process module module (10%)
1,927.8 2,862.1 36,787 52.4 0.0 20.9 5.7% resolving module (16%)
1,762.6 2,491.5 7,297 241.5 0.7 50.6 5.3% parse ecmascript analyze ecmascript module (31%)
1,688.7 2,699.0 17,512 96.4 0.4 61.3 5.0% code generation chunking (2%)
1,075.6 1,173.8 12,834 83.8 0.2 22.6 3.2% chunking write all entrypoints to disk (0%)
912.8 912.8 10,004 91.2 0.3 9.1 2.7% precompute code generation code generation (58%)
746.3 746.3 2,335 319.6 2.3 19.1 2.2% read file parse ecmascript (91%)
744.2 1,006.8 7,139 104.2 0.0 136.8 2.2% write all entrypoints to disk None (0%)
740.7 740.7 7,825 94.7 0.4 67.3 2.2% compute async module info chunking (0%)
603.8 604.3 9,199 65.6 0.1 42.3 1.8% compute async chunks webpack loader (0%)
378.3 386.2 1,007 375.7 1.8 18.3 1.1% webpack loader parse css (15%)
309.7 309.7 2,082 148.8 0.4 15.9 0.9% generate source map code generation (96%)
247.9 458.4 729 340.0 1.4 24.1 0.7% parse css module (6%)
59.8 59.8 823 72.6 0.0 13.6 0.2% compute binding usage info write all entrypoints to disk (0%)
35.8 44.4 614 58.4 0.1 6.0 0.1% async reference write all entrypoints to disk (1%)
29.8 29.8 1,243 23.9 0.0 7.1 0.1% collect mergeable modules compute merged modules (0%)
22.1 22.1 557 39.7 0.0 12.0 0.1% read directory internal resolving (99%)

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 186.5 2 process module → analyze ecmascript module
2 77.3 2 code generation → generate source map
3 69.1 2 process module → analyze ecmascript module
4 68.8 2 code generation → generate source map
5 50.7 2 analyze ecmascript module → parse ecmascript

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,341 process module (79%) 106.5 us 0.16 ms 3,765.1 ms

Duration Distribution

Range Count Percentage
<10us 1,194,757 76.1%
10us-100us 348,950 22.2%
100us-1ms 20,159 1.3%
1ms-10ms 5,790 0.4%
10ms-100ms 403 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 0fcbf40 into next Apr 28, 2026
33 checks passed
@fireairforce fireairforce deleted the support-mdx-rs branch April 28, 2026 11:28
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