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 555834 - Patch reducing CPU usage in visualization pipeline
Patch reducing CPU usage in visualization pipeline
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: GStreamer
git master
Other Linux
: Normal minor
: 1.6
Assigned To: Aaron Bockover
Banshee Maintainers
Depends on: 561281
Blocks: 572590
 
 
Reported: 2008-10-10 19:00 UTC by Chris Howie
Modified: 2009-04-28 04:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (3.79 KB, patch)
2008-10-10 19:01 UTC, Chris Howie
none Details | Review
New patch (7.60 KB, patch)
2008-10-10 21:52 UTC, Chris Howie
needs-work Details | Review
New new patch! (8.51 KB, patch)
2008-11-12 06:50 UTC, Chris Howie
none Details | Review
Even newer new patch!! (8.84 KB, patch)
2008-11-14 03:22 UTC, Chris Howie
needs-work Details | Review
New NEW patch!!!1!one! (8.93 KB, patch)
2008-11-15 17:25 UTC, Chris Howie
reviewed Details | Review
Work around the crash on exit (901 bytes, patch)
2008-11-15 23:22 UTC, Bertrand Lorentz
none Details | Review
Fantabulous patch (15.78 KB, patch)
2009-01-21 01:16 UTC, Chris Howie
none Details | Review
Stupendicular patch (16.58 KB, patch)
2009-01-22 19:34 UTC, Chris Howie
none Details | Review
New patch against r4961 (16.67 KB, patch)
2009-01-26 02:46 UTC, Chris Howie
reviewed Details | Review
New patch against r5021 (17.52 KB, patch)
2009-02-10 19:27 UTC, Chris Howie
none Details | Review
Patch updated to work on git master (18.51 KB, patch)
2009-04-24 06:55 UTC, Aaron Bockover
committed Details | Review

Description Chris Howie 2008-10-10 19:00:55 UTC
Attached is a patch that reduces the (rather large) increase in CPU usage associated with the visualization pipeline.  Usage should now be only about 1.25 to 1.75 times the normal CPU usage of banshee.
Comment 1 Chris Howie 2008-10-10 19:01:15 UTC
Created attachment 120358 [details] [review]
Patch
Comment 2 Chris Howie 2008-10-10 21:52:13 UTC
Created attachment 120364 [details] [review]
New patch

Updated patch.  Now almost completely disables the visualization pipeline when the callback is NULL, which happens when nothing is listening to the event on the managed side.

The only thing left running is a 5-second queue so when visualization resumes there is data available immediately.  This doesn't seem to have any significant impact on performance.
Comment 3 Bertrand Lorentz 2008-10-11 11:14:40 UTC
With this patch and the latest Banshee.OpenVP trunk, I see no noticeable difference in CPU load when the visualization source is not selected.

Great job !
Comment 4 Chris Howie 2008-10-30 16:20:26 UTC
I've discovered a nasty bug in this patch related to how gstreamer detects when a pipeline is done running.  Let me try to resolve this issue before any patch is applied to trunk.
Comment 5 Andrew Conkling 2008-10-30 19:10:59 UTC
Marking patch "needs_work" as per previous comment.
Comment 6 Chris Howie 2008-11-12 06:50:24 UTC
Created attachment 122473 [details] [review]
New new patch!

Fixes issue with previous patch.  (When the visualizer was not the active source, a playing song would continue "playing" until the visualizer was activated.)
Comment 7 Bertrand Lorentz 2008-11-13 20:32:16 UTC
After applying the patch and with the Banshee.OpenVP extension, I have the following problem :
1. Start banshee
2. play a track
3. Go to the Visualization source
4. Pause the track
5. Quit banshee
I get the following stack trace :
[Debug 21:28:30.792] Service disposed (AudioscrobblerService)
[Debug 21:28:30.797] Service disposed (Network)
[Debug 21:28:30.847] Service disposed (LastfmRecommendationService)
[Debug 21:28:30.860] Service disposed (AudioCdService)
[Debug 21:28:30.867] Service disposed (NotificationAreaService)
[Debug 21:28:30.912] Service disposed (DapService)
[Debug 21:28:30.915] Service disposed (BookmarksService)
[Debug 21:28:30.921] Service disposed (MultimediaKeysService)
[Debug 21:28:30.929] Service disposed (NereidPlayerInterface)
[Debug 21:28:30.930] Service disposed (CollectionIndexerService)
[Debug 21:28:30.933] Service disposed (HardwareManager)
[Debug 21:28:30.936] (libbanshee:player) bp_stop: setting state to GST_STATE_NULL
[Debug 21:28:31.012] Player state change: Paused -> Idle
[Debug 21:28:31.020] (libbanshee:player) bp_destroy: disposed player
[Debug 21:28:31.026] Service disposed (PlayerEngine)
[Debug 21:28:31.096] Service disposed (SourceManager)
[Debug 21:28:31.102] Service disposed (DbConnection)
Stacktrace:


