Skip to content

context: Limit trigger_gc_if_needed frequency to 5 minutes

Daniel van Vugt requested to merge vanvugt/gjs:gc-less-often-again into master

Instead of every 10 seconds.

When profiling cursor movement (mutter#283 (closed)) with fixes applied to specifically optimize cursor movement, trigger_gc_if_needed started appearing as one of the main remaining users of CPU. Just with cursor movement.

trigger_gc_if_needed would typically occupy 20%-80% of gnome-shell's CPU usage according to Google Profiler. And according to sysprof the function js::GCRuntime::collect would typically account for 98% or more of the JavaScript profile (which obviously makes finding other bottlenecks more difficult).

After changing the maximum frequency to every 5 minutes (30 times less often), garbage collection no longer shows up in short term performance profiles at all.

If we assume that most of the work was in the scanning process of trigger_gc_if_needed and not proportional to the amount of garbage collected then it stands to reason that long term power usage should also benefit from this change. So total power used is reduced and not just moved.

Helps with: mutter#283 (closed)

Merge request reports