Repository navigation
Shorten the generated bindings in the bundle - #160
Merged
Merged
Conversation
The generated constructor spelled out this.exported( 147 times and this.wrapWithStringArguments( 37 times, and a minifier has to leave a method name alone. Two locals in the constructor take their place, so the named stores stay as they were and dist/index.js goes from 113.4 kB to 110.7 kB. The README size table was stale (108 + 194) and now carries the measured numbers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The constructor
utils/create-bindings.jsgenerates spelled outthis.exported(147 times andthis.wrapWithStringArguments(37 times. A minifier cannot shorten a method name, so each one landed in the bundle in full. The constructor now builds the bindings through two locals,rawandwithStrings, which it can.The bindings are still named stores in the constructor, so the instance layout is unchanged.
dist/index.jsdist/glue.wasmglue.wasmand both glues are byte for byte the same.LuaRuntime.load()measures the same before and after (1.78 ms median, interleaved A/B).The README size table was stale (108 + 194) and now carries the measured numbers.
What was tried and left out
This is about all there is without trading something away. Measured and dropped:
-flto, a single translation unit throughonelua.c,-Os,-O2, extra Binaryen passes,EVAL_CTORSandTEXTDECODER=2all tie with the current-Ozor come out larger.--closure 1on the glue: 79 kB to 43 kB out of emcc, but it renamesFSmethods (mount,mkdirTree,lookupPath,syncfs, ...), which breaks the publicemscripten.FS.strtod: about 14.6 kB of the wasm, since musl's parser pulls in 128 bit soft-float. Dropping it means a float parser of our own.privateto#private: the minifier does shorten#names, for an estimated 4 kB, but it is a refactor of about 110 members on hot paths.Testing
npm test(486 passing) andnpm run lint:nofix.