Native stacktrace:

	/usr/bin/mono [0x817f8e4]
	/usr/bin/mono [0x80802b0]
	[0x4001c40c]

Debug info from gdb:

(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 0x402966e0 (LWP 24402)]
[New Thread 0x47600b90 (LWP 24435)]
[New Thread 0x45445b90 (LWP 24431)]
[New Thread 0x44e15b90 (LWP 24413)]
[New Thread 0x438e3b90 (LWP 24412)]
[New Thread 0x43ae4b90 (LWP 24411)]
[New Thread 0x40f91b90 (LWP 24404)]
[New Thread 0x40912b90 (LWP 24403)]
(no debugging symbols found)
...
Comment 8 Bertrand Lorentz 2008-11-13 20:34:35 UTC
Might be helpful : The following actions
1. Start banshee, do not play anything
2. Go to the Visualization source
3. Quit banshee
Gets me the following messages :

[Debug 21:31:54.339] Service disposed (CoverArtService)
[Debug 21:31:54.340] Service disposed (GStreamerCoreService)
[Debug 21:31:54.440] Service disposed (PodcastService)
[Debug 21:31:54.441] Service disposed (GnomeService)
[Debug 21:31:54.446] Service disposed (AudioscrobblerService)
[Debug 21:31:54.455] Service disposed (Network)
[Debug 21:31:54.465] Service disposed (LastfmRecommendationService)
[Debug 21:31:54.525] Service disposed (AudioCdService)
[Debug 21:31:54.533] Service disposed (NotificationAreaService)
[Debug 21:31:54.540] Service disposed (DapService)
[Debug 21:31:54.541] Service disposed (BookmarksService)
[Debug 21:31:54.587] Service disposed (MultimediaKeysService)
[Debug 21:31:54.591] Service disposed (NereidPlayerInterface)
[Debug 21:31:54.592] Service disposed (CollectionIndexerService)
[Debug 21:31:54.594] Service disposed (HardwareManager)
[Debug 21:31:54.603] (libbanshee:player) bp_stop: setting state to GST_STATE_NULL
[Debug 21:31:54.605] (libbanshee:player) bp_destroy: disposed player
[Debug 21:31:54.605] Service disposed (PlayerEngine)
[Debug 21:31:54.677] Service disposed (SourceManager)
[Debug 21:31:54.722] Service disposed (DbConnection)

(Nereid:24527): GStreamer-CRITICAL **: gst_element_get_static_pad: assertion `GST_IS_ELEMENT (element)' failed

(Nereid:24527): GStreamer-CRITICAL **: gst_pad_set_blocked_async: assertion `GST_IS_PAD (pad)' failed

