profiling tools and pulseaudio CPU usage

asked 2014-11-22 02:44:30 +0300

lion gravatar image

updated 2016-01-04 06:13:33 +0300

Mano gravatar image

I'm test some android voip app and get following perfomance result:
16406 10012 20 0 883m 59m 26m S 66.5 7.3 0:09.15 com.androidapp
969 nemo 9 -11 329m 6728 4256 S 26.6 0.8 31:15.77 pulseaudio
1084 nemo 20 0 438m 4624 3364 S 25.9 0.6 28:04.49 alien_audio_server
974 nemo 20 0 350m 93m 63m S 15.9 11.6 30:48.01 lipstick
1231 system 20 0 919m 79m 49m S 15.2 9.9 16:19.24 system_server
1086 media 20 0 44684 3172 1604 S 4.5 0.4 4:46.78 mediaserver
CPU usage marked bold, sailfish os 1.0.8.21.

App is outputs audio in 16khz, so, pulseaudio, alien_audio_server to process 16khz eats almost same CPU time as whole voip app with HD video.

I do not find any profiler which not require re-compilation (like perf top in linux) in sailfish os repos and http://openrepos.net/.

I've tried compile and use crxprof, here results:

alien_audio_server:
--- 513 snapshot interrputs got (0 dropped)
android::IPCThreadState::joinThreadPool (100.0% | 0.0% self)
\_ android::IPCThreadState::executeCommand (89.7% | 0.0% self)
| \_ android::BBinder::transact (59.8% | 0.0% self)
| \_ android::BnAlienAudioService::onTransact (59.8% | 0.0% self)
| \_ pa_simple_read (43.8% | 0.3% self)
| \_ pa_threaded_mainloop_wait (30.8% | 0.0% self)
| \_ pthread_cond_wait (30.7% | 30.7% self)
| \_ pa_stream_drop (11.8% | 0.2% self)
| \_ pa_memblock_unref (10.6% | 1.0% self)
| \_ pa_shm_free (5.1% | 0.0% self)
| \_ munmap (5.1% | 5.1% self)
\_ android::IPCThreadState::sendReply (29.9% | 0.0% self)
\_ android::IPCThreadState::waitForResponse (29.9% | 0.0% self)
\_ android::IPCThreadState::talkWithDriver (29.9% | 0.0% self)
\_ ioctl (29.9% | 29.9% self)
\_ android::IPCThreadState::talkWithDriver (10.3% | 0.0% self)
\_ ioctl (10.3% | 10.3% self)

pulseaudio:
--- 989 snapshot interrputs got (0 dropped)
pa_mainloop_iterate (100.0% | 0.0% self)
\_ pa_mainloop_dispatch (62.8% | 2.6% self)
| \_ pa_iochannel_write (27.0% | 0.0% self)
| \_ pa_write (27.0% | 0.0% self)
| \_ send (27.0% | 27.0% self)
| \_ pa_iochannel_read_with_creds (9.2% | 0.0% self)
| \_ pa_asyncmsgq_dispatch (7.0% | 0.3% self)
| \_ pa_mainloop_wakeup (5.5% | 0.0% self)
| \_ pa_write (5.5% | 0.0% self)
| \_ write (5.5% | 5.5% self)
\_ pa_mainloop_poll (30.1% | 0.0% self)
\_ ppoll (30.1% | 30.1% self)
\_ pa_mainloop_prepare (7.2% | 2.7% self)

It seems not accurate, it generate small amount of samples for long period. So, we need good profile tools in SDK...

Something not right with pulseaudio and it's not in resample method. If we play 44.1khz mp3 we get up to 9% cpu for pulseaudio. Changing resample-method to trivial in daemon.conf gives nothing (trivial already used in arm_qct_msm8930_cdp.pa config).

Bump: It's still a problem for Saimaa, see comment…

edit retag flag offensive close delete

Comments

This still is true for Saimaa (2.0.0.10)…

Although I haven't done any profiling (best practiced by lion), 'top' shows me aliendalvik leaves pluseaudio wasting lot of PCU cycles, while no aliendalvik app is in foreground. This kind of leak leads to serious runtime degradation :-( Stopping "Android-Support" and restarting it via "Settings" helped last time i checked; same is true for a reboot of course ;-) But it's not a good habit to expect users doing reboots to "work around" bugs ;-)

-Mano

Mano ( 2016-01-04 06:11:55 +0300 )edit

I experienced the same pulseaudio consumption using QAudioRecorder with SailDBMeter, without android app usage.

16kHz mono: ~25% cpu 44.1kHz: little more

But it always went down when channel stopped from application, being in background or exited.

Anyway, the CPU usage is too big to only dispatch an audio stream.

LouJo ( 2016-01-04 10:06:50 +0300 )edit