perf(wasm): sync init wasm in thread worker#2547
Conversation
Summary of ChangesHello @xusd320, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on optimizing WebAssembly integration within worker threads by transitioning from an asynchronous to a synchronous initialization method. This change aims to enhance the reliability and performance of worker thread spawning. Accompanying this core modification are various dependency updates to ensure compatibility and leverage the latest versions of underlying libraries. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the WebAssembly initialization in threadWorker.ts to use a synchronous function, initSync, which is crucial for supporting worker thread spawning as described. This change aligns with the stated goal of improving WASM performance in thread workers. The Cargo.lock file has been updated to reflect new dependency versions, including specific git references for tokio and wasm_thread forks, and some dependency downgrades.
| "windows-sys 0.52.0", | ||
| "windows-sys 0.59.0", |
There was a problem hiding this comment.
The stacker package now lists two different versions of windows-sys (0.52.0 and 0.59.0) as dependencies. This can lead to increased binary size and potential runtime conflicts due to multiple versions of the same crate being linked. It is best practice to consolidate to a single compatible version of a dependency across the project to avoid such issues. Please resolve this to use a single version of windows-sys for the stacker package.
"windows-sys 0.59.0",
📊 Performance Benchmark Report (with-antd)🚀 Utoopack Performance Report: Async Task Scheduling Overhead AnalysisReport ID: 📊 Executive SummaryThis report analyzes the performance of Utoopack/Turbopack, covering the full spectrum of the Performance Analysis Protocol (P0-P4). Key Findings
Workload Distribution by Tier
⚡ Parallelization Analysis (P0-P2)Thread Utilization
Assessment: With 11 threads available, achieving 8.6x parallelism indicates reasonable throughput. 📈 Top 20 Tasks (Global)These are the most significant tasks by total duration:
🔍 Deep Dive by Tier🔴 Tier 1: Runtime & Resolution (P0)Focus: Task scheduling and dependency resolution.
Potential P0 Issues:
🟠 Tier 2: Physical & Resource Barriers (P1)Focus: Hardware utilization, I/O, and heavy monoliths.
Potential P1 Issues:
🟡 Tier 3: Architecture & Asset Pipeline (P2-P3)Focus: Global state and transformation pipeline.
💡 Recommendations (Prioritized P0-P2)🚨 Critical: (P0) ImprovementProblem: 78.4% thread utilization.
|
| Signal | Status | Finding |
|---|---|---|
| Tracing Noise (P0) | 60.2% of tasks < 10µs | |
| Thread Utilization (P0) | ✅ Good | 78.4% utilization |
| Heavy Monoliths (P1) | 16 tasks > 100ms | |
| Asset Pipeline (P3) | 🔍 Review | 4,573.3 ms total |
| Bridge/Interop (P4) | ✅ Low | 0.0 ms total |
🎯 Action Items (Comprehensive P0-P4)
- [P0] Investigate task scheduling gaps for incremental gains
- [P1] Breakdown heavy monolith tasks (>100ms) to improve granularity
- [P1] Review I/O patterns for potential batching opportunities
- [P3] Optimize asset transformation pipeline hot-spots
- [P4] Reduce "chatty" bridge operations if interop overhead is significant
Report generated by Utoopack Performance Analysis Agent on 2026-01-27
Following: Utoopack Performance Analysis Agent Protocol
Fellow #2540
This pull request makes a minor update to how WebAssembly initialization is handled in the
threadWorker.tsfile. The change replaces the asynchronous initialization function with a synchronous one to better support worker thread spawning.initWasmwith the synchronous initialization functioninitSyncfromutoo, and updated the assignment ofwasm_bindgenaccordingly inthreadWorker.ts.