You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed the entire runtime gets linked in even if we don't use anything from it. It would be nice if onyx was smart enough to only include things it uses in the wasm module. With AssemblyScript, modules can compile down to a few hundred bytes, importing only what is needed.
Here's an example from an AssemblyScript-compiled binary I'm using for an embedded scripting language in an app I'm working on.
This is an issue I have thought about. A lot part of the binary currently is all of the type information that can be used for reflection. Things like printf use it heavily. However, it does add a large overhead to the executable size. If you run the compile with -V, you can see the type table size. For me, it is usually around ~170Kb, depending on how many types are in the program.
If you know your projects does not need type information or reflection, you can use the flag --no-type-info to onyx build or onyx run to omit outputting that info.
Also, one optimization I have not done yet is proper tree-shaking, or removing all the functions that are impossible to reach. Once I implement that, the binary size should decrease dramatically.
While it is far from perfect, Onyx does now perform tree-shaking before outputting the final binary, at least to the best of its abilities. This does help drastically reduce the size of the outputted binaries, especially in term of the number of function and data elements.
It is nowhere near as minimal as AssemblyScript though, because a couple features in the standard library are quite large and have internal dependencies on each other, such as the heap implementation and formatted printing. Because of this, the binary for the above code example with --no-type-info provided is still around 37Kb right now, which is far from ideal.
Just wanted to provide an update as there has been progress on this issue!
I noticed the entire runtime gets linked in even if we don't use anything from it. It would be nice if onyx was smart enough to only include things it uses in the wasm module. With AssemblyScript, modules can compile down to a few hundred bytes, importing only what is needed.
Here's an example from an AssemblyScript-compiled binary I'm using for an embedded scripting language in an app I'm working on.
using a "simpler" onyx program:
The output is very large, and can't be used for embedded use cases:
https://cdn.jb55.com/s/92a683de3fdcdf89.txt
I'm sure you're thinking about this, but thought I'd open an issue for it.
The text was updated successfully, but these errors were encountered: