-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
LuaJIT's JIT compiler is disabled by default #899
Comments
It has been pointed out to me that this may be intended: https://discord.com/channels/717692382849663036/795037494106128434/1168024641638518814 |
It seems that there's a lot of confusion and many mod authors are assume the JIT compiler is enabled by default, so further clarity on this issue would be appreciated. |
We wouldnt use LuaJIT if we didn't want to use LuaJIT :P So yeah, this should be fixed although I'm pretty certain we use some compile flags which should enable the optimizations even without this... Should be checked though, mainly when we potentially do not do something according to docs, may have been some oversight. Reopened the issue. |
I tested with this simple local function integrate(x0, x1, nsteps, omegan, f)
local x, dx = x0, (x1-x0)/nsteps
local rvalue = ((x0+1)^x0 * f(omegan*x0)) / 2
for i=3,nsteps do
x = x + dx
rvalue = rvalue + (x+1)^x * f(omegan*x)
end
return (rvalue + ((x1+1)^x1 * f(omegan*x1)) / 2) * dx
end
local function series(n)
local sin, cos = math.sin, math.cos
local omega = math.pi
local t = {}
t[1] = integrate(0, 2, 1000, 0, function() return 1 end) / 2
t[2] = 0
for i=2,n do
t[2*i-1] = integrate(0, 2, 1000, omega*i, cos)
t[2*i] = integrate(0, 2, 1000, omega*i, sin)
end
return t
end
function run_iter(n)
for i=1,n do
keep = series(1000)
end
end
registerForEvent("onUpdate", function(deltaTime)
run_iter(1);
end) and I changed void ScriptContext::TriggerOnUpdate(float aDeltaTime) const
{
auto lockedState = m_sandbox.GetLockedState();
const auto start = std::chrono::high_resolution_clock::now();
TryLuaFunction(m_logger, m_onUpdate, aDeltaTime);
const auto end = std::chrono::high_resolution_clock::now();
spdlog::get("scripting")->info("Time taken for last update call: {}", std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count());
} I believe the results with and without Without
With
|
Add `sol::lib::jit` to actually enable JIT ( resolves #899 )
Ignore this if disabling the JIT compiler is the intended behavior, but the default Lua initialization does not enable the JIT compiler by default:
CyberEngineTweaks/src/scripting/Scripting.cpp
Line 52 in 91565e3
For the JIT to be enabled, the
sol::lib::jit
library must be opened even if thejit
module is to be sandboxed away later:The LuaJIT documentation mentions this here: https://luajit.org/install.html#embed
This is also mentioned in this sol2 issue: ThePhD/sol2#61
The text was updated successfully, but these errors were encountered: