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

Using getfenv to get requiring script Name disables Luau optimization #5

Open
Ozzypig opened this issue Sep 4, 2020 · 0 comments
Open

Comments

@Ozzypig
Copy link
Owner

Ozzypig commented Sep 4, 2020

The use of any of these functions [loadstring, getfenv, setfenv] performs a dynamic deoptimization, marking the affected environment as “impure”. The optimizations are only in effect on functions with “pure” environments - because of this, the use of loadstring/getfenv/setfenv is not recommended. Note that getfenv deoptimizes the environment even if it’s only used to read values from the environment.

https://roblox.github.io/luau/performance.html#importing-global-access-chains

Modules currently gets the requiring script's name using getfenv, as this paragraph describes. This disables Luau optimizations, as the requiring script's environment becomes "impure".

A suggestion made by @howmanysmall provides a good alternative: using debug.traceback to create the "require taking too long" warnings. The output format of debug.traceback is not defined, so parsing its output is a bad idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant