[gnome-remote-desktop] session-rdp: Only signal GCond, when all encode jobs are complete



commit ad950d44b32c768db24847dbb0ea431704adfdf9
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Mon Oct 4 08:15:17 2021 +0200

    session-rdp: Only signal GCond, when all encode jobs are complete
    
    Currently, when using the raw bitmaps path, every worker thread in the
    raw bitmaps path signals the GCond for the thread pool once their task
    is done.
    However, this is wasteful, since the only necessary signal here is the
    final one, where the last tile is being encoded.
    
    So, make the signal call conditional. For a FullHD frame this saves
    about 509 unnecessary wakeups of the graphics thread.

 src/grd-session-rdp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/grd-session-rdp.c b/src/grd-session-rdp.c
index 6d9fe5f..22aefe0 100644
--- a/src/grd-session-rdp.c
+++ b/src/grd-session-rdp.c
@@ -802,7 +802,9 @@ rdp_peer_encode_nsc_rect (gpointer data,
 
   g_mutex_lock (thread_pool_context->pending_jobs_mutex);
   --thread_pool_context->pending_job_count;
-  g_cond_signal (thread_pool_context->pending_jobs_cond);
+
+  if (!thread_pool_context->pending_job_count)
+    g_cond_signal (thread_pool_context->pending_jobs_cond);
   g_mutex_unlock (thread_pool_context->pending_jobs_mutex);
 }
 
@@ -976,7 +978,9 @@ rdp_peer_compress_raw_tile (gpointer data,
 
   g_mutex_lock (thread_pool_context->pending_jobs_mutex);
   --thread_pool_context->pending_job_count;
-  g_cond_signal (thread_pool_context->pending_jobs_cond);
+
+  if (!thread_pool_context->pending_job_count)
+    g_cond_signal (thread_pool_context->pending_jobs_cond);
   g_mutex_unlock (thread_pool_context->pending_jobs_mutex);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]