Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions crates/utoo-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ wasm-bindgen-futures = "0.4.54"
## turbpack specific - conditional on utoo-pack feature
pack-api = { workspace = true, optional = true }
pack-core = { workspace = true, optional = true }
parking_lot = { workspace = true, features = ["nightly"] }
turbo-rcstr = { workspace = true, optional = true }
turbo-tasks = { workspace = true, optional = true }
turbo-tasks-backend = { workspace = true, optional = true }
turbo-tasks-fs = { workspace = true, optional = true }
turbo-tasks-malloc = { workspace = true, default-features = false, features = ["custom_allocator"] }
turbopack-core = { workspace = true, optional = true }
turbopack-node = { workspace = true, optional = true, default-features = false, features = ["worker_pool"] }

[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
parking_lot = { workspace = true, features = ["nightly"] }
3 changes: 3 additions & 0 deletions crates/utoo-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ mod project;
pub(crate) mod tokio_runtime;
pub use project::Project;

#[global_allocator]
static ALLOC: turbo_tasks_malloc::TurboMalloc = turbo_tasks_malloc::TurboMalloc;

#[wasm_bindgen(start)]
fn init_pack() {
panic::set_hook(Box::new(console_error_panic_hook::hook));
Expand Down
1 change: 0 additions & 1 deletion crates/utoo-wasm/src/tokio_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub fn init_tokio_runtime(worker_url: String) {
* it will block threads scheduling,
* see https://web.dev/articles/scaling-multithreaded-webassembly-applications#heap_management_mallocfree
*/
.worker_threads(4)
.disable_lifo_slot()
.thread_name_fn(|| {
static ATOMIC_ID: AtomicUsize = AtomicUsize::new(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/utoo-web/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,6 @@ Your build setup should be configured to output these files to a location that y

## Notes

* Due to the current default memory allocator for Rust, [`dlmalloc`](https://github.com/alexcrichton/dlmalloc-rs), having less than ideal performance on multi-threaded `wasm`, we are currently trying to support [`mimalloc`](https://github.com/microsoft/mimalloc) with reference to [`emscripten`](https://emscripten.org/docs/tools_reference/settings_reference.html#malloc)'s solution. Once successful, the build speed will be greatly improved;
* Since the default memory allocator on Rust, [`dlmalloc`](https://github.com/alexcrichton/dlmalloc-rs), does not perform ideally on multi-threaded `wasm`, we have ported [`mimalloc`](https://github.com/microsoft/mimalloc) to the wasm32-unknown-unknown platform to support running builds with threads equal to the number of CPU cores. Therefore, the difference in build performance between the browser environment and the operating system environment is very small.
* In the future, we will also support the [`HMR`](https://webpack.js.org/concepts/hot-module-replacement/) feature in the browser;
* Advanced features of turbopack such as [`persistent caching`](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackPersistentCaching), are also in the plan and will be supported directly in the browser in the future.
2 changes: 1 addition & 1 deletion packages/utoo-web/API_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ import "@utoo/web/esm/serviceWorker";

## 注意

* 由于当前 Rust 上默认的内存分配器 [`dlmalloc`](https://github.com/alexcrichton/dlmalloc-rs) 在多线程 `wasm` 上性能不够理想,我们目前正在尝试参考 [`emscripten`](https://emscripten.org/docs/tools_reference/settings_reference.html#malloc) 的方案支持 [`mimalloc`](https://github.com/microsoft/mimalloc),一旦成功,构建速度将会有大幅提升;
* 由于当前 Rust 上默认的内存分配器 [`dlmalloc`](https://github.com/alexcrichton/dlmalloc-rs) 在多线程 `wasm` 上性能不够理想,我们将 [`mimalloc`](https://github.com/microsoft/mimalloc) 移植到了 wasm32-unknown-unknown 平台,以支持开启 CPU 核心数量的线程来运行构建。因此在浏览器环境和在操作系统环境,构建的性能差异十分微小。
* 未来我们也会在浏览器中支持 [`HMR`](https://webpack.js.org/concepts/hot-module-replacement/) 功能;
* turbopack 的部分高级功能如[`持久化缓存`](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackPersistentCaching),目前也在计划之中,未来会在浏览器内直接支持。

Loading
Loading