Skip to content

Commit 67b74c5

Browse files
committed
Chose a middle ground
1 parent a3670aa commit 67b74c5

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

Source/Managers/LuaMan.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ void LuaStateWrapper::Initialize() {
3333
luabind::open(m_State);
3434
tracy::LuaRegister(m_State);
3535

36-
if (!g_SettingsMan.LuaMultithreadedGarbageCollectionDisabled())
37-
{
38-
// Disable gc. We do this manually, so we can thread it to occur parallel with non-lua updates
39-
// See LuaMan::StartAsyncGarbageCollection()
40-
lua_gc(m_State, LUA_GCSTOP, 0);
41-
}
36+
// We do async GC, but we still keep the normal GC on so it can catch any big spikes or runaway allocs
37+
//lua_gc(m_State, LUA_GCSTOP, 0);
4238

4339
const luaL_Reg libsToLoad[] = {
4440
// Basic Lua libraries
@@ -1282,11 +1278,6 @@ void LuaMan::Update() {
12821278
void LuaMan::StartAsyncGarbageCollection() {
12831279
ZoneScoped;
12841280

1285-
if (g_SettingsMan.LuaMultithreadedGarbageCollectionDisabled())
1286-
{
1287-
return;
1288-
}
1289-
12901281
std::vector<LuaStateWrapper*> allStates;
12911282
allStates.reserve(m_ScriptStates.size() + 1);
12921283

@@ -1301,7 +1292,7 @@ void LuaMan::StartAsyncGarbageCollection() {
13011292
g_ThreadMan.GetPriorityThreadPool().submit([luaState]() {
13021293
ZoneScopedN("Lua Garbage Collection");
13031294
std::lock_guard<std::recursive_mutex> lock(luaState->GetMutex());
1304-
lua_gc(luaState->GetLuaState(), LUA_GCCOLLECT, 0);
1295+
lua_gc(luaState->GetLuaState(), LUA_GCSTEP, 100);
13051296
lua_gc(luaState->GetLuaState(), LUA_GCSTOP, 0);
13061297
}));
13071298
}

Source/Managers/SettingsMan.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ void SettingsMan::Clear() {
5151
m_AIUpdateInterval = 2;
5252
m_NumberOfLuaStatesOverride = -1;
5353
m_ForceImmediatePathingRequestCompletion = false;
54-
m_LuaMultithreadedGarbageCollectionDisabled = true;
5554

5655
m_SkipIntro = false;
5756
m_ShowToolTips = true;
@@ -168,7 +167,6 @@ int SettingsMan::ReadProperty(const std::string_view& propName, Reader& reader)
168167
MatchProperty("AIUpdateInterval", { reader >> m_AIUpdateInterval; });
169168
MatchProperty("NumberOfLuaStatesOverride", { reader >> m_NumberOfLuaStatesOverride; });
170169
MatchProperty("ForceImmediatePathingRequestCompletion", { reader >> m_ForceImmediatePathingRequestCompletion; });
171-
MatchProperty("LuaMultithreadedGarbageCollectionDisabled", { reader >> m_LuaMultithreadedGarbageCollectionDisabled; });
172170
MatchProperty("EnableParticleSettling", { reader >> g_MovableMan.m_SettlingEnabled; });
173171
MatchProperty("EnableMOSubtraction", { reader >> g_MovableMan.m_MOSubtractionEnabled; });
174172
MatchProperty("DeltaTime", { g_TimerMan.SetDeltaTimeSecs(std::stof(reader.ReadPropValue())); });

Source/Managers/SettingsMan.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ namespace RTE {
104104
/// Gets whether pathing requests will be forced to immediately complete for the next frame, or if they can take multiple frames to calculate.
105105
/// @return Whether pathing requests will be forced to immediately complete for the next frame
106106
bool GetForceImmediatePathingRequestCompletion() const { return m_ForceImmediatePathingRequestCompletion; }
107-
108-
/// Gets whether Lua multithreaded garbage collection is disabled.
109-
/// @return Whether Lua multithreaded garbage collection is disabled.
110-
bool LuaMultithreadedGarbageCollectionDisabled() const { return m_LuaMultithreadedGarbageCollectionDisabled; }
111107
#pragma endregion
112108

113109
#pragma region Gameplay Settings
@@ -402,7 +398,6 @@ namespace RTE {
402398
int m_AIUpdateInterval; //!< How often actor's AI should be updated, i.e. every n simulation updates.
403399
int m_NumberOfLuaStatesOverride; //!< Overrides how many threaded Lua states we'll use. -1 for no override, which defaults to the maximum number of concurrent hardware threads.
404400
bool m_ForceImmediatePathingRequestCompletion; //!< Whether pathing requests will be forced to immediately complete for the next frame, or if they can take multiple frames to calculate.
405-
bool m_LuaMultithreadedGarbageCollectionDisabled; //!< Whether Lua multithreaded garbage collection is disabled.
406401

407402
bool m_SkipIntro; //!< Whether to play the intro of the game or skip directly to the main menu.
408403
bool m_ShowToolTips; //!< Whether ToolTips are enabled or not.

0 commit comments

Comments
 (0)