GNOME Bugzilla – Bug 793006
High CPU load for GUnixMountsMonitor consumers
Last modified: 2018-01-30 14:48:38 UTC
When I cause hundreds of mounts changes within few seconds, GUnixMountsMonitor consumers (gsd-housekeeping, gvfsd-trash, gvfs-udisks2-volume-monitor...) are using tens of percent of CPU for some time, even after last real change... This happens only on systems which still uses /etc/mtab (e.g. RHEL 6, but also e.g. Arch Linux nowadays if I am not wrong). mounts_changed is emitted for each changed signal from GFileMonitor. If too many changes happened in a short time, GUnixMountsMonitor consumers are not able to handle mounts_changed signals in a real-time and processing still continues after last real change. However, most of the distributions currently use /proc/mounts and GIOChannel based monitoring is used for /proc/* files, which seems doesn't have this problem. See also discussion on Bug 792235 for more details. Just a note that it helps to reduce CPU load from tens of percents to units of percents in my test environment on RHEL 6 where /etc/mtab code is still used... See: https://bugzilla.redhat.com/show_bug.cgi?id=1154183
Created attachment 367576 [details] [review] gunixmounts: Skip accumulated events from file monitor Skip accumulated events from file monitor which we are not able to handle in a real time instead of emitting mounts_changed signal several times. This should behave equally to GIOChannel based monitoring. See Bug 792235.
(In reply to Ondrej Holy from comment #0) > Just a note that it helps to reduce CPU load from tens of percents to units The attachment 367576 [details] [review] helps to reduce CPU load of GUnixMountsMonitor consumers...
Review of attachment 367576 [details] [review]: ::: gio/gunixmounts.c @@ +1657,3 @@ static GSource *proc_mounts_watch_source; static GList *mount_poller_mounts; +static gint64 mtab_file_changed_id; It's a guint. Otherwise LGTM, feel free to push with that change!
For some reason Splinter isn't doing anything when I press submit. Anyways my comment is: It's a guint for source ID, not gint64. Feel free to push with that change!
Created attachment 367648 [details] [review] gunixmounts: Skip accumulated events from file monitor Thanks for your review. You are right, it is guint, updated...
Comment on attachment 367648 [details] [review] gunixmounts: Skip accumulated events from file monitor Pushed as commit 7e0d42e3dc7f64a11afcf124d635bf4ca435abd6.