> On Sunday 11 October 2009 10:58:01 Al Dimond wrote:
>> On Sunday 11 October 2009 04:04:00 Michael Schwendt wrote:
>>> On Sun, 11 Oct 2009 00:07:28 -0600, Al wrote:
>>>> Well, I might be repro-ing it. Something weird is going on, at least.
>>>> Audacity has been sitting untouched on another desktop for 20 minutes
>>>> and its CPU usage is reading 32%, and has been steadily rising. But
>>>> what's odd is that the load average is not rising with it; it's been
>>>> close to 0 the whole time (occasionally rising when I do something
>>>> else).
>>> Meanwhile, I'm able to reproduce it. Simply by starting Audacity and not
>>> touching it further. It's already reproducible without clicking away the
>>> "Welcome to Audacity" dialog. CPU usage doesn't jump up, but increases
>>> consecutively and _slowly_. I switch the display to another workspace and
>>> then run "top" in a terminal to observe it.
>>>
>>> One trick is to _not_ give Audacity focus. Once it gets focus, cpu usage
>>> jumps down. The symptoms smell a bit like something piles up somewhere
>>> (e.g. GUI events) while the window is inactive.
>> Yeah, that's exactly what I'm doing. I left it running like that all night
>> and top reported CPU usage of 99.9%, CPU0 pegged, and each of the load
>> averages around 1.5. Just two Audacity threads. And when I focused it it
>> stopped. It's odd that I can repro it now but couldn't before my dist-
>> upgrade...
>>
>> Anyhow, I'm going to try to run it in a profiler. Unfortunately it seems
>> that every single profiler package is broken currently in Ubuntu... guess
>> I'll have to build one.
>>
>
> Here's what I have so far (to replicate this you need to have debug symbols
> for glib).
>
> 1. From oprofile I found that almost all of the time is being spent in a glib
> function called g_hook_insert_before. Unfortunately callgraph support wasn't
> helping much (perhaps glib was compiled with -fomit-frame-pointer).
>
> 2. Here's a stacktrace of a typical g_hook_insert_before() call from gdb:
>
> (gdb) where
> #0 IA__g_hook_insert_before (hook_list=0x22351c0, sibling=0x0,
> hook=0x23525e0) at /build/buildd/glib2.0-2.22.2/glib/ghook.c:242
> #1 0x00007ffff24b9b06 in IA__g_signal_add_emission_hook (signal_id=<value
> optimized out>, detail=0, hook_func=0x7ffff6951de0 <event_emission_hook>,
> hook_data=0x0, data_destroy=0) at
> /build/buildd/glib2.0-2.22.2/gobject/gsignal.c:939
> #2 0x00007ffff6952549 in wxAddEmissionHook () at ../src/gtk/app.cpp:167
> #3 wxapp_idle_callback () at ../src/gtk/app.cpp:188
> #4 0x00007ffff2212bbe in g_main_dispatch (context=0x1c61920) at
> /build/buildd/glib2.0-2.22.2/glib/gmain.c:1960
> #5 IA__g_main_context_dispatch (context=0x1c61920) at
> /build/buildd/glib2.0-2.22.2/glib/gmain.c:2513
> #6 0x00007ffff2216588 in g_main_context_iterate (context=0x1c61920,
> block=<value optimized out>, dispatch=<value optimized out>, self=<value
> optimized out>)
> at /build/buildd/glib2.0-2.22.2/glib/gmain.c:2591
> #7 0x00007ffff22169e5 in IA__g_main_loop_run (loop=0x2250330) at
> /build/buildd/glib2.0-2.22.2/glib/gmain.c:2799
> #8 0x00007ffff2acc0e7 in IA__gtk_main () at
> /build/buildd/gtk+2.0-2.18.2/gtk/gtkmain.c:1216
> #9 0x00007ffff696bb48 in wxEventLoop::Run (this=0x224fbe0) at
> ../src/gtk/evtloop.cpp:76
> #10 0x00007ffff69fbec8 in wxAppBase::MainLoop (this=0x1d0a100) at
> ../src/common/appcmn.cpp:312
> #11 0x00007ffff60513bc in wxEntry (argc=<value optimized out>, argv=<value
> optimized out>) at ../src/common/init.cpp:460
> #12 0x00000000005436f2 in main (argc=1, argv=0x7fffffffe238) at
> AudacityApp.cpp:598
>
> 3. g_signal_add_emission_hook() calls a macro, g_hook_append, which expands to
> calling g_hook_insert_before() with the "sibling" parameter NULL, which causes
> it to append. We appear to be appending to a list of hooks for signal 37,
> with name "event" (according to the node structure used in
> g_signal_add_emission_hook). The list of hooks is a linked list, so to append
> it must cycle through every hook in the list. You may see what I'm getting
> at.
>
> 4. The list of hooks continually expands when Audacity is idle. After just
> several seconds of idling gdb counts 7000 hooks on the list. All of them
> point to the function event_emission_hook(), which for me is in
> libwx_gtk2ud_core-2.8.so.0; all of them have ->data == NULL.
>
> 5. I set a breakpoint at g_hook_list_clear, but it's never hit. Rather, these
> hooks seem to be reference-counted (when the count hits zero they're removed
> from the list). Reference counts are all set to 1 when the hooks are inserted
> into the list; glib source notes that the counterpart to this is a
> g_hook_unref() call in g_hook_destroy_link(). g_hook_destroy_link() is
> called, in our case, from signal_emit_unlocked_R(). This seems to only happen
> when the window has focus.
>
> That's what I have now. I don't know very much about GTK or wxGTK, though.
> WX seems to continually add emission hooks, but events are not being emitted.
> And seemingly the only problem this causes is that a linked list gets really
> long; it doesn't eat much memory (16 bytes per hook... so a modern system
> won't really have problems until you make several million of them). I'll look
> through some of the relevant wx source and see if I can figure out what's going
> on there; it may well be Audacity's fault, but I at least have a function name
> in wxGTK to look at that might lead me back. I'm just posting all this in
> case someone with more WX and GTK knowledge can figure it out from here.
>
> - Al
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>
http://p.sf.net/sfu/devconference> _______________________________________________
> audacity-devel mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/audacity-devel>
is the only developer event you need to attend this year. Jumpstart your
ahead of the curve. Join us from November 9 - 12, 2009. Register now!