(Nereid:24527): GStreamer-CRITICAL **: gst_object_unref: assertion `object != NULL' failed
Comment 9 Chris Howie 2008-11-14 03:22:07 UTC
Created attachment 122626 [details] [review]
Even newer new patch!!

Thanks Bertrand.  I think this new patch fixes those issues.
Comment 10 Bertrand Lorentz 2008-11-14 20:20:25 UTC
Better, but not perfect ;)
The GStreamer-CRITICAL are gone, but still crashing on exit with those steps :
1. Start banshee
2. play a track
3. Go to the Visualization source
4. Pause the track
5. Quit banshee

[Debug 21:15:21.201] Player state change: Playing -> Paused
[Debug 21:15:24.864] Service disposed (CoverArtService)
[Debug 21:15:24.864] Service disposed (GStreamerCoreService)
[Debug 21:15:24.964] Service disposed (PodcastService)
[Debug 21:15:24.965] Service disposed (GnomeService)
[Debug 21:15:24.969] Track Alanis Morissette - Moratorium (on Flavors Of Entanglement) <00:05:35.2730000> [file:///home/lorentz/Music/Library/Alanis%20Morissette/Flavors%20Of%20Entanglement/08%20-%20Moratorium.mp3] had playtime of 14947 msec (14sec), duration 335273 msec, queued: False
[Debug 21:15:24.981] Service disposed (AudioscrobblerService)
[Debug 21:15:24.986] Service disposed (Network)
[Debug 21:15:25.038] Service disposed (LastfmRecommendationService)
[Debug 21:15:25.053] Service disposed (AudioCdService)
[Debug 21:15:25.059] Service disposed (NotificationAreaService)
[Debug 21:15:25.108] Service disposed (DapService)
[Debug 21:15:25.109] Service disposed (BookmarksService)
[Debug 21:15:25.115] Service disposed (MultimediaKeysService)
[Debug 21:15:25.125] Service disposed (NereidPlayerInterface)
[Debug 21:15:25.126] Service disposed (CollectionIndexerService)
[Debug 21:15:25.129] Service disposed (HardwareManager)
[Debug 21:15:25.228] (libbanshee:player) bp_stop: setting state to GST_STATE_NULL
[Debug 21:15:25.320] Player state change: Paused -> Idle
[Debug 21:15:25.333] (libbanshee:player) bp_destroy: disposed player
[Debug 21:15:25.334] Service disposed (PlayerEngine)
[Debug 21:15:25.416] Service disposed (SourceManager)
[Debug 21:15:25.421] Service disposed (DbConnection)
Stacktrace:

  at (wrapper managed-to-native) Banshee.GStreamer.PlayerEngine.bp_set_vis_data_callback (System.Runtime.InteropServices.HandleRef,Banshee.GStreamer.BansheePlayerVisDataCallback) <0x00004>
  at (wrapper managed-to-native) Banshee.GStreamer.PlayerEngine.bp_set_vis_data_callback (System.Runtime.InteropServices.HandleRef,Banshee.GStreamer.BansheePlayerVisDataCallback) <0xffffffff>
  at Banshee.GStreamer.PlayerEngine.remove_DataAvailable (Banshee.MediaEngine.VisualizationDataHandler) [0x00029] in /home/lorentz/Projets/banshee/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs:104
  at Banshee.OpenVP.BansheePlayerData.set_Active (bool) [0x00034] in /home/lorentz/Projets/openvisualizationplatform-trunk/Banshee.OpenVP/Banshee.OpenVP/BansheePlayerData.cs:55
  at Banshee.OpenVP.BansheePlayerData.Dispose () [0x00000] in /home/lorentz/Projets/openvisualizationplatform-trunk/Banshee.OpenVP/Banshee.OpenVP/BansheePlayerData.cs:97
  at Banshee.OpenVP.VisualizationDisplayWidget.RenderLoop () [0x000a0] in /home/lorentz/Projets/openvisualizationplatform-trunk/Banshee.OpenVP/Banshee.OpenVP/VisualizationDisplayWidget.cs:133
  at (wrapper runtime-invoke) System.Object.runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	/usr/bin/mono [0x817f8e4]
	/usr/bin/mono [0x80802b0]
	[0x4001c40c]
	./libbanshee.so [0x43cef558]
	./libbanshee.so(bp_set_vis_data_callback+0x28) [0x43cef5c8]
	[0x457482cc]
	[0x47e59dd3]
	[0x45748140]
	[0x47e59d15]
	[0x45747df6]
	[0x408ff911]
	/usr/bin/mono(mono_runtime_delegate_invoke+0x36) [0x80ea4d6]
	/usr/bin/mono [0x80c85fd]
	/usr/bin/mono [0x811f6b2]
	/usr/bin/mono [0x8139e45]
	/lib/libpthread.so.0 [0x4012d18b]
	/lib/libc.so.6(clone+0x5e) [0x4022709e]
Comment 11 Chris Howie 2008-11-15 17:25:02 UTC
Created attachment 122736 [details] [review]
New NEW patch!!!1!one!

Bertrand:

I was unable to reproduce the crash you mentioned but based on the console output it looks like either a race or some random order of disposal that's different.  This patch should fix the case where the player gets disposed before the OpenVP extension.
Comment 12 Bertrand Lorentz 2008-11-15 20:02:00 UTC
With this patch, I still have the same crash on exit.
Tell me if I can do more to help track this one down.
Comment 13 Bertrand Lorentz 2008-11-15 23:22:30 UTC
Created attachment 122753 [details] [review]
Work around the crash on exit

Here's a ridiculously bad patch to prevent my crash on exit.
It has to be applied on top of the latest one from Chris.

Doesn't make much sense to me, unless strange things are happening to player->vis_resampler...
Comment 14 Chris Howie 2008-11-17 16:09:58 UTC
(In reply to comment #12)
> With this patch, I still have the same crash on exit.
> Tell me if I can do more to help track this one down.

Please try with the latest Banshee.OpenVP.  I believe the bug was located there.
Comment 15 Bertrand Lorentz 2008-11-17 19:35:32 UTC
I updated Banshee.OpenVP from svn trunk, but I still have the same crash. :(
Comment 16 Chris Howie 2008-11-17 19:45:19 UTC
(In reply to comment #15)
> I updated Banshee.OpenVP from svn trunk, but I still have the same crash. :(

Then this crash is a problem with Banshee itself, where it's disposing of two objects simultaneously: the GStreamer.PlayerEngine and the stack of sources.  Can we modify Banshee so it's not disposing of stuff from more than one thread during shutdown?
Comment 17 Bertrand Lorentz 2008-11-17 22:42:47 UTC
Chris' latest patch is fine for me, my crash is caused by a problem in Banshee.GStreamer.PlayerEngine. See bug #561281.

Btw, CPU usage is normal when the visualization source is not selected.
Comment 18 Chris Howie 2009-01-21 01:16:01 UTC
Created attachment 126886 [details] [review]
Fantabulous patch

New patch.  Fixes issues with the spectrum analysis and also includes a patch for #561281.
Comment 19 Chris Howie 2009-01-22 19:34:48 UTC
Created attachment 127031 [details] [review]
Stupendicular patch

Ok, this is the last patch for a while.  Sorry about all the noise.

This patch fixes a lot of timing and general "odd behavior" problems, improves display of the visualizations by giving them data slightly ahead of time (reduces laggy appearance) and fixes one rare segfault caused by a race.
Comment 20 Chris Howie 2009-01-26 02:46:21 UTC
Created attachment 127230 [details] [review]
New patch against r4961

Updated patch that applies cleanly to r4961.
Comment 21 Gabriel Burt 2009-01-27 04:34:59 UTC
With a couple minute scan, this looks fine, but I'll leave it Aaron to fully review since the libbanshee stuff is his bag.
Comment 22 Chris Howie 2009-01-27 15:24:04 UTC
Note that this bug is said to depend on #561281.  This is true, but the last few patches on this bug include the patch I developed to fix that other bug.  I'll leave this up to you guys to figure out how to best handle this.
Comment 23 Chris Howie 2009-02-03 17:21:14 UTC
Give me a bit to come up with another patch.  There are some lingering issues I found yesterday while applying it to a fresh Banshee checkout.  I'm not exactly sure why since it applied cleanly but apparently something has changed that caused the patch to screw up without failing.
Comment 24 Chris Howie 2009-02-10 19:27:17 UTC
Created attachment 128403 [details] [review]
New patch against r5021

Updated patch.  Fix calling of a nonexistent function and remove that function's prototype from libbanshee/banshee-player-vis.h.
Comment 25 Aaron Bockover 2009-04-24 06:55:16 UTC
Created attachment 133239 [details] [review]
Patch updated to work on git master

Updated to build, and started testing and reviewing. I'll dig deeper tomorrow. Right now I am seeing unacceptably high CPU usage (20-30%) when visualization is turned on. However, this patch is good for no CPU extra usage when visualization is turned off.

I'd like to commit this ASAP and focus on reducing CPU usage for the enabled case. I'll follow up tomorrow, hopefully committing.
Comment 26 Aaron Bockover 2009-04-28 04:31:18 UTC
I have created a new branch from stable called stable-vis where this patch is now applied [1].

Further CPU reduction work will happen on this branch and is of high priority to me, so I am going to close this bug. This is a good patch that does a good job at cleanly accomplishing the desired pass of CPU reduction.

When the pending further CPU reduction work is finished, the stable-vis branch will merge back into the stable branch, and from there will port up to master.

Thanks Chris!

[1] http://git.gnome.org/cgit/banshee/commit/?h=stable-vis&id=d712cedfd86997339850f00edcab4eddeeb02416