Very cool! For those interested to check this out, you can just replace the existing optimizer executable, and if you want to go back, just deleting the replacement will make emcc rebuild the original one.
Regarding those improvements to speed and memory use, I'm curious where they come from - what were the changes you made? Small things, or large structural changes to the AST? For comparison, the binaryen optimizer also has some major improvements to speed and memory compared to the emscripten asm.js one, and that's mostly from the redesigned AST - I'm curious if we ended up doing similar things to improve on the old optimizer. Also, do you think your choice of language had an effect here? Have you verified this generates the same output as the asm.js one, btw? You mention it passes the test suite, but I'm also curious if it's literally generating the same code as well. On Fri, Nov 4, 2016 at 8:08 PM, Aidan Hobson Sayers <[email protected]> wrote: > Using Ayzim as a drop-in replacement for the Emscripten asm.js native > optimizer when compiling an asm.js project of moderate or large size on > `-O2` or `-O3` should result in a ~50-75% reduction in memory usage and a > ~25-50% speedup when running asm.js native optimizer passes (i.e. most of > the "js opts" stage as seen in in EMCC_DEBUG output). > > To get it, download the compiled releases for Linux and Windows from the > ayzim releases page <https://github.com/aidanhs/ayzim/releases>, extract > them and replace (after backing up!) the existing optimizer(.exe) binary in > `emsdk/emscripten/incoming_optimizer_64bit/` (if you're not on `incoming` > but still feel brave, take a look at your emscripten config file, usually > at `$HOME/.emscripten`, which should point you to the right place). > > -- > > Some background: when I was trying to port a large application to asm.js > about 6 months ago I had serious problems with the Emscripten asm.js > optimizer - it would split the 750MB .js file into chunks and promptly > consume all 8GB of my RAM by trying to optimize the chunks in parallel, > swapping everything else out of memory and grinding the machine to a halt. > I tackled this problem by taking a brief(!) diversion to rewrite the > optimizer in Rust to be more memory efficient. Along the way I added a few > speedups. > > Ayzim is probably an entry in the "well this might have been useful two > years ago" section of software (since asm.js is 'shortly' going to be made > redundant by wasm) but someone may find a use for it. For example, people > wanting to understand the structure of the Emscripten optimizer ast may > want to look at this code > <https://github.com/aidanhs/ayzim/blob/0.1.2/src/cashew.rs#L141> and/or > ask me since I'm very familiar with it now :) > > In time I may extend Ayzim to support wasm optimizations and move it to > being more of a library, but that's for the future. > > Aidan > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
