Skip to content

WASM#1

Merged
devongovett merged 2 commits intoparcel-bundler:masterfrom
mischnic:wasm
Nov 9, 2021
Merged

WASM#1
devongovett merged 2 commits intoparcel-bundler:masterfrom
mischnic:wasm

Conversation

@mischnic
Copy link
Member

@mischnic mischnic commented Nov 9, 2021

Looks like the perf difference got larger since last time I tested.

$ node bench.js ../bootstrap.css
cssnano: 1.128s
162289 bytes

esbuild: 33.304ms
163165 bytes

parcel-css: 14.803ms
161398 bytes
$ CSS_TRANSFORMER_WASM=1 node bench.js ../bootstrap.css
cssnano: 1.350s
162289 bytes

esbuild: 38.626ms
163165 bytes

parcel-css: 29.698ms
161395 bytes

@devongovett
Copy link
Member

Maybe because of jemalloc?

@Brooooooklyn
Copy link
Contributor

because opt level changed to s. And I recommend https://github.com/purpleprotocol/mimalloc_rust which is faster than jemalloc

@devongovett
Copy link
Member

Ah, yes. Removing opt-level=s does improve perf, at least for the native version. For WASM, the performance is roughly the same. It also doesn't seem to affect size for wasm, so I removed it.

Also btw, I had to add this to Cargo.toml to get it to build on M1:

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

I think wasm-opt isn't built for ARM yet...

@devongovett devongovett merged commit f142ef1 into parcel-bundler:master Nov 9, 2021
@devongovett
Copy link
Member

And I recommend https://github.com/purpleprotocol/mimalloc_rust which is faster than jemalloc

I just tried, and at least for me on an M1 Mac, jemalloc is a little faster. I think in Parcel we use mimalloc on Windows though.

@mischnic mischnic deleted the wasm branch November 9, 2021 14:43
@mischnic
Copy link
Member Author

mischnic commented Nov 9, 2021

Another thing to note is that the first (couple?) invocation(s) of the wasm version are slower because it's not JITed yet but interpreted. So for accurate timings, you need to do something like

  for(let i = 0; i < 10; i++){
    css.transform(opts);
  }
  console.time('parcel-css');
  let res = css.transform(opts);
  console.timeEnd('parcel-css');
  console.log(res.length + ' bytes');

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.

3 participants