Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Lua 5.1.5 bytecode is larger than Lua source code #6891

Closed
britzl opened this issue Aug 18, 2022 · 0 comments · Fixed by #6893
Closed

Generated Lua 5.1.5 bytecode is larger than Lua source code #6891

britzl opened this issue Aug 18, 2022 · 0 comments · Fixed by #6893
Labels
bob Issues related to the bob command line build tool lua Issues related to the use of Lua task A task that needs to be performed

Comments

@britzl
Copy link
Contributor

britzl commented Aug 18, 2022

Task (REQUIRED):
We recently changed so that all platforms, not only LuaJIT based platforms, use Lua bytecode instead of source code. For Lua 5.1.5 it turned out that the bytecode is larger than the source code. Since Lua 5.1.5 is used for the HTML5 builds this is an unfortunate development because of the focus on small download for web games. The issue was raised in this forum post:

https://forum.defold.com/t/defold-1-3-5-has-been-released/71451/4?u=britzl

Some measurements done to confirm this:

Original Lua file and compressed size
39398 monarch.lua
13902 monarch.lua.lz4
11642 monarch.lua.lz4.gz

Lua 5.15 bytecode and compressed size
52126 monarch.lua.luac32.unstripped
23098 monarch.lua.luac32.unstripped.lz4
18472 monarch.lua.luac32.unstripped.lz4.gz
27050 monarch.lua.luac32.stripped
13332 monarch.lua.luac32.stripped.lz4
10924 monarch.lua.luac32.stripped.lz4.gz


LuaJIT bytecode and compressed size
31211 monarch.lua.luajit32.unstripped
16278 monarch.lua.luajit32.unstripped.lz4
13426 monarch.lua.luajit32.unstripped.lz4.gz
20640 monarch.lua.luajit32.stripped
11319 monarch.lua.luajit32.stripped.lz4
9254 monarch.lua.luajit32.stripped.lz4.gz

.lz4 = size of file as when compressed in the game.archive
.gz = size of file when sent “over the wire” for HTML5

It would seem like the correct solution to the problem would be to bundle the game with the --use-lua-source option, but this has the side-effect of flagging the Lua source code as uncompressed and unencrypted:

https://github.com/defold/defold/blob/dev/com.dynamo.cr/com.dynamo.cr.bob/src/com/dynamo/bob/pipeline/LuaBuilder.java#L318-L331

This option was added to solve issues with Apple blocking the release of a game, as discussed in this forum post:

https://forum.defold.com/t/urgent-need-help-i-have-huge-problem-with-game-submission-to-apple/68031

Expected outcome (REQUIRED):
We either need an option to say that the Lua source code should be compressed and encrypted even if stored as plain text source code or we need to revert back to always using Lua source code for Lua 5.1.5

@britzl britzl added task A task that needs to be performed bob Issues related to the bob command line build tool lua Issues related to the use of Lua labels Aug 18, 2022
@britzl britzl changed the title Add option to compress Lua source if it is used instead of bytecode Generated Lua 5.1.5 bytecode is larger than Lua source code Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bob Issues related to the bob command line build tool lua Issues related to the use of Lua task A task that needs to be performed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant