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
bytecode.rpyb recompiled when there's no changes #1647
Comments
I think you did miss something. The main thing is that:
Doesn't run during a "normal" run of Ren'Py, one where no script file has changed. During a normal run, the .rpy file won't change, and hence Ren'Py will load in the .rpyc file instead (see Line 662 in 0382e17
Because of that, the hash won't change, the bytecode will be looked up, the bytecode cache won't get dirtied, and Ren'Py will start fast. So I think there's a problem here, but my bet is that something is changing the md5 of the .rpy file between the time it is created and the time it is loaded into Ren'Py, and that's causing it to be recompiled unnecessarily. (Ren'Py actively rejects Reproducible Builds. The .rpyc files contain annotations needed to make a game loadable - annotations that if included in the script, would make the scripts unbearable to write.) |
Hi, Note: I'm talking about Python snippets compilation only, not about the .rpy->.rpyc AST-compilation. I did see that in the common case the bytecode isn't dirtied. Again, that's a confusing corner-case situation, that could be avoided by using a stable hash for the Python snippets bytecode. If we care to. (I don't think .rpyc files are a reason to "reject" Reproducible Builds. From what I understand .rpyc are partial source files too. For clarity we could even have 3 files: the source .rpy, the annotations that complement the .rpy (e.g. a ".rpya"), and the purely-derived/compiled parts in a .rpyc that could be safely removed/recreated. Anyway, just an aside.) |
I don't think the approach to reproduceable builds is likely to change, so closing this to clean up the tracker. |
While working on RenPyWeb I noted that bytecode.rpyb was updated even when there was no change in any .rpy file.
This caused a gratuitous delay of dozen(s) of seconds on load for the web platform due to recompiling a lot of Python snippets embedded in the renpy/common/ .rpyc/.rpymc files.
Currently I fixed the issue by having developers ship their renpy/common/ directory but this was strange nonetheless.
I tracked the culprit in ast.py:
Ren'Py checks if the Python code located in a .rpyc file was already compiled by checking whether its pre-computed hash is referenced in bytecode.rpyb. This pre-computed hash changes at each compilation, even if the resulting bytecode is the exact same, due to using
time()
.Since the .rpyc/.rpymc files are recompiled every time one makes a new Distribution (with Force recompile), this means a game's bytecode.rpyb never carries the same hashes even when compiling the same snippets twice in a row. Consequently the bytecode hashes referenced in the
renpy/common/
shipped in renpyweb will never be found in a game'sgame/bytecode.rpyb
even if these bytecodes are identical.It seems to me that the location of the Python snippet does not matter as long as the resulting bytecode is bit-for-bit identical. I tested with:
and with this bytecode.rpyb is left untouched, unless there was an actual change in the Python snippet.
This is similar to the way Git identifies files with their SHA-1.
I understand that we ship a full renpy/ directory in a Distribution anyway (we'll do that even in renpyweb eventually), so this unnecessary recompilation does not happen often.
However (maybe that's my Reproducible Builds background kicking in) I do not see a valid reason to make the bytecode hashes change every time.
Did I miss something?
The text was updated successfully, but these errors were encountered: