Skip to content

perf(build): remove --export-dynamic flag in wasi compilation - #2523

Merged
Brooooooklyn merged 1 commit into
napi-rs:mainfrom
CPunisher:03-18-perf/wasm-export-dynamic
Mar 19, 2025
Merged

perf(build): remove --export-dynamic flag in wasi compilation#2523
Brooooooklyn merged 1 commit into
napi-rs:mainfrom
CPunisher:03-18-perf/wasm-export-dynamic

Conversation

@CPunisher

@CPunisher CPunisher commented Mar 18, 2025

Copy link
Copy Markdown
Contributor

From my study, --export-dynamic isn't usually used when compiling to dynamic libraries. With this flag enable, there are many unused symbols exported from the wasm artifact.

Rspack suffers from this with ~130,000 exported symbols, due to the 100,000 limitation of node.js, although currently there is no problem in rolldown with ~20,000 exported symbols.

I'm not sure whether this flag is necessary. But at least we need to find some ways to control the exports.

I also build rolldown without this flag, and the examples in the repo can be still successfully built. Here is some data for comparison:

Data Before After
compilation time 71.13s 70.98s
export count 20,025 80
wasm size(debug) 169.93MB 167.15MB
wasm size 14.99MB 11.91MB
Example Before (ms) After (ms)
basic-typescript 57.51 46.34
basic-vue 97.39 84.74
module-federation-host 152.89 130.17
module-federation-remote 93.33 87.27
rollup-plugin-esbuild 68.16 67.07

Before:
image

After:
image

@Brooooooklyn

Copy link
Copy Markdown
Member

It was from https://github.com/toyobayashi/emnapi?tab=readme-ov-file#usage, maybe @toyobayashi know why there is --export-dynamic flag

@toyobayashi

Copy link
Copy Markdown
Contributor

