Ticket #722 (new defect)

Opened 8 months ago

High CPU load during capture from the ALSA "default" device

Reported by: krnekit Owned by: ossman
Milestone: Component: alsa-plugins-pulse
Keywords: alsa capture default cpu load Cc:

Description

While doing capture from the ALSA "default" device the program have high cpu load (~20% of one core on my AMD Athlon X2). This can be reproduced by the following command:

arecord > /dev/null

Using the device, distinct from "default" (for example "plughw:0,0"), using capture through pulseaudio without emulation (with parecord) or doing playback works well without high cpu load.

This problem discovered in version 0.9.19 on Mandriva Linux 2010.0. Also it have been reproduced on Ubintu 9.10 and Fedora 12 with the same version of pulseaudio, and on Mandriva 2009.1. This problem is absent in pulseadio 0.9.12 (openSUSE 11.1). But in 0.9.10 on Mandriva 2009.0 it again gives high cpu load.

Calling strace on arecord gives information about enormous amount of poll() calls:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 95.30    0.014735           0     62709           poll
  2.43    0.000375         375         1           execve
  2.27    0.000351           2       156         2 futex
  0.00    0.000000           0       233        92 read
  0.00    0.000000           0       167           write
  0.00    0.000000           0        75        14 open
  0.00    0.000000           0        62           close
  0.00    0.000000           0         1           stat
  0.00    0.000000           0        57           fstat
  0.00    0.000000           0        96           mmap
  0.00    0.000000           0        54           mprotect
  0.00    0.000000           0        18           munmap
  0.00    0.000000           0         4           brk
  0.00    0.000000           0         5           rt_sigaction
  0.00    0.000000           0         1           rt_sigprocmask
  0.00    0.000000           0        17           writev
  0.00    0.000000           0         6         3 access
  0.00    0.000000           0         2           pipe
  0.00    0.000000           0         2           socket
  0.00    0.000000           0         2           connect
  0.00    0.000000           0         1         1 sendto
  0.00    0.000000           0         1           getsockname
  0.00    0.000000           0         1           getpeername
  0.00    0.000000           0         1           setsockopt
  0.00    0.000000           0         1           clone
  0.00    0.000000           0         8         1 kill
  0.00    0.000000           0         1           uname
  0.00    0.000000           0        23           fcntl
  0.00    0.000000           0         1           ftruncate
  0.00    0.000000           0         2           getdents
  0.00    0.000000           0         1           unlink
  0.00    0.000000           0         2           readlink
  0.00    0.000000           0         1           getrlimit
  0.00    0.000000           0         1           getuid
  0.00    0.000000           0         1           statfs
  0.00    0.000000           0         1           arch_prctl
  0.00    0.000000           0         1           set_tid_address
  0.00    0.000000           0         1           set_robust_list
------ ----------- ----------- --------- --------- ----------------
100.00    0.015461                 63717       113 total

This is for approximately ten seconds.

More detailed strace output shows, that this call:

poll([{fd=5, events=POLLIN|POLLERR|POLLNVAL}], 1, -1) = 1 ([{fd=5, revents=POLLIN}])

repeated ~1000 times.

Doing playback, poll() not called so frequently:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 87.26    0.004999          54        92           poll
  9.25    0.000530          17        32         2 futex
  3.23    0.000185           2        77           write
  0.26    0.000015           0        96           mmap
  0.00    0.000000           0       267        75 read
  0.00    0.000000           0        75        14 open
  0.00    0.000000           0        62           close
  0.00    0.000000           0         1           stat
  0.00    0.000000           0        57           fstat
  0.00    0.000000           0        54           mprotect
  0.00    0.000000           0        17           munmap
  0.00    0.000000           0         4           brk
  0.00    0.000000           0         5           rt_sigaction
  0.00    0.000000           0         1           rt_sigprocmask
  0.00    0.000000           0        17           writev
  0.00    0.000000           0         6         3 access
  0.00    0.000000           0         2           pipe
  0.00    0.000000           0         2           socket
  0.00    0.000000           0         2           connect
  0.00    0.000000           0         1         1 sendto
  0.00    0.000000           0         1           getsockname
  0.00    0.000000           0         1           getpeername
  0.00    0.000000           0         1           setsockopt
  0.00    0.000000           0         1           clone
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         8           kill
  0.00    0.000000           0         1           uname
  0.00    0.000000           0        23           fcntl
  0.00    0.000000           0         1           ftruncate
  0.00    0.000000           0         2           getdents
  0.00    0.000000           0         2           readlink
  0.00    0.000000           0         1           getrlimit
  0.00    0.000000           0         1           getuid
  0.00    0.000000           0         1           statfs
  0.00    0.000000           0         1           arch_prctl
  0.00    0.000000           0         1           set_tid_address
  0.00    0.000000           0         1           set_robust_list
------ ----------- ----------- --------- --------- ----------------
100.00    0.005729                   918        95 total

for the approximately same time. Playback is executed as:

aplay < /dev/zero
Note: See TracTickets for help on using tickets.