42 Commits
Author SHA1 Message Date
nox7 768773a31a Don't run simulation or game timers when the game is paused 2026-10-13 20:24:09 -05:00
nox7 40ba44aa5d Remove useless methods 2026-09-18 13:54:43 -05:00
nox7 4e88ec9049 Remove useless method and just group the timers into the original two 2026-09-18 13:54:43 -05:00
nox7 c992c8cb0c Implement new real time timers. Works when the game is paused 2026-09-18 13:54:43 -05:00
Thomas decf020ecd Add test coverage to avoid silent breakage 2026-09-08 13:01:49 +02:00
Thomas Portal dd5d7887d7 Keep the active local scripts in a sorted vector
mActiveLocalScripts is walked four times a frame (prune, stats, timers,
update) and inserted into only when an object becomes active, which is the
access pattern a contiguous container is for. A std::set pays red-black tree
pointer chasing on every one of those walks.

Hold a vector sorted by container address instead. Sorted rather than
unsorted because a duplicate entry would dispatch a container's handlers
twice; the ordering itself was never meaningful, since the set was ordered by
pointer address too.

Measured on the Path of the Incarnate save: Lua p50 3.489 -> 3.366 ms, -3.5%,
with all three treatment runs below all three control runs.

This only fixes the first of the three hops needed to reach a container: the
weak pointer is now sequential, but dereferencing it to the heap slot and
then to the container are still dependent misses. Resolving the list into
dense pointers once per frame is blocked on lifetime, since running timers
and update handlers can deactivate an object mid-walk and re-resolving is
exactly the protection that would be discarded.
2026-09-08 13:01:49 +02:00
Thomas Portal ebbadc87fa Decay Lua script instruction averages lazily
statsNextFrame walked every script in a container every frame purely to
multiply each running average by a decay constant, whether or not the script
had run. With 701 active containers that walk is pure overhead for scripts
that were idle.

The averaging is a geometric decay, so the frames a script sat out fold into
a single power. Record the frame each average was last written and apply the
missing decay when it is next written or read; the per-frame call then only
bumps a counter, and a frame costs the same whether a container holds one
script or a thousand.

Reading the stats deliberately does not write them back, so collectStats
stays const and the decay is applied for real by whoever writes next.
2026-09-08 13:01:49 +02:00
Evil Eye eb15948b0e Account for nullptrs 2026-03-19 20:34:32 +01:00
Evil Eye 233fb4e7bd Address feedback 2026-03-09 21:25:59 +01:00
Evil Eye 814e51785f Avoid tracking dangling LocalScripts 2026-03-09 21:15:42 +01:00
Evil Eye 4f8b418c23 Ensure LuaUtil::call is invoked from a safe context 2025-10-30 22:24:53 +01:00
Evil EyeandPetr Mikheev ff79c2d826 Turn menu.saveGame into a delayed action 2025-09-20 10:39:43 +00:00
elsid d121b606b6 Fix and enforce local variable naming 2025-08-05 21:27:48 +02:00
Mads Buvik SandveiandSkyhasacat 34eb3d485d [Lua] Partially dehardcode onHit 2025-07-30 20:21:15 +00:00
Evil Eye b0e9df0139 Ensure class members are tied to the main Lua state 2025-03-03 19:37:07 +01:00
Evil EyeandPetr Mikheev 68ebefc2dd Fix Lua memory usage 2024-10-15 21:18:13 +00:00
elsid b4f77e8bd7 Store Lua script path as VFS normalized 2024-09-15 13:53:20 +02:00
Evil Eye c9783344a0 Wrap all memory allocating Lua functions in protected calls 2024-08-22 22:22:28 +02:00
psi29a 6754b8d941 Revert "Merge branch 'were_engineers_not_salt_miners' into 'master'"
This reverts merge request !4178
2024-06-25 20:58:31 +00:00
Dave Corleyandpsi29a 1a79e79f57 FEAT: Lua Engine Handler for MWScript startscript functionality 2024-06-24 07:09:23 +00:00
Petr Mikheev 71ba7b88e2 Move asyncpackage from apps/openmw/mwlua to components/lua 2023-02-14 20:03:32 +01:00
Petr Mikheev d9e9db0983 Additional information in Lua profiler 2023-01-13 21:14:23 +01:00
Petr Mikheev b248c3e173 Allow passing initData to the :addSript call (#7091) 2022-12-31 22:08:17 +01:00
Petr Mikheev 55db95d4cf Update Lua profiler; add ability to run OpenMW with old LuaJit that doesn't allow custom allocator (Lua profiler will be disabled in this case) 2022-12-03 16:58:03 +01:00
Petr Mikheev 6fa65e4729 Track memory and CPU usage per script in LuaUtil::LuaState 2022-11-30 00:06:14 +01:00
uramer a2fa1fe0a5 Execute async callbacks on the main Lua stack 2022-10-18 22:12:11 +02:00
clang-format-botandζeh Matt ddb0522bbf Apply clang-format to code base 2022-09-22 21:35:26 +03:00
Petr Mikheev a70d5831c5 Lua scripts configuration in omwaddon 2022-06-05 01:36:39 +02:00
Petr Mikheev d16fa553c8 Fix LuaUtil::Callback 2022-05-15 21:34:48 +02:00
Petr Mikheev eae1e87081 [Lua] Update openmw.storage 2022-04-23 18:55:12 +02:00
uramerandPetr Mikheev 36c46ada6f Pass unhandled Lua UI events to the parent 2022-03-14 19:07:23 +00:00
Petr Mikheev 2d1b100239 Change terminology of gameSecond/gameHour to simulationTime/gameTime 2022-01-10 21:03:35 +01:00
Petr Mikheev f9136d4392 Support multiple arguments in Lua callbacks. 2021-11-21 13:12:35 +01:00
Petr Mikheev e7ec89573e Refactoring. Lua Callback is moved from apps/openmw/mwlua to components/lua. 2021-10-31 17:47:46 +01:00
Petr Mikheev 4ec7f0625e Store Lua timers in std::map rather than in sol::table. 2021-10-26 21:32:48 +02:00
Petr Mikheev 9adc190209 Redesign LuaUtil::ScriptsContainer to work with ScriptsConfiguration 2021-10-26 21:32:48 +02:00
Petr Mikheev 24ecdc37a7 Fix crash in LuaUtil::ScriptsContainer::~ScriptsContainer() 2021-09-30 03:01:38 +02:00
Petr Mikheev fb3917fc1a Lua callbacks 2021-09-28 09:36:23 +02:00
Petr Mikheev 2f25257a3e Move LuaState::makeReadOnly(sol::table) out of the class because it doesn't need to access LuaState internals. 2021-09-19 14:38:27 +02:00
Petr Mikheev 702eb19271 Fixes and refactoring 2021-07-09 20:48:54 +02:00
Petr Mikheev cc7dbabd19 Change argument of onKeyPress 2021-07-09 20:48:54 +02:00
Petr Mikheev 479856f812 Add components/lua/scriptscontainer and components/esm/luascripts 2021-07-09 20:03:27 +02:00