View Single Post
Posts: 503 | Thanked: 267 times | Joined on Jul 2006 @ Helsinki
#304
Hello,

Regarding A2DP performance on N800/N810. Using the latest diablo firmware, a2dp-support_0.9_all.deb package and nothing else, we get the following profiling statistics (Signed 16 bit Little Endian, Rate 44100 Hz, Stereo WAV file played with aplay for 100 seconds), the results are consistent across multiple runs, CPU was set to run at 400MHz:

CPU_CYCLES:100000|
samples| %|
------------------
27578 46.8448 libasound_module_pcm_bluetooth.so
27005 45.8715 no-vmlinux
1232 2.0927 oprofiled
814 1.3827 libc-2.5.so
356 0.6047 libasound.so.2.0.0
305 0.5181 ld-2.5.so
257 0.4365 Xomap
215 0.3652 libglib-2.0.so.0.1200.12
190 0.3227 busybox
182 0.3092 libpthread-2.5.so
120 0.2038 libgobject-2.0.so.0.1200.12
107 0.1818 libdbus-1.so.3.2.0
97 0.1648 dbus-daemon
67 0.1138 libgdk-x11-2.0.so.0.1000.12
61 0.1036 aplay

CPU_CYCLES:100000|
samples| %|
------------------
27238 47.7692 libasound_module_pcm_bluetooth.so
26289 46.1049 no-vmlinux
1176 2.0624 oprofiled
790 1.3855 libc-2.5.so
337 0.5910 libasound.so.2.0.0
267 0.4683 ld-2.5.so
191 0.3350 busybox
151 0.2648 libpthread-2.5.so
114 0.1999 libglib-2.0.so.0.1200.12
100 0.1754 libgobject-2.0.so.0.1200.12
82 0.1438 aplay
CPU usage is split between kernel and bluez SBC encoder more or less evenly and the bluetooth driver consumes quite a noticeable share of cpu time. Applying attached patch (tweak of UART FIFO buffer settings) to the kernel reduces CPU usage in the bluetooth driver. The fix for UART FIFO stuff for the bluetooth is available in pre-alpha fremantle kernel which was released to the public. I just did some tweaks which should work better on N800/N810, but of course somebody else can probably improve it more (reading OMAP1 and OMAP3 documentation about UART and "interpolating" it for OMAP2). Even better optimization would be to try using DMA in the bluetooth driver, but that may be a bit harder.

With the patch applied, the profiling statistics changes to the following:
CPU_CYCLES:100000|
samples| %|
------------------
28345 56.8401 libasound_module_pcm_bluetooth.so
18780 37.6594 no-vmlinux
989 1.9832 oprofiled
641 1.2854 libc-2.5.so
283 0.5675 libasound.so.2.0.0
257 0.5154 ld-2.5.so
194 0.3890 busybox
131 0.2627 libpthread-2.5.so
91 0.1825 libuClibc-0.9.28.so
61 0.1223 aplay

CPU_CYCLES:100000|
samples| %|
------------------
28315 56.1861 libasound_module_pcm_bluetooth.so
18894 37.4918 no-vmlinux
997 1.9784 oprofiled
787 1.5617 libc-2.5.so
265 0.5258 ld-2.5.so
264 0.5239 libasound.so.2.0.0
184 0.3651 busybox
141 0.2798 libpthread-2.5.so
120 0.2381 libglib-2.0.so.0.1200.12
82 0.1627 libgobject-2.0.so.0.1200.12
76 0.1508 dbus-daemon
69 0.1369 aplay
CPU usage in the kernel gets lower and there are less interrupts generated. On the other hand, bluetooth transfer speed may become a little bit smaller.

As for the SBC codec alone, it takes ~7% of CPU on N800/N810. With ARMv6 SIMD optimizations (which are still to be done) and the latest SBC encoder from upstream bluez project, I expect that this time might get halved.

Alternatively, DSP can be used for SBC encoder (port to it is done by lardman). But ARM<->DSP communication overhead is also kind of can of worms and may (or may not) kill the benefits of offloading some work to DSP.
Attached Files
File Type: gz bluetooth-fifo-fix.diff.gz (508 Bytes, 213 views)
 

The Following 11 Users Say Thank You to Serge For This Useful Post: