-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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.