Sorry, I wrote that for convenience when testing emnapi. For napi-rs, it should be reasonable to remove it if you know which symbols need to explicitly export. (symbols those explicitly exported related to napi entry and for emnapi runtime use purpose shouldn't be removed)

@Brooooooklyn

Copy link
Copy Markdown
Member

Make sense 👍

@Brooooooklyn Brooooooklyn changed the title perf: remove --export-dynamic flag in wasi compilation perf(build): remove --export-dynamic flag in wasi compilation Mar 19, 2025
@Brooooooklyn
Brooooooklyn merged commit 6f6c110 into napi-rs:main Mar 19, 2025
github-merge-queue Bot pushed a commit to rolldown/rolldown that referenced this pull request Mar 22, 2025
Ref: napi-rs/napi-rs#2523

### Performance Comparison: Before vs After

*My mac is on low power mode during the benchmark*

| Example | Before (ms) | After (ms) | Difference (ms) | Improvement (%)
|

|---------|------------|------------|-----------------|-----------------|
| @example/typescript | 62.50 | 52.78 | -9.72 | 15.55% |
| @example/vue | 109.41 | 98.47 | -10.94 | 10.00% |
| @example/module-federation-host | 165.38 | 159.82 | -5.56 | 3.36% |
| @example/module-federation-remote | 110.44 | 95.87 | -14.57 | 13.19% |
| @example/rollup-plugin-esbuild | 65.82 | 68.91 | +3.09 | -4.69% |
| **Average** | **102.71** | **95.17** | **-7.54** | **7.34%** |
richerfu added a commit to ohos-rs/ohos-rs that referenced this pull request Apr 25, 2025
* chore(napi): SharedReference can be sync (napi-rs#2503)

* fix(napi): reference cannot impl send (napi-rs#2499)

* chore(napi): upgrade wasm tools

* chore(release): publish

 - @napi-rs/cli@3.0.0-alpha.74
 - @napi-rs/triples@2.0.0-alpha.36

* chore(deps): bump @babel/runtime from 7.26.9 to 7.26.10 (napi-rs#2508)

Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.26.9 to 7.26.10.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.26.10/packages/babel-runtime)

---
updated-dependencies:
- dependency-name: "@babel/runtime"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump axios from 1.8.1 to 1.8.3 (napi-rs#2507)

Bumps [axios](https://github.com/axios/axios) from 1.8.1 to 1.8.3.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](axios/axios@v1.8.1...v1.8.3)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(napi): tokio multi-thread mode on wasi (napi-rs#2501)

* feat(napi): tokio multi-thread mode on wasi

* tokio_unstable flag

* snapshot

* ensure runtime

* oncelock combine lazylock

* noop feature

* fix(cli): CXX path for s390x (napi-rs#2509)

* chore(release): publish

 - @napi-rs/cli@3.0.0-alpha.75
 - @napi-rs/triples@2.0.0-alpha.37

* chore(deps): update dependency oxlint to ^0.16.0 (napi-rs#2512)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(napi): js callback in threadsafefunction should not be Send (napi-rs#2510)

* chore(deps): update dependency @oxc-node/core to ^0.0.21 (napi-rs#2515)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: upgrade npm dependencies (napi-rs#2516)

* Release independent packages

- napi@3.0.0-alpha.32
- napi-derive@3.0.0-alpha.29

* chore(deps): update dependency shx to ^0.4.0 (napi-rs#2518)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(napi): re-create async runtime (napi-rs#2519)

* Release independent packages

- napi@3.0.0-alpha.33

* feat(cli): add `wasm.browser.asyncInit` for large wasm file (napi-rs#2514)

* perf(build): remove --export-dynamic flag in wasi compilation (napi-rs#2523)

* chore(release): publish

 - @napi-rs/cli@3.0.0-alpha.76
 - @napi-rs/triples@2.0.0-alpha.38

* Release independent packages

- napi-build@2.1.6

* chore(deps): update dependency vite to v6.2.3 [security] (napi-rs#2528)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency sinon to v20 (napi-rs#2526)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update yarn to v4.8.0 (napi-rs#2530)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(cli): excludeNetwork on getting report (napi-rs#2531)

* chore(cli): excludeNetwork on getting report

* Update cli/src/api/templates/js-binding.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* format

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore(deps): update yarn to v4.8.1 (napi-rs#2536)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency vite to v6.2.4 [security] (napi-rs#2538)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(cli): trim is not a function (napi-rs#2541)

* chore(cli): update deps (napi-rs#2542)

* chore(release): publish

 - @napi-rs/cli@3.0.0-alpha.77
 - @napi-rs/triples@2.0.0-alpha.39
 - @napi-rs/wasm-runtime@0.2.8

* chore(deps): update dependency @oxc-node/core to ^0.0.22 (napi-rs#2543)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: clippy fix (napi-rs#2545)

* chore(deps): update dependency vite to v6.2.5 [security] (napi-rs#2549)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update yarn to v4.9.0 (napi-rs#2551)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency @oxc-node/core to ^0.0.23 (napi-rs#2552)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat(napi): serde value ref to napi_value (napi-rs#2550)

* perf: convert serde value ref to napi_value

* chore: add test case

* fix: snapshot

* chore(deps): update dependency vite to v6.2.6 [security] (napi-rs#2554)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(wasm-runtime): remove `_isBuffer` patch (napi-rs#2560)

closes napi-rs#2559

* chore(deps): update yarn to v4.9.1 (napi-rs#2562)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(wasm-runtime): wasm fs proxy serialization (napi-rs#2564)

* fix: wasm fs proxy serialization

* type

* test(wasm-runtime): testing fs proxy on CI (napi-rs#2565)

* fix(cli): replace .wasm extension of wasm artifact (napi-rs#2556)

Co-authored-by: LongYinan <lynweklm@gmail.com>

* chore(release): publish

 - @napi-rs/cli@3.0.0-alpha.78
 - @napi-rs/triples@2.0.0-alpha.40
 - @napi-rs/wasm-runtime@0.2.9

* ci: test Windows on ARM (napi-rs#2566)

* fix(wasm-runtime): upgrade emnapi (napi-rs#2568)

* fix: fix window warning

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Cong-Cong Pan <dacongsama@live.com>
Co-authored-by: LongYinan <lynweklm@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
Co-authored-by: CPunisher <1343316114@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kevin Deng 三咲智子 <sxzz@sxzz.moe>
Co-authored-by: Toyo Li <lifenglin314@outlook.com>
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