Skip to content

Conversation

@Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Apr 9, 2024

should shrink the wasm file. removes build artifacts and other files we dont need.

Comment on lines +86 to +90
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

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2). This shell command depends on an uncontrolled [absolute path](3). This shell command depends on an uncontrolled [absolute path](4).
-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

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2).
Comment on lines +96 to +100
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

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2). This shell command depends on an uncontrolled [absolute path](3). This shell command depends on an uncontrolled [absolute path](4).
-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

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2).
@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.06%. Comparing base (7a94682) to head (4a8f4a7).

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.
📢 Have feedback on the report? Share it here.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Apr 9, 2024

@mcollina

Can you please this PR on your special benchmarking PC please :)?

@mcollina
Copy link
Member

mcollina commented Apr 9, 2024

how does it shrink the wasm file?

Copy link
Contributor Author

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcollina

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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcollina

This is where we define O4 for optimizing the wasm file.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina requested a review from ronag April 22, 2024 13:10
@mcollina mcollina merged commit 3f9e147 into nodejs:main Apr 22, 2024
@github-actions github-actions bot mentioned this pull request Apr 22, 2024
@Uzlopak Uzlopak deleted the wasm-builder branch April 22, 2024 13:31
kodiakhq bot referenced this pull request in X-oss-byte/Canary-nextjs Apr 24, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](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) | [![age](https://developer.mend.io/api/mc/badges/age/npm/undici/6.14.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/undici/6.14.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/undici/6.13.0/6.14.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/undici/6.13.0/6.14.1?slim=true)](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 [@&#8203;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 [@&#8203;tsctx](https://togithub.com/tsctx) in [https://github.com/nodejs/undici/pull/3101](https://togithub.com/nodejs/undici/pull/3101)
-   util: remove isReadableAborted by [@&#8203;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 [@&#8203;zbinlin](https://togithub.com/zbinlin) in [https://github.com/nodejs/undici/pull/3106](https://togithub.com/nodejs/undici/pull/3106)
-   fix: onConnect types by [@&#8203;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 [@&#8203;KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3119](https://togithub.com/nodejs/undici/pull/3119)
-   core: improve parseURL by [@&#8203;Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3102](https://togithub.com/nodejs/undici/pull/3102)
-   test: increase coverage by [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;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 [@&#8203;KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3142](https://togithub.com/nodejs/undici/pull/3142)
-   fix([H2-#&#8203;3140](https://togithub.com/H2-/undici/issues/3140)): abort requets upon GOAWAY by [@&#8203;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 [@&#8203;KhafraDev](https://togithub.com/KhafraDev) in [https://github.com/nodejs/undici/pull/3146](https://togithub.com/nodejs/undici/pull/3146)
-   improve: wasm build by [@&#8203;Uzlopak](https://togithub.com/Uzlopak) in [https://github.com/nodejs/undici/pull/3074](https://togithub.com/nodejs/undici/pull/3074)

#### New Contributors

-   [@&#8203;10xLaCroixDrinker](https://togithub.com/10xLaCroixDrinker) made their first contribution in [https://github.com/nodejs/undici/pull/2994](https://togithub.com/nodejs/undici/pull/2994)
-   [@&#8203;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).
@mochaaP
Copy link
Contributor

mochaaP commented May 21, 2024

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!

@Uzlopak
Copy link
Contributor Author

Uzlopak commented May 21, 2024

What do you mean with external wasm codepath?

Comment on lines -62 to -107
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__
`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ I meant this.

Copy link
Contributor Author

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

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.

4 participants