From b6841d75c2f259c84d5ab6b012bd2ae37d985451 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 15 Apr 2022 19:02:07 -0500 Subject: SL-17219 WIP - Texture pipeline overhaul --- indra/llcommon/lltimer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index aaa6df325c..b250bc3e1c 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -64,7 +64,8 @@ LLTimer* LLTimer::sTimer = NULL; #if LL_WINDOWS void ms_sleep(U32 ms) { - Sleep(ms); + LL_PROFILE_ZONE_SCOPED; + std::this_thread::sleep_for(std::chrono::microseconds(ms)); } U32 micro_sleep(U64 us, U32 max_yields) -- cgit v1.2.3 From 9bcc01e3e33c9152a0fb71de2b33e3e41b5a5534 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 24 May 2022 14:30:30 -0500 Subject: SL-17484 Build fix. --- indra/llcommon/lltimer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index b250bc3e1c..466f98f9b2 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -30,6 +30,9 @@ #include "u64.h" +#include +#include + #if LL_WINDOWS # include "llwin32headerslean.h" #elif LL_LINUX || LL_DARWIN -- cgit v1.2.3 From fc7b5549cb6092194d11b8d87600f21992305c1c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 31 May 2022 16:54:05 -0500 Subject: SL-17484 Fix for unit tests. Deprecate non-threaded LLQueuedThread and make lllfsthread threaded. --- indra/llcommon/lltimer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 466f98f9b2..39dfee3755 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -68,7 +68,12 @@ LLTimer* LLTimer::sTimer = NULL; void ms_sleep(U32 ms) { LL_PROFILE_ZONE_SCOPED; - std::this_thread::sleep_for(std::chrono::microseconds(ms)); + using TimePoint = std::chrono::steady_clock::time_point; + auto resume_time = TimePoint::clock::now() + std::chrono::milliseconds(ms); + while (TimePoint::clock::now() < resume_time) + { + std::this_thread::yield(); //note: don't use LLThread::yield here to avoid yielding for too long + } } U32 micro_sleep(U64 us, U32 max_yields) -- cgit v1.2.3 From ec5009d70eb0fd729126b2321b9d7d6118741573 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 13 Oct 2022 19:51:40 -0500 Subject: SL-18190 Potential fix for sapping CPU when "sleeping" --- indra/llcommon/lltimer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 39dfee3755..8739eeef00 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -65,6 +65,9 @@ LLTimer* LLTimer::sTimer = NULL; //--------------------------------------------------------------------------- #if LL_WINDOWS + + +#if 0 void ms_sleep(U32 ms) { LL_PROFILE_ZONE_SCOPED; @@ -83,6 +86,31 @@ U32 micro_sleep(U64 us, U32 max_yields) ms_sleep((U32)(us / 1000)); return 0; } + +#else + +U32 micro_sleep(U64 us, U32 max_yields) +{ + LL_PROFILE_ZONE_SCOPED + LARGE_INTEGER ft; + ft.QuadPart = -static_cast(us * 10); // '-' using relative time + + HANDLE timer = CreateWaitableTimer(NULL, TRUE, NULL); + SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); + + return 0; +} + +void ms_sleep(U32 ms) +{ + LL_PROFILE_ZONE_SCOPED + micro_sleep(ms * 1000, 0); +} + +#endif + #elif LL_LINUX || LL_DARWIN static void _sleep_loop(struct timespec& thiswait) { -- cgit v1.2.3 From 87bb72a47a1fc64b98e498120e332de76e6a9211 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 30 Nov 2022 13:25:00 -0600 Subject: SL-18154 WIP -- CPU sampling (AMD uProf) profile guided optimizations to reduce CPU usage of background threads. --- indra/llcommon/lltimer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon/lltimer.cpp') diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 8739eeef00..24eaa4c1a9 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -92,6 +92,7 @@ U32 micro_sleep(U64 us, U32 max_yields) U32 micro_sleep(U64 us, U32 max_yields) { LL_PROFILE_ZONE_SCOPED +#if 0 LARGE_INTEGER ft; ft.QuadPart = -static_cast(us * 10); // '-' using relative time @@ -99,6 +100,9 @@ U32 micro_sleep(U64 us, U32 max_yields) SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); WaitForSingleObject(timer, INFINITE); CloseHandle(timer); +#else + Sleep(us / 1000); +#endif return 0; } -- cgit v1.2.3