From 36ec3cbcf88e9dc4898bbe2319cc4a5a71ba72e1 Mon Sep 17 00:00:00 2001 From: Tomasz Pyra Date: Tue, 10 Mar 2020 13:00:03 +0100 Subject: [PATCH] gallium/swr: spin-lock performance improvement Currently, the worker threads are very aggresively polling for new tasks. If the work is not constantly fed into the pipeline (which is a case for most of interactive applications), this creates unnecessary memory pressure and is using CPU cycles that could otherwise be used by the applications. The change implements simple back off mechanism to help with this problem Change by Tomasz Pyra (tomasz.pyra@intel.com) Reviewed-by: Alok Hota Reviewed-by: Jan Zielinski Tested-by: Marge Bot Part-of: --- .../drivers/swr/rasterizer/core/threads.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp index c75fb568431..556e02e99ef 100644 --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp @@ -592,17 +592,20 @@ bool WorkOnFifoBE(SWR_CONTEXT* pContext, pDC->pTileMgr->getTileIndices(tileID, x, y); if (((x ^ y) & numaMask) != numaNode) { + _mm_pause(); continue; } if (!tile->getNumQueued()) { + _mm_pause(); continue; } // can only work on this draw if it's not in use by other threads if (lockedTiles.get(tileID)) { + _mm_pause(); continue; } @@ -663,6 +666,7 @@ bool WorkOnFifoBE(SWR_CONTEXT* pContext, // This tile is already locked. So let's add it to our locked tiles set. This way we // don't try locking this one again. lockedTiles.set(tileID); + _mm_pause(); } } } @@ -750,7 +754,7 @@ void WorkOnFifoFE(SWR_CONTEXT* pContext, uint32_t workerId, uint32_t& curDrawFE) uint32_t dcSlot = curDraw % pContext->MAX_DRAWS_IN_FLIGHT; DRAW_CONTEXT* pDC = &pContext->dcRing[dcSlot]; - if (!pDC->isCompute && !pDC->FeLock) + if (!pDC->FeLock && !pDC->isCompute) { if (CheckDependencyFE(pContext, pDC, lastRetiredFE)) { @@ -765,7 +769,16 @@ void WorkOnFifoFE(SWR_CONTEXT* pContext, uint32_t workerId, uint32_t& curDrawFE) CompleteDrawFE(pContext, workerId, pDC); } + else + { + _mm_pause(); + } + } + else + { + _mm_pause(); } + curDraw++; } } -- 2.30.2