[pulseaudio-discuss] [PATCH RFC 00/17] memory optimizations

Peter Meerwald pmeerw at pmeerw.net
Fri Oct 24 14:21:24 PDT 2014


this patch series aims to save memory allocations and some system calls
related to PA's client/server protocol implementation


patches 1 to 5 ('tagstruct:') introduce a new tagstruct type _APPENDED
which can hold tagstruct data up to a certain size; tagstructs are now 
kept in a specific free-list -- this typically replaces two malloc()/free()s
with one flist push()/pop()

patches 6 to 8 ('packet:') make packets fixed-size (typically); packets are
kept in a specific free-list -- this replaces one malloc()/free() with one
flist push()/pop()

patches 9 to 14 ('pstream:') allows to send tagstructs directly to a pstream
without encapsulation in a packet -- this saves one flist push()/pop()

patches 15 and 16 ('pstream') often save a read() call by reading more than
just the descriptor (up to 40 bytes, e.g. description (20 bytes) + shm
info (16 bytes)); the idea is similar to b4342845d, "Optimize write 
of smaller packages", but for read -- this trades some extra memcpy() for
a read()

patch 17 ('iochannel') fixes a strange behaviour in iochannel/mainloop that
deleted the input_event with every read which caused a rebuild of the pollfds
for every read()!


with these patches typical playback (i.e. after setup) runs without any malloc()/free()
thanks to the use of free-lists; number of memory management operations is reduced

no benchmarking yet


Peter Meerwald (17):
  tagstruct: Distinguish pa_tagstruct_new() use cases
  tagstruct: Replace dynamic flag with type
  tagstruct: Get rid of pa_tagstruct_free_data()
  tagstruct: Add type _APPENDED
  tagstruct: Use flist to potentially save calls to malloc()/free()
  packet: Hide internals of pa_packet, introduce pa_packet_data()
  packet: Make pa_packet_new() create fixed-size packets
  packet: Introduce pa_packet_new_data() to copy data into a newly
    created packet
  packet: Use flist to save calls to malloc()/free()
  pstream: Unionize item_info
  pstream: Add pa_pstream_send_tagstruct()
  pstream: #define PA_PSTREAM_SHM_SIZE
  pstream: Duplicate assignment, write.data is always NULL
  pstream: Only reset memchunk if it has been used
  pstream: Split up do_read()
  pstream: Use small minibuffer to combine several read()s if possible
  iochannel: Fix channel enable

 src/modules/module-card-restore.c   |   4 +-
 src/modules/module-device-manager.c |  12 +-
 src/modules/module-device-restore.c |  16 +-
 src/modules/module-stream-restore.c |  12 +-
 src/modules/module-tunnel.c         |  52 +--
 src/pulse/context.c                 |  26 +-
 src/pulse/ext-device-manager.c      |  14 +-
 src/pulse/ext-device-restore.c      |  10 +-
 src/pulse/ext-stream-restore.c      |  10 +-
 src/pulse/introspect.c              |  82 ++---
 src/pulse/scache.c                  |  10 +-
 src/pulse/stream.c                  |  22 +-
 src/pulse/subscribe.c               |   2 +-
 src/pulsecore/iochannel.c           |  35 +-
 src/pulsecore/packet.c              |  53 ++-
 src/pulsecore/packet.h              |  20 +-
 src/pulsecore/pdispatch.c           |   9 +-
 src/pulsecore/protocol-native.c     |  94 +++---
 src/pulsecore/pstream-util.c        |  33 +-
 src/pulsecore/pstream-util.h        |   2 -
 src/pulsecore/pstream.c             | 635 +++++++++++++++++++++---------------
 src/pulsecore/pstream.h             |   2 +
 src/pulsecore/tagstruct.c           |  66 ++--
 src/pulsecore/tagstruct.h           |   4 +-
 src/tests/srbchannel-test.c         |  21 +-
 25 files changed, 704 insertions(+), 542 deletions(-)

-- 
1.9.1



More information about the pulseaudio-discuss mailing list