After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 793006 - High CPU load for GUnixMountsMonitor consumers
High CPU load for GUnixMountsMonitor consumers
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2018-01-29 14:58 UTC by Ondrej Holy
Modified: 2018-01-30 14:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gunixmounts: Skip accumulated events from file monitor (2.09 KB, patch)
2018-01-29 14:59 UTC, Ondrej Holy
none Details | Review
gunixmounts: Skip accumulated events from file monitor (2.09 KB, patch)
2018-01-30 14:45 UTC, Ondrej Holy
committed Details | Review

Description Ondrej Holy 2018-01-29 14:58:15 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
Comment 1 Ondrej Holy 2018-01-29 14:59:34 UTC
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.
Comment 2 Ondrej Holy 2018-01-29 15:31:20 UTC
(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...
Comment 3 Colin Walters 2018-01-29 20:05:04 UTC
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!
Comment 4 Colin Walters 2018-01-29 20:06:56 UTC
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!
Comment 5 Ondrej Holy 2018-01-30 14:45:12 UTC
Created attachment 367648 [details] [review]
gunixmounts: Skip accumulated events from file monitor

Thanks for your review. You are right, it is guint, updated...
Comment 6 Ondrej Holy 2018-01-30 14:48:11 UTC
Comment on attachment 367648 [details] [review]
gunixmounts: Skip accumulated events from file monitor

Pushed as commit 7e0d42e3dc7f64a11afcf124d635bf4ca435abd6.