pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/50539: pulseaudio consumes too much /var/shm for shm_open(3)
>Number: 50539
>Category: pkg
>Synopsis: pulseaudio consumes too much /var/shm for shm_open(3)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Dec 11 18:05:00 +0000 2015
>Originator: Izumi Tsutsui
>Release: NetBSD 7.0
>Organization:
>Environment:
System: NetBSD/i386 7.0 (GENERIC.201509250726Z) i386
Architecture: i386
Machine: i386
>Description:
It looks pulseaudio creates 64MB shm files in /var/shm via shm_open(3)
per each pulseaudio client.
On the other hand, the default NetBSD sysinst installation prepares
the following fstab(5) entry:
>> tmpfs /var/shm tmpfs rw,-m1777,-sram%25
This means:
- On 1GB RAM machines, /var/shm will have only(?) ~256 MB
- Pulseaudio can handle only three clients with ~256 MB /var/shm
and it will complain about shm failure like:
>> Dec 6 14:05:36 mirage pulseaudio[29034]: [(null)] shm.c: ftruncate() failed: No space left on device
- Even if the machine have enough tmpfs, it seems multiple 64 MB
shm files on tmpfs could cause extreme high CPU load,
as mentioned in PR/50306
http://gnats.netbsd.org/50306
>> html5 sound output in firefox with the pulseaudio default eats
>> a lot of CPU cycles and very often results in "audiostream underrun"
>> and stuttering of the sound on my oldish Asus P4B533 with
>> Pentium 4 @ 2.5GHz
Note if /var/shm is not mounted as tmpfs (that could happen on users
who didn't use sysinst on upgrade), pulseaudio also complains:
>> shm.c: shm_open() failed: Not supported
>How-To-Repeat:
Install pulseaudio and clients (like firefox html5 player, onscripter,
mplayer etc.) via pkgsrc and execute them?
>Fix:
In pulseaudio-7.1/src/pulsecore/memblock.c there is the following comment:
---
/* We can allocate 64*1024*1024 bytes at maximum. That's 64MB. Please
* note that the footprint is usually much smaller, since the data is
* stored in SHM and our OS does not commit the memory before we use
* it for the first time. */
---
It looks the authors assume "our OS" is always Linux, but unfortunately
it does not seem true on shm_open(3) implementation of NetBSD 7.x.
I've tried shm setting to 8MB on NetBSD/i386 7.0 and
firefox html5 video is played smoothly without particular problem
on my Atom N455 + 1GB RAM (i.e. with 256MB tmpfs) netbook.
---
Index: MESSAGE.NetBSD
===================================================================
RCS file: MESSAGE.NetBSD
diff -N MESSAGE.NetBSD
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MESSAGE.NetBSD 11 Dec 2015 17:45:41 -0000
@@ -0,0 +1,11 @@
+===========================================================================
+$NetBSD$
+
+If you are running NetBSD 7.0 or later please make sure that /var/shm is
+mounted as tmpfs for pulseaudio to use shm_open(2):
+
+This can be automated by adding the following to your /etc/fstab:
+
+tmpfs /var/shm tmpfs rw,-m1777,-sram%25
+
+===========================================================================
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/audio/pulseaudio/distinfo,v
retrieving revision 1.55
diff -u -p -d -r1.55 distinfo
--- distinfo 10 Dec 2015 10:54:50 -0000 1.55
+++ distinfo 11 Dec 2015 17:45:41 -0000
@@ -13,6 +13,7 @@ SHA1 (patch-src_modules_module-detect.c)
SHA1 (patch-src_modules_module-solaris.c) = 03ea8912da4bb76294ca23271e47d40a8c9a61a7
SHA1 (patch-src_modules_oss_module-oss.c) = 399ac178ae832619253ce8dd985edbed23db86e7
SHA1 (patch-src_pulsecore_core-util.c) = 186c805ac4083446afe3ce8db5c6157da92871be
+SHA1 (patch-src_pulsecore_memblock.c) = 9ceb5d7e489a730875c1c4a5bd9676e5de5cea20
SHA1 (patch-src_pulsecore_mix__neon.c) = 6f6d33d38024d65045d637d48276e1ba92b81342
SHA1 (patch-src_pulsecore_sample-util.h) = b6bd83cfdc1c337453d9a728f07205a2cf0af831
SHA1 (patch-src_pulsecore_svolume__mmx.c) = c34d153e3bfdb812eb7bd70fa330a9ec674c2dc2
Index: patches/patch-src_pulsecore_memblock.c
===================================================================
RCS file: patches/patch-src_pulsecore_memblock.c
diff -N patches/patch-src_pulsecore_memblock.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_pulsecore_memblock.c 11 Dec 2015 17:45:41 -0000
@@ -0,0 +1,22 @@
+$NetBSD$
+
+Restrict PA_MEMPOLL_SLOT_SIZE to 8MB on NetBSD to avoid shortage of
+/var/shm which is mount as tmpfs with 25% of the physical memory.
+
+--- src/pulsecore/memblock.c.orig 2015-02-12 14:10:35.000000000 +0000
++++ src/pulsecore/memblock.c
+@@ -55,7 +55,14 @@
+ * stored in SHM and our OS does not commit the memory before we use
+ * it for the first time. */
+ #define PA_MEMPOOL_SLOTS_MAX 1024
++#if defined(__NetBSD__)
++/* On NetBSD (i.e. non-"our OS" system), shm_open(3) uses /var/shm
++ * which is usually mounted as tmpfs and it's a bit pain to consume
++ * 64MB for each client (i.e. >256MB tmpfs even only for four clients). */
++#define PA_MEMPOOL_SLOT_SIZE (8*1024)
++#else
+ #define PA_MEMPOOL_SLOT_SIZE (64*1024)
++#endif
+
+ #define PA_MEMEXPORT_SLOTS_MAX 128
+
---
I know this patch should be submitted to upstream first,
but I'm so lazy and use pulseaudio only via pkgsrc :-p
---
Home |
Main Index |
Thread Index |
Old Index