nodejs / postject

Easily inject arbitrary read-only resources into executable formats (Mach-O, PE, ELF) and use it at runtime.
Other
187 stars 14 forks source link

Investigate why running the wasm blob in Postject is slow #85

Closed RaisinTen closed 1 year ago

RaisinTen commented 1 year ago

See the discussion in https://github.com/nodejs/node/issues/47741.


Measurements of injecting a 4KB resource into a Mach-O binary on an x86_64 macOS with Node.js v20.1.0:

TLDR - https://github.com/nodejs/postject/blob/24818680fef14b298e251dd0645fb290a5e8e280/src/postject.cpp#L16-L21 is where the bottleneck is.

Replacing the emscripten::vecFromJSArray<uint8_t>(value) call at https://github.com/nodejs/postject/blob/24818680fef14b298e251dd0645fb290a5e8e280/src/postject.cpp#L20 with a call to emscripten::vecFromJSArray<uint8_t>(value) reduces the time consumption from ~30s to ~6s.