-
-
Notifications
You must be signed in to change notification settings - Fork 688
improve: wasm build #3074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve: wasm build #3074
Conversation
| execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \ | ||
| ${join(WASM_SRC, 'src')}/*.c \ | ||
| -I${join(WASM_SRC, 'include')} \ | ||
| -o ${join(WASM_OUT, 'llhttp.wasm')} \ | ||
| ${WASM_LDLIBS}`, { stdio: 'inherit' }) |
Check warning
Code scanning / CodeQL
Shell command built from environment values
| -o ${join(WASM_OUT, 'llhttp.wasm')} \ | ||
| ${WASM_LDLIBS}`, { stdio: 'inherit' }) | ||
|
|
||
| execSync(`./wasm-opt ${WASM_OPT_FLAGS} -o ${join(WASM_OUT, 'llhttp.wasm')} ${join(WASM_OUT, 'llhttp.wasm')}`, { stdio: 'inherit' }) |
Check warning
Code scanning / CodeQL
Shell command built from environment values
| execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \ | ||
| ${join(WASM_SRC, 'src')}/*.c \ | ||
| -I${join(WASM_SRC, 'include')} \ | ||
| -o ${join(WASM_OUT, 'llhttp_simd.wasm')} \ | ||
| ${WASM_LDLIBS}`, { stdio: 'inherit' }) |
Check warning
Code scanning / CodeQL
Shell command built from environment values
| -o ${join(WASM_OUT, 'llhttp_simd.wasm')} \ | ||
| ${WASM_LDLIBS}`, { stdio: 'inherit' }) | ||
|
|
||
| execSync(`./wasm-opt ${WASM_OPT_FLAGS} --enable-simd -o ${join(WASM_OUT, 'llhttp_simd.wasm')} ${join(WASM_OUT, 'llhttp_simd.wasm')}`, { stdio: 'inherit' }) |
Check warning
Code scanning / CodeQL
Shell command built from environment values
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3074 +/- ##
=======================================
Coverage 94.06% 94.06%
=======================================
Files 89 89
Lines 24327 24331 +4
=======================================
+ Hits 22883 22887 +4
Misses 1444 1444 ☔ View full report in Codecov by Sentry. |
|
Can you please this PR on your special benchmarking PC please :)? |
|
how does it shrink the wasm file? |
Uzlopak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using -04 we optimize the wasm further.
| WASM_LDFLAGS += ' -Wl,--allow-undefined -Wl,--export-dynamic -Wl,--export-table' | ||
| WASM_LDFLAGS += ' -Wl,--export=malloc -Wl,--export=free -Wl,--no-entry' | ||
|
|
||
| const WASM_OPT_FLAGS = '-O4 --converge --strip-debug --strip-dwarf --strip-producers' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we define O4 for optimizing the wasm file.
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [undici](https://undici.nodejs.org) ([source](https://togithub.com/nodejs/undici)) | [`6.13.0` -> `6.14.1`](https://renovatebot.com/diffs/npm/undici/6.13.0/6.14.1) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>nodejs/undici (undici)</summary> ### [`v6.14.1`](https://togithub.com/nodejs/undici/compare/v6.14.0...1c440555a0c25d6a2ee2b0bdf8c5afcd9636332f) [Compare Source](https://togithub.com/nodejs/undici/compare/v6.14.0...v6.14.1) ### [`v6.14.0`](https://togithub.com/nodejs/undici/releases/tag/v6.14.0) [Compare Source](https://togithub.com/nodejs/undici/compare/v6.13.0...v6.14.0) #### What's Changed - bench: enable benchmarks for h2 by [@​metcoder95](https://togithub.com/metcoder95) in [https://github.com/nodejs/undici/pull/3100](https://togithub.com/nodejs/undici/pull/3100) - perf: improve performance of isomorphicEncode by [@​tsctx](https://togithub.com/tsctx) in [https://github.com/nodejs/undici/pull/3101](https://togithub.com/nodejs/undici/pull/3101) - util: remove isReadableAborted by [@​Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3104](https://togithub.com/nodejs/undici/pull/3104) - fix(types): The second parameter of EventSource is optional by [@​zbinlin](https://togithub.com/zbinlin) in [https://github.com/nodejs/undici/pull/3106](https://togithub.com/nodejs/undici/pull/3106) - fix: onConnect types by [@​ronag](https://togithub.com/ronag) in [https://github.com/nodejs/undici/pull/3116](https://togithub.com/nodejs/undici/pull/3116) - add dispatcher option to EventSource by [@​KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3119](https://togithub.com/nodejs/undici/pull/3119) - core: improve parseURL by [@​Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3102](https://togithub.com/nodejs/undici/pull/3102) - test: increase coverage by [@​Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3121](https://togithub.com/nodejs/undici/pull/3121) - docs: add directions to run docs and benchmarks by [@​FatumaA](https://togithub.com/FatumaA) in [https://github.com/nodejs/undici/pull/3092](https://togithub.com/nodejs/undici/pull/3092) - perf: avoid unnecessary clone by [@​tsctx](https://togithub.com/tsctx) in [https://github.com/nodejs/undici/pull/3117](https://togithub.com/nodejs/undici/pull/3117) - build(deps-dev): bump borp from 0.10.0 to 0.11.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/nodejs/undici/pull/3126](https://togithub.com/nodejs/undici/pull/3126) - drop node support for < v18.17.0 by [@​KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3125](https://togithub.com/nodejs/undici/pull/3125) - test: improve test and ci performance by [@​Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3135](https://togithub.com/nodejs/undici/pull/3135) - Added EnvHttpProxyAgent to support HTTP_PROXY by [@​10xLaCroixDrinker](https://togithub.com/10xLaCroixDrinker) in [https://github.com/nodejs/undici/pull/2994](https://togithub.com/nodejs/undici/pull/2994) - fetch: Change wording of "Body is unusable" error by [@​nzakas](https://togithub.com/nzakas) in [https://github.com/nodejs/undici/pull/3105](https://togithub.com/nodejs/undici/pull/3105) - perf: use class instead of object literals with getters by [@​tsctx](https://togithub.com/tsctx) in [https://github.com/nodejs/undici/pull/3138](https://togithub.com/nodejs/undici/pull/3138) - fix: unhandled exception or failing error body by [@​ronag](https://togithub.com/ronag) in [https://github.com/nodejs/undici/pull/3137](https://togithub.com/nodejs/undici/pull/3137) - reuse realm for Request/Response by [@​KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3142](https://togithub.com/nodejs/undici/pull/3142) - fix([H2-#​3140](https://togithub.com/H2-/undici/issues/3140)): abort requets upon GOAWAY by [@​metcoder95](https://togithub.com/metcoder95) in [https://github.com/nodejs/undici/pull/3143](https://togithub.com/nodejs/undici/pull/3143) - don't store realm on Request/Response by [@​KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3146](https://togithub.com/nodejs/undici/pull/3146) - improve: wasm build by [@​Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3074](https://togithub.com/nodejs/undici/pull/3074) #### New Contributors - [@​10xLaCroixDrinker](https://togithub.com/10xLaCroixDrinker) made their first contribution in [https://github.com/nodejs/undici/pull/2994](https://togithub.com/nodejs/undici/pull/2994) - [@​nzakas](https://togithub.com/nzakas) made their first contribution in [https://github.com/nodejs/undici/pull/3105](https://togithub.com/nodejs/undici/pull/3105) **Full Changelog**: nodejs/undici@v6.13.0...v6.14.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/X-oss-byte/Canary-nextjs).
|
Hi @Uzlopak, The external wasm codepath was used by Fedora due to our package policy. This is blocking us from updating to v6.14.0 and onwards. If you think some code / files is redundant, please explain it further to me and I'll be glad to update my code! |
|
What do you mean with external wasm codepath? |
| writeFileSync(join(WASM_OUT, 'wasm_build_env.txt'), buildInfo) | ||
| } | ||
|
|
||
| const writeWasmChunk = EXTERNAL_PATH | ||
| ? (path, dest) => { | ||
| const base64 = readFileSync(join(WASM_OUT, path)).toString('base64') | ||
| writeFileSync(join(WASM_OUT, dest), ` | ||
| const { Buffer } = require('node:buffer') | ||
| module.exports = Buffer.from('${base64}', 'base64') | ||
| `) | ||
| } | ||
| : (path, dest) => { | ||
| writeFileSync(join(WASM_OUT, dest), ` | ||
| const { fs } = require('node:fs') | ||
| module.exports = fs.readFileSync(require.resolve('./${basename(path)}')) | ||
| `) | ||
| } | ||
|
|
||
| // Build wasm binary | ||
| execSync(`${WASM_CC} ${WASM_CFLAGS} ${WASM_LDFLAGS} \ | ||
| ${join(WASM_SRC, 'src')}/*.c \ | ||
| -I${join(WASM_SRC, 'include')} \ | ||
| -o ${join(WASM_OUT, 'llhttp.wasm')} \ | ||
| ${WASM_LDLIBS}`, { stdio: 'inherit' }) | ||
|
|
||
| writeWasmChunk('llhttp.wasm', 'llhttp-wasm.js') | ||
|
|
||
| // Build wasm simd binary | ||
| execSync(`${WASM_CC} ${WASM_CFLAGS} -msimd128 ${WASM_LDFLAGS} \ | ||
| ${join(WASM_SRC, 'src')}/*.c \ | ||
| -I${join(WASM_SRC, 'include')} \ | ||
| -o ${join(WASM_OUT, 'llhttp_simd.wasm')} \ | ||
| ${WASM_LDLIBS}`, { stdio: 'inherit' }) | ||
|
|
||
| writeWasmChunk('llhttp_simd.wasm', 'llhttp_simd-wasm.js') | ||
|
|
||
| if (EXTERNAL_PATH) { | ||
| writeFileSync(join(ROOT, 'loader.js'), ` | ||
| 'use strict' | ||
| globalThis.__UNDICI_IS_NODE__ = true | ||
| module.exports = require('node:module').createRequire('${EXTERNAL_PATH}/loader.js')('./index-fetch.js') | ||
| delete globalThis.__UNDICI_IS_NODE__ | ||
| `) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ I meant this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then it has to be added back + a big fat comment to not remove it because of fedora
should shrink the wasm file. removes build artifacts and other files we dont need.