diff --git a/Source/Engine/Profiler/ProfilerCPU.cpp b/Source/Engine/Profiler/ProfilerCPU.cpp index 2119a25d7..cab429d2c 100644 --- a/Source/Engine/Profiler/ProfilerCPU.cpp +++ b/Source/Engine/Profiler/ProfilerCPU.cpp @@ -12,7 +12,7 @@ bool ProfilerCPU::Enabled = false; ProfilerCPU::EventBuffer::EventBuffer() { - _capacity = Math::RoundUpToPowerOf2(10 * 1000); + _capacity = 8192; _capacityMask = _capacity - 1; _data = NewArray(_capacity); _head = 0; diff --git a/Source/Engine/Threading/JobSystem.cpp b/Source/Engine/Threading/JobSystem.cpp index 0a29bdecf..08bbef410 100644 --- a/Source/Engine/Threading/JobSystem.cpp +++ b/Source/Engine/Threading/JobSystem.cpp @@ -20,6 +20,7 @@ // JOB_SYSTEM_USE_MUTEX=0, enqueue=300-700 cycles, dequeue=10-16 cycles // So using RingBuffer+Mutex+Signals is better than moodycamel::ConcurrentQueue +#define JOB_SYSTEM_ENABLED 1 #define JOB_SYSTEM_USE_MUTEX 1 #define JOB_SYSTEM_USE_STATS 0 @@ -32,6 +33,8 @@ #include "ConcurrentQueue.h" #endif +#if JOB_SYSTEM_ENABLED + class JobSystemService : public EngineService { public: @@ -201,11 +204,14 @@ int32 JobSystemThread::Run() return 0; } +#endif + int64 JobSystem::Dispatch(const Function& job, int32 jobCount) { PROFILE_CPU(); if (jobCount <= 0) return 0; +#if JOB_SYSTEM_ENABLED #if JOB_SYSTEM_USE_STATS const auto start = Platform::GetTimeCycles(); #endif @@ -234,15 +240,23 @@ int64 JobSystem::Dispatch(const Function& job, int32 jobCount) JobsSignal.NotifyAll(); return label; +#else + for (int32 i = 0; i < jobCount; i++) + job(i); + return 0; +#endif } void JobSystem::Wait() { +#if JOB_SYSTEM_ENABLED Wait(Platform::AtomicRead(&NextLabel)); +#endif } void JobSystem::Wait(int64 label) { +#if JOB_SYSTEM_ENABLED PROFILE_CPU(); // Early out @@ -262,4 +276,5 @@ void JobSystem::Wait(int64 label) LOG(Info, "Job average dequeue time: {0} cycles", DequeueSum / DequeueCount); DequeueSum = DequeueCount = 0; #endif +#endif } diff --git a/Source/Engine/Threading/ThreadLocal.h b/Source/Engine/Threading/ThreadLocal.h index b37b18661..c3395ff56 100644 --- a/Source/Engine/Threading/ThreadLocal.h +++ b/Source/Engine/Threading/ThreadLocal.h @@ -69,7 +69,8 @@ public: return result; } - void GetValues(Array& result) const + template + void GetValues(Array& result) const { result.EnsureCapacity(MaxThreads); for (int32 i = 0; i < MaxThreads; i++) @@ -134,7 +135,8 @@ public: } } - void GetNotNullValues(Array& result) const + template + void GetNotNullValues(Array& result) const { result.EnsureCapacity(MaxThreads); for (int32 i = 0; i < MaxThreads; i++)