Mashi - A compressor for JS/WASM 64k intros
category: code [glöplog]
Hi friends, I just released the first version of Mashi, which is a compressor for JS/WASM 64k intros. It is based on the core compression routines of Squishy by Ferris/Logicoma, which I'm sure most of you are familiar with.
It is intended as a replacement for Compeko or JsExe or any other kind of tool that relies on the browser's built-in Deflate implementation. I built it primarily for use for compression of WASM (with a tiny amount of JS needed for browser interop) and for that reason it adds a full WASM context model that really improves compression of those kinds of binaries. The decompressor is hand-written in WASM so if you're interested to see what hell looks like, check out "decompress.wat" in the repo linked below.
However, intros that are pure JS can also benefit, although in my unscientific testing the results varied. 0b5vr's 0mix intro went from 64k to 48k, but Luminosity by Bypass was almost unchanged. So YMMV.
Anyway, feel free to test it out. Binaries are available at https://github.com/datatrash/mashi/releases and the source code is at https://github.com/datatrash/mashi
It's all a bit untested (especially under Linux and on non-Chrome-based browsers), but I thought that with Revision coming our way it could already be of use to someone.
Btw, pull requests that reduce final binary size are of course very welcome :)
And a big shout out to Ferris for allowing me to use Squishy as a basis for this, obviously!
It is intended as a replacement for Compeko or JsExe or any other kind of tool that relies on the browser's built-in Deflate implementation. I built it primarily for use for compression of WASM (with a tiny amount of JS needed for browser interop) and for that reason it adds a full WASM context model that really improves compression of those kinds of binaries. The decompressor is hand-written in WASM so if you're interested to see what hell looks like, check out "decompress.wat" in the repo linked below.
However, intros that are pure JS can also benefit, although in my unscientific testing the results varied. 0b5vr's 0mix intro went from 64k to 48k, but Luminosity by Bypass was almost unchanged. So YMMV.
Anyway, feel free to test it out. Binaries are available at https://github.com/datatrash/mashi/releases and the source code is at https://github.com/datatrash/mashi
It's all a bit untested (especially under Linux and on non-Chrome-based browsers), but I thought that with Revision coming our way it could already be of use to someone.
Btw, pull requests that reduce final binary size are of course very welcome :)
And a big shout out to Ferris for allowing me to use Squishy as a basis for this, obviously!
Nice 👍
👍
That 2.5k stub handwritten in .wat 😅
Very cool!
wtf
Ahh it's context modeling based on Squishy, very very nice contribution. Would try this later
Yes, to be clear, WASM compression has a lot of extra logic to improve compression. JS doesn't, but it should still be nice improvement over just Deflate.
Wow, the handdone WASM based depacker is super impressive.
Reading the context modelling code for Squishy was super instructive. My code for my packer is just bog standard LZMA1, with a super tiny (500 bytes) x86/x64 depacker. Should port to ARM/68k/WASM.
Reading the context modelling code for Squishy was super instructive. My code for my packer is just bog standard LZMA1, with a super tiny (500 bytes) x86/x64 depacker. Should port to ARM/68k/WASM.
@^ML!^: I'm fairly sure people would find that very suitable for 4k intros :)
Quote:
@^ML!^: I'm fairly sure people would find that very suitable for 4k intros :)
I wonder how hard it would be to modify crinkler to allow for the depacker. That seems to be the goto standard for Windows compressing linkers these days.
Or even do a custom packer ala 1kpack, but specifically made for GL4.6 (bindless could help there). Linux is interesting in that there is solutions out there for that.
Nice!
Also sounds like a dutch MicroW8 thingy for easter to me...? ;)
Also sounds like a dutch MicroW8 thingy for easter to me...? ;)
hfr: That would be inaccurate, I'm afraid :)
very nice!
can this work together, with other wasm stuff, like sointu ?
Quote:
can also be used for JS-only productions
can this work together, with other wasm stuff, like sointu ?
@pandur, in theory, yes. Currently mashi always generates an index.html, but I could provide a 'raw mode' that just outputs a compressed WASM that you can call manually from your JS to depack.
Let me know if you want to discuss this further, or feel free to open a GitHub issue where we can hash this out :)
Let me know if you want to discuss this further, or feel free to open a GitHub issue where we can hash this out :)
Quote:
@pandur, in theory, yes. Currently mashi always generates an index.html, but I could provide a 'raw mode' that just outputs a compressed WASM that you can call manually from your JS to depack.
Let me know if you want to discuss this further, or feel free to open a GitHub issue where we can hash this out :)
I wonder if this could be extended to WASM in general, like even Emscripten. Not sure if Emscripten allows linking raw WASM modules with compiled C/C++ code, would be really nice.
Yay, excited for this! This could be the future of the size coding categories. Intros that people can download and see. Like in the old days.
Thanks for doing this, I'll be trying it.
Thanks for doing this, I'll be trying it.
@iq: This was indeed my goal. I love 64k intros, but it's sad that they're getting increasingly difficult to watch (or even download, when they're flagged as malware). If this tool leads to 1% more people watching 64k intros it's a win :)
Quote:
Yay, excited for this! This could be the future of the size coding categories. Intros that people can download and see. Like in the old days.
Thanks for doing this, I'll be trying it.
The influx of fantasy consoles helps a ton there as well, since its all WASM. I am hoping there is someway Enscriptem would be supported by the packer.
I guess if I provide a raw mode that just emits a WASM module then you can do whatever you like to run the depacker and get back the depacked WASM. I don't have any experience with Emscripten though, so I don't know exactly what your requirements would be. Feel free to open a GitHub issue with details.
Quote:
Intros that people can download and see. Like in the old days.
It's a bit sad that the typical 4K is so rich with sharp details and then viewed almost exclusively through mediocre-to-bad video encodes. :-/
Quote:
I guess if I provide a raw mode that just emits a WASM module then you can do whatever you like to run the depacker and get back the depacked WASM. I don't have any experience with Emscripten though, so I don't know exactly what your requirements would be. Feel free to open a GitHub issue with details.
I did some digging myself as I always wanted to get into fantasy consoles (since I don't have a real C64 with needed flashcart hardware or a Amiga at all, or a PAL N64 with Everdrive), and it seems Emscripten does its own "relocated" WASM modules. So it seems to be its own thing :/, unless WAT scripts could be compiled into such a module as part of the C/C++ process.
