Skip to content

Commit

Permalink
19235: Fixes slowdown with garbage collection when multithreading is …
Browse files Browse the repository at this point in the history
…used (#71)
  • Loading branch information
howsohazard authored Feb 7, 2024
1 parent 0b326a7 commit c18d7f2
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/Amalgam/evaluablenode/EvaluableNodeManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,13 @@ void EvaluableNodeManager::CollectGarbage()
//keep trying to acquire write lock to see if this thread wins the race to collect garbage
Concurrency::WriteLock write_lock(memoryModificationMutex, std::defer_lock);

Concurrency::threadPool.ChangeCurrentThreadStateFromActiveToWaiting();
do
{
if(!RecommendGarbageCollection())
{
if(memory_modification_lock != nullptr)
memory_modification_lock->lock();

Concurrency::threadPool.ChangeCurrentThreadStateFromWaitingToActive();

if(PerformanceProfiler::IsProfilingEnabled())
PerformanceProfiler::EndOperation(GetNumberOfUsedNodes());

Expand All @@ -206,15 +203,11 @@ void EvaluableNodeManager::CollectGarbage()
if(memory_modification_lock != nullptr)
memory_modification_lock->lock();

Concurrency::threadPool.ChangeCurrentThreadStateFromWaitingToActive();

if(PerformanceProfiler::IsProfilingEnabled())
PerformanceProfiler::EndOperation(GetNumberOfUsedNodes());

return;
}

Concurrency::threadPool.ChangeCurrentThreadStateFromWaitingToActive();
#endif

//perform garbage collection
Expand Down

0 comments on commit c18d7f2

Please sign in to comment.