Possible small GC optimization or bad idea?

On average FRenderCommandFence::IsFenceComplete() is called once per tick. However, during heavy Garbage Collection with streaming worlds, this call can happen many thousands of times per second.

In turn, IsFenceComplete() calls CheckRenderingThreadHealth() that calls FWindowsPlatformApplicationMisc::PumpMessages().

We have a feeling that calling CheckRenderingThreadHealth() at this rate is unnecessary. These calls seem to mostly just do a few checks and return but they are not free on a possibly already lengthy GC process.

A simple way to mitigate this, so far without any side effects.

RenderingThread.cpp:

…
#include "UObject/GarbageCollection.h"
…
bool FRenderCommandFence::IsFenceComplete() const
…
#if (UE_BUILD_TEST || UE_BUILD_SHIPPING)
   if (!GIsGarbageCollecting)
   {
      CheckRenderingThreadHealth();
   }
#else
   CheckRenderingThreadHealth();
#endif
1 Like