[gjs: 1/2] context: Defer and therefore batch forced GC runs



commit e62ee84a0ecb5b20928c0369a79969ea6a0b2142
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Fri Oct 5 18:24:58 2018 +0800

    context: Defer and therefore batch forced GC runs
    
    Since commit e9e969553, forced GC runs get queued very often in some
    cases. For example, during the gnome-shell icon spring animation around
    60% of gnome-shell's CPU time was spent in `trigger_gc_if_needed`.
    That's too much.
    
    We now defer the forced GC runs by 10 seconds, which provides two
    significant performance benefits:
    
      1. Animations triggering garbage collection are unlikely to have their
         performance adversely affected by the run because the animation
         will be finished before it starts.
    
      2. The total number of garbage collection runs is much lower because
         they're more likely to have been batched into the same run.
    
    This has the observed benefit, for example, of reducing the CPU usage
    of the gnome-shell icon spring animation from 78% to 47% on an i7-7700
    (a 40% relative reduction).
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/582

 gjs/context.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index b29447df..d07213ee 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -636,9 +636,10 @@ _gjs_context_schedule_gc_internal(GjsContext *js_context,
     if (js_context->auto_gc_id > 0)
         return;
 
-    js_context->auto_gc_id = g_idle_add_full(G_PRIORITY_LOW,
-                                             trigger_gc_if_needed,
-                                             js_context, NULL);
+    js_context->auto_gc_id = g_timeout_add_full(G_PRIORITY_LOW,
+                                                10000,
+                                                trigger_gc_if_needed,
+                                                js_context, NULL);
 }
 
 void


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