[abrt/f20] Binary python modules in sitearch, upload-watch consuming too much of CPU

Jakub Filak jfilak at fedoraproject.org
Mon Feb 10 15:22:49 UTC 2014


commit 295a368bda7b69b3ec2809cfb0b2942bf0f803e8
Author: Jakub Filak <jfilak at redhat.com>
Date:   Mon Feb 10 15:46:35 2014 +0100

    Binary python modules in sitearch, upload-watch consuming too much of CPU
    
    Resolves: #1060020

 ...hon-install-modules-to-sitearch-directory.patch |   25 +++++
 ...upload-watch-remove-busy-wait-for-SIGUSR1.patch |  114 ++++++++++++++++++++
 abrt.spec                                          |   28 ++++-
 3 files changed, 162 insertions(+), 5 deletions(-)
---
diff --git a/0001-python-install-modules-to-sitearch-directory.patch b/0001-python-install-modules-to-sitearch-directory.patch
new file mode 100644
index 0000000..659ba70
--- /dev/null
+++ b/0001-python-install-modules-to-sitearch-directory.patch
@@ -0,0 +1,25 @@
+From e452c2b3586cc827d105e66b0bd08960a44e61a7 Mon Sep 17 00:00:00 2001
+From: Jakub Filak <jfilak at redhat.com>
+Date: Fri, 31 Jan 2014 11:09:46 +0100
+Subject: [ABRT PATCH 01/11] python: install modules to sitearch directory
+
+Signed-off-by: Jakub Filak <jfilak at redhat.com>
+---
+ src/python-problem/problem/Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/python-problem/problem/Makefile.am b/src/python-problem/problem/Makefile.am
+index cd8f04e..c7d99cb 100644
+--- a/src/python-problem/problem/Makefile.am
++++ b/src/python-problem/problem/Makefile.am
+@@ -1,6 +1,6 @@
+ problem_PYTHON = __init__.py exception.py proxies.py tools.py watch.py config.py
+ 
+-problemdir = $(pythondir)/problem
++problemdir = $(pyexecdir)/problem
+ 
+ pyabrtdir = $(problemdir)
+ pyabrt_LTLIBRARIES = _pyabrt.la
+-- 
+1.8.3.1
+
diff --git a/0011-upload-watch-remove-busy-wait-for-SIGUSR1.patch b/0011-upload-watch-remove-busy-wait-for-SIGUSR1.patch
new file mode 100644
index 0000000..dd0ad2a
--- /dev/null
+++ b/0011-upload-watch-remove-busy-wait-for-SIGUSR1.patch
@@ -0,0 +1,114 @@
+From c12b430997567f3d68ec8e7ba76674f20c27441b Mon Sep 17 00:00:00 2001
+From: Jakub Filak <jfilak at redhat.com>
+Date: Fri, 7 Feb 2014 17:54:14 +0100
+Subject: [ABRT PATCH 11/11] upload-watch: remove busy-wait for SIGUSR1
+
+Unconditional checking of SIGUSR1 flag in the idle source of main loop
+causes 100% CPU usage.
+
+hanle_sigusr() function and got_sigusr flag are not necessary because
+abrt-upload-watch already implements signal handling based on usage of
+GIO Channels.
+
+Closes rhbz#1060020
+
+Signed-off-by: Jakub Filak <jfilak at redhat.com>
+---
+ src/daemon/abrt-upload-watch.c | 37 +++++++++----------------------------
+ 1 file changed, 9 insertions(+), 28 deletions(-)
+
+diff --git a/src/daemon/abrt-upload-watch.c b/src/daemon/abrt-upload-watch.c
+index 59bfbe4..a42b285 100644
+--- a/src/daemon/abrt-upload-watch.c
++++ b/src/daemon/abrt-upload-watch.c
+@@ -27,7 +27,6 @@
+ #define DEFAULT_CACHE_MIB_SIZE 4
+ 
+ static int g_signal_pipe[2];
+-static sig_atomic_t got_sigusr;
+ 
+ struct queue
+ {
+@@ -122,24 +121,11 @@ handle_new_path(struct process *proc, char *name)
+     }
+ }
+ 
+-static gboolean
++static void
+ print_stats(struct process *proc)
+ {
+-    /* there is a race, because we run this function from 2 different places
+-     * 1st when a child dies
+-     * 2nd as idle source from mainloop
+-     * if it happens the stats will be printed twice, which I think
+-     * is not a big deal, because it's only for debug and tests
+-     */
+-    if (got_sigusr == 1)
+-    {
+-        got_sigusr = 0;
+-        /* this is meant only for debugging, so not marking it as translatable */
+-        fprintf(stderr, "%i archives to process, %i active workers\n", g_queue_get_length(&proc->queue.q), proc->children);
+-    }
+-
+-    /* don't remove this source from glib */
+-    return true;
++    /* this is meant only for debugging, so not marking it as translatable */
++    fprintf(stderr, "%i archives to process, %i active workers\n", g_queue_get_length(&proc->queue.q), proc->children);
+ }
+ 
+ static void
+@@ -157,13 +143,6 @@ process_next_in_queue(struct process *proc)
+ }
+ 
+ static void
+-handle_sigusr(int signo)
+-{
+-    /* just set the flag and process it synchronously */
+-    got_sigusr = 1;
+-}
+-
+-static void
+ handle_signal(int signo)
+ {
+     int save_errno = errno;
+@@ -200,7 +179,11 @@ handle_signal_pipe_cb(GIOChannel *gio, GIOCondition condition, gpointer user_dat
+         {
+             /* we did receive a signal */
+             log_debug("Got signal %d through signal pipe", signals[signo]);
+-            if (signals[signo] != SIGCHLD)
++            if (signals[signo] == SIGUSR1)
++            {
++                print_stats(proc);
++            }
++            else if (signals[signo] != SIGCHLD)
+             {
+                 process_quit(proc);
+                 return FALSE; /* remove this event */
+@@ -363,7 +346,7 @@ main(int argc, char **argv)
+     close_on_exec_on(g_signal_pipe[1]);
+     ndelay_on(g_signal_pipe[0]);
+     ndelay_on(g_signal_pipe[1]);
+-    signal(SIGUSR1, handle_sigusr);
++    signal(SIGUSR1, handle_signal);
+     signal(SIGTERM, handle_signal);
+     signal(SIGINT, handle_signal);
+     signal(SIGCHLD, handle_signal);
+@@ -373,7 +356,6 @@ main(int argc, char **argv)
+                 handle_signal_pipe_cb,
+                 &proc);
+ 
+-    int status_callback_source_id = g_idle_add((GSourceFunc)print_stats, &proc);
+     log_info("Starting glib main loop");
+ 
+     g_main_loop_run(proc.main_loop);
+@@ -381,7 +363,6 @@ main(int argc, char **argv)
+     log_info("Glib main loop finished");
+ 
+     g_source_remove(channel_signal_source_id);
+-    g_source_remove(status_callback_source_id);
+ 
+     GError *error = NULL;
+     g_io_channel_shutdown(channel_signal, FALSE, &error);
+-- 
+1.8.3.1
+
diff --git a/abrt.spec b/abrt.spec
index 1f0940f..5aa0142 100644
--- a/abrt.spec
+++ b/abrt.spec
@@ -40,12 +40,18 @@
 Summary: Automatic bug detection and reporting tool
 Name: abrt
 Version: 2.1.12
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2+
 Group: Applications/System
 URL: https://fedorahosted.org/abrt/
 Source: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.gz
 
+Patch1:  0001-python-install-modules-to-sitearch-directory.patch
+Patch11: 0011-upload-watch-remove-busy-wait-for-SIGUSR1.patch
+
+# '%%autosetup -S git' -> git
+BuildRequires: git
+
 BuildRequires: dbus-devel
 BuildRequires: gtk3-devel
 BuildRequires: rpm-devel >= 4.6
@@ -76,7 +82,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires: %{name}-libs = %{version}-%{release}
 Requires(pre): shadow-utils
 Requires: python-dbus
-Requires: libreport-plugin-ureport
+Requires: libreport-plugin-ureport >= %{libreport_ver}
 
 %description
 %{name} is a tool to help users to detect defects in applications and
@@ -368,10 +374,17 @@ A small script which prints a count of detected problems when someone logs in
 to the shell
 
 %prep
-%setup -q
+# http://www.rpm.org/wiki/PackagerDocs/Autosetup
+# Default '__scm_apply_git' is 'git apply && git commit' but this workflow
+# doesn't allow us to create a new file within a patch, so we have to use
+# 'git am' (see /usr/lib/rpm/macros for more details)
+%define __scm_apply_git(qp:m:) %{__git} am
+%autosetup -S git
+
+autoreconf --force --install
+intltoolize --force --copy --automake
 
 %build
-autoconf
 CFLAGS="%{optflags} -Werror" %configure --enable-doxygen-docs --disable-silent-rules
 make %{?_smp_mflags}
 
@@ -828,7 +841,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %{_defaultdocdir}/%{name}-dbus%{docdirversion}/html/*.css
 
 %files python
-%{python_sitelib}/problem/
+%{python_sitearch}/problem/
 %{_mandir}/man5/abrt-python.5.gz
 
 %files python-doc
@@ -838,6 +851,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %config(noreplace) %{_sysconfdir}/profile.d/abrt-console-notification.sh
 
 %changelog
+* Mon Feb 10 2014 Jakub Filak <jfilak at redhat.com> - 2.1.12-2
+- python: install modules to sitearch directory
+- upload-watch: remove busy-wait for SIGUSR1
+- Resolves: #1060020
+
 * Thu Jan 30 2014 Jakub Filak <jfilak at redhat.com> 2.1.12-1
 - don't break the event run by failures of abrt-action-notify
 - harvest-vmcore: properly handle inaccessible dir error


More information about the scm-commits mailing list