Unverified Commit 3f36bc1c authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Use Talc for threaded WASM allocation

The default WASM dlmalloc path spent substantial time growing linear memory as the trace store expanded. Use Talc's threaded WASM allocator, reducing this trace from 28.5s to 21.8–23.6s with about 41 MB more peak footprint.
Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
parent 85de4b83
......@@ -121,6 +121,12 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "allocator-api2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880"
[[package]]
name = "allsorts"
version = "0.14.1"
......@@ -810,7 +816,7 @@ version = "3.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
dependencies = [
"allocator-api2",
"allocator-api2 0.2.21",
]
[[package]]
......@@ -2589,7 +2595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash 0.8.12",
"allocator-api2",
"allocator-api2 0.2.21",
]
[[package]]
......@@ -2598,7 +2604,7 @@ version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
dependencies = [
"allocator-api2",
"allocator-api2 0.2.21",
"equivalent",
"foldhash 0.1.5",
"serde",
......@@ -2610,7 +2616,7 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"allocator-api2",
"allocator-api2 0.2.21",
"equivalent",
"foldhash 0.2.0",
]
......@@ -5860,7 +5866,7 @@ version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08effbc1fa53aaebff69521a5c05640523fab037b34a4a2c109506bc938246fa"
dependencies = [
"allocator-api2",
"allocator-api2 0.2.21",
"bumpalo",
"hashbrown 0.15.4",
"log",
......@@ -6750,6 +6756,15 @@ dependencies = [
"lock_api",
]
[[package]]
name = "spinning_top"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300"
dependencies = [
"lock_api",
]
[[package]]
name = "st-map"
version = "0.2.0"
......@@ -6977,7 +6992,7 @@ version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb41c2f41afa7357a86109f7e058f6b140ab415b8cd196c1a7b54f2703c85417"
dependencies = [
"allocator-api2",
"allocator-api2 0.2.21",
"bumpalo",
"hashbrown 0.14.5",
"rustc-hash 2.1.1",
......@@ -8354,6 +8369,16 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "talc"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49661c532dfd6e4f570ef10a45cb92f6f4fce5a28245558ae48307b57b40a5b4"
dependencies = [
"allocator-api2 0.4.0",
"lock_api",
]
[[package]]
name = "tap"
version = "1.0.1"
......@@ -9738,7 +9763,7 @@ dependencies = [
name = "turbopack-ecmascript"
version = "0.1.0"
dependencies = [
"allocator-api2",
"allocator-api2 0.2.21",
"anyhow",
"async-trait",
"auto-hash-map",
......@@ -10128,6 +10153,8 @@ dependencies = [
"napi",
"napi-build",
"napi-derive",
"spinning_top",
"talc",
"turbopack-trace-server",
]
......
......@@ -346,10 +346,12 @@ smallvec = { version = "1.15.1", features = [
"union",
"const_new",
] }
spinning_top = "0.3.0"
shrink-to-fit = "0.2.10"
strsim = "0.11.1"
swc_sourcemap = "10.0.2"
syn = "2.0.100"
talc = "5.1.0"
tempfile = "3.20.0"
terminal_size = "0.3.0"
thiserror = "1.0.48"
......
......@@ -18,5 +18,9 @@ napi = { version = "3.10.0", default-features = false, features = ["napi3"] }
napi-derive = { workspace = true }
turbopack-trace-server = { workspace = true, default-features = false }
[target.'cfg(target_family = "wasm")'.dependencies]
spinning_top = { workspace = true }
talc = { workspace = true }
[build-dependencies]
napi-build = { workspace = true }
......@@ -12,6 +12,14 @@ use turbopack_trace_server::{
protocol::ProtocolSession, read_trace_bytes, read_trace_bytes_with_progress,
};
#[cfg(target_family = "wasm")]
#[global_allocator]
static ALLOC: talc::sync::TalcLock<
spinning_top::RawSpinlock,
talc::wasm::WasmGrowAndClaim,
talc::wasm::WasmBinning,
> = talc::sync::TalcLock::new(talc::wasm::WasmGrowAndClaim);
const PROGRESS_INTERVAL: Duration = Duration::from_millis(250);
#[napi(object)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment