[alsa-devel] [alsa-lib][PATCH 00/34] pcm/conf/alisp: replace usage of alloca() with automatic variables
Takashi Iwai
tiwai at suse.de
Thu Jul 14 18:02:55 CEST 2016
On Thu, 14 Jul 2016 16:07:17 +0200,
Takashi Sakamoto wrote:
>
> Hi,
>
> A batch of this patchset is to save storage consumption and to improve
> execution performance, just for a little.
>
> Currently, ALSA userspace library doesn't disclose layouts of major
> structures to applications. The applications call some APIs in the
> library to get memory objects for the structures, then operates to
> corresponding opaque pointers. In most cases, the objects are kept on
> stack by calls of alloca(3).
>
> On the other hand, inner the library, the layouts are decided in
> pre-compile or compile time. Therefore, there's little needs to call
> of alloca(3).
>
> However, inner the library, we can see some usages of alloca(3). This
> brings two disadvantages to system. One is to execute more instructions
> to use stack than automatic variables, for the same task. Another is to
> enlarge size of shared object. Although both disadvantages are not so
> remarkable, it's better to improve them.
>
> This patchset replaces usages of alloca() with automatic variables just
> to raw structures. Additionally, this commit improves code formats in
> related functions.
>
> I can see below effect on my environment (Ubuntu 16.04, amd64, gcc)
> $ git checkout master
> $ git show HEAD
> commit 941bd150bef2560f3e38a3bf74d546447e3126d1
> ...
> $ ./gitcompile --with-plugindir=/usr/lib/x86_64-linux-gnu/alsa-lib/
> ...
> $ ls -l src/.libs/libasound.so.2.0.0
> -rwxrwxr-x 1 mocchi mocchi 4794528 7月 14 22:22 src/.libs/libasound.so.2.0.0
> $ git checkout remove-alloca-asound
> $ make
> ...
> $ ls -l src/.libs/libasound.so.2.0.0
> -rwxrwxr-x 1 mocchi mocchi 4783712 7月 14 22:21 src/.libs/libasound.so.2.0.0
> $ gcc -v
> ...
> gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.1)
>
> Takashi Sakamoto (34):
> pcm: change code formatting for snd_pcm_set_params()
> pcm: remove alloca() from snd_pcm_set_params()
> pcm: change code formatting for snd_pcm_get_params()
> pcm: remove alloca() from snd_pcm_get_params
> pcm: change code formatting for snd_pcm_direct_initialize_slave()
> pcm: remove alloca() from snd_pcm_direct_initialize_slave
> pcm: change code formatting for snd_pcm_direct_initialize_poll_fd()
> pcm: remove alloca() from snd_pcm_direct_initialize_poll_fd()
> pcm: change code formatting for snd_pcm_direct_set_timer_params()
> pcm: remove alloca() from snd_pcm_direct_set_timer_params
> pcm: remove alloca() from _snd_pcm_hook_ctl_elems_install()
> pcm: change code formatting for snd_pcm_hw_change_timer()
> pcm: remove alloca() from snd_pcm_hw_change_timer()
> pcm: remove alloca() from snd_pcm_query_chmaps_from_hw()
> pcm: remove alloca() from snd_pcm_hw_get_chmap()
> pcm: remove alloca() from snd_pcm_hw_set_chmap()
> pcm: remove alloca() from snd_spcm_init()
> pcm: remove alloca() from snd_spcm_init_duplex()
> pcm: change code formatting for softvol_load_control()
> pcm: remove alloca() from softvol_load_control()
> pcm: change code formatting for _snd_pcm_softvol_open()
> pcm: remove alloca() from _snd_pcm_softvol_open()
> conf: remove alloca() from snd_determine_driver()
> conf: remove alloca() from snd_func_card_id()
> conf: remove alloca() from snd_func_card_name()
> conf: remove alloca() from snd_func_pcm_id()
> conf: remove alloca() from snd_func_pcm_args_by_class()
> conf: remove alloca() from snd_func_private_pcm_subdevice()
> alisp: remove alloca() from FA_card_info()
> alisp: remove alloca() from FA_hctl_find_elem()
> alisp: remove alloca() from FA_hctl_elem_info()
> alisp: remove alloca() from FA_hctl_elem_read()
> alisp: remove alloca() from FA_hctl_elem_write()
> alisp: remove alloca() from FA_pcm_info()
Thanks, it's a nice cleanup. Applied all patches now.
Takashi
More information about the Alsa-devel
mailing list