shm tmps

Optimize your system for ultimate performance.

Moderators: khz, MattKingUSA

User avatar
khz
Establlshed Member
Posts: 672
Joined: Thu Apr 17, 2008 6:29 am
Location: German

shm tmps

Postby khz » Fri May 18, 2018 6:28 am

I've been using this entry for years. Since I wrote this, I want to ask if this is correct, just to be on the safe side.
Is that true?
khz wrote:@realTimeConfigQuickScan

Code: Select all

** Warning: no tmpfs partition mounted on /tmp

As "root" in the console, add "nano /etc/fstab":

Code: Select all

shm           /dev/shm     tmpfs         nodev,nosuid,noexec      0 0
tmpfs         /tmp         tmpfs         defaults,size=7500M,mode=1777      0 0

("size=7500M" <-- adjusted to your actually built-in RAM, size=lessM than actually built-in RAM. (M = Megabyte).)
("F2" "yes" "enter") and computer "reboot".

>> "tmpfs /tmp tmpfs defaults,size=7500M,mode=1777 0 0" is still useful when you compile a lot. But it has nothing to do with audio/jack. <<


@shm
http://jackaudio.org/faq/build_info.html
(For Linux only) tmpfs file system
JACK’s performance on Linux is much improved if it can use a “tmpfs” (shared memory) file system for certain purposes. Specifically, it will try to use a tmpfs filesystem mounted on /dev/shm by default. You can test if you have this already by running the following command in a terminal:

Code: Select all

mount | grep shm

If it generates any output, you are all set. Most modern Linux systems will be this way. If yours is not then we are going to assume that you know what you are doing and understand how to set up a new tmpfs filesystem and how to tell JACK to use it.

https://wiki.archlinux.org/index.php/PulseAudio/Examples#PulseAudio_from_within_a_chroot
/dev/shm should also be mounted for efficiency and good performance.


https://www.spinics.net/lists/linux-audio-users/msg29692.html
> JACK compiled with System V SHM support.
> cannot create /dev/shm/jack-1000 directory (Permission denied)

Hi,
It seems pretty clear to me that this is a permissions problem, not a
kernel issue. I would suggest looking at how shm is mounted in your
distro and whether users are given access. On my Gentoo machine I have
this in fstab:

Code: Select all

shm                     /dev/shm        tmpfs     nodev,nosuid,noexec    0 0

For me, using udev, it gets the job done.

NOTE: This also might be a groups issue. If your distro has an 'audio'
group, for instance, and if your securities setup enforces a user
being part of that group to use /dev/shm then this might stop you from
being able to creat /dev/shm/jack-1000 when you try to run Jack as a
normal user.

I think it's a good idea to use it.


@tmps
Why does the script issue this warning?
"tmpfs /tmp tmpfs defaults,size=7500M,mode=1777 0 0" isn't needed by jack anymore, is it?
This "tmpfs /tmp tmpfs defaults,size=7500M,mode=1777 0 0" entry is definitely helpful, for example for daily compile.

https://wiki.linuxaudio.org/wiki/system_configuration#filesystems
Both Jack1 and Jack2 now use /dev/shm/ so mounting /tmp/ to tmpfs is not necessary anymore.


EDIT:
https://superuser.com/questions/45342/when-should-i-use-dev-shm-and-when-should-i-use-tmp/45509#45509
/dev/shm is a temporary file storage filesystem, i.e., tmpfs, that uses RAM for the backing store. It can function as a shared memory implementation that facilitates IPC.

From Wikipedia:

Recent 2.6 Linux kernel builds have started to offer /dev/shm as shared memory in the form of a ramdisk, more specifically as a world-writable directory that is stored in memory with a defined limit in /etc/default/tmpfs. /dev/shm support is completely optional within the kernel config file. It is included by default in both Fedora and Ubuntu distributions, where it is most extensively used by the Pulseaudio application.             (Emphasis added.)

/tmp is the location for temporary files as defined in the Filesystem Hierarchy Standard, which is followed by almost all Unix and Linux distributions.

Since RAM is significantly faster than disk storage, you can use /dev/shm instead of /tmp for the performance boost, if your process is I/O intensive and extensively uses temporary files.

To answer your questions: No, you cannot always rely on /dev/shm being present, certainly not on machines strapped for memory. You should use /tmp unless you have a very good reason for using /dev/shm.

Remember that /tmp can be part of the / filesystem instead of a separate mount, and hence can grow as required. The size of /dev/shm is limited by excess RAM on the system, and hence you're more likely to run out of space on this filesystem.


####
####

@max_user_watches
The "increase max_user_watches by adding 'fs.inotify.max_user_watches = 524288'" I find confusing. For a newcomer, perhaps even more confusing.
http://wiki.linuxaudio.org/wiki/system_configuration#sysctlconf
There are references on the net on adjusting the fs.inotify.max_user_watches value also for enhanced performance. But it remains very unclear where these references come from and if adjusting this value actually does anything at all. The max_user_watches parameter sets the maximum number of files your system can monitor with inotify (which is part of the kernel) for changes. Setting this parameter too low results in inotify failing. Setting it too high can make inotify needlessly consume memory. Best is to not touch the default settings as setting this parameter is unrelated to performance in an audio context.
FZ - Does humor belongs in Music?
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
    I don't care about the freedom of speech because I have nothing to say.

User avatar
protozone
Establlshed Member
Posts: 170
Joined: Tue May 08, 2018 9:02 pm
Contact:

Is that needed?

Postby protozone » Wed May 30, 2018 6:47 pm

I don't understand much about these suggested changes to the mounting/filesystem/RAM/etc.
I've never been advised to do it in the past. Are they really necessary?

I'm running a 32-bit distro, and not in PAE mode, so I can't get to the other 4 GB of RAM anyhow, right?

Also, I get an error message during boot that says that it's the wrong command and that it should be /dev/run/shm instead of dev/shm (or something like that)... :oops: :shock: :|

I'm just not really sure. Luckily the system still boots.

User avatar
khz
Establlshed Member
Posts: 672
Joined: Thu Apr 17, 2008 6:29 am
Location: German

Re: shm tmps

Postby khz » Mon Jun 04, 2018 4:47 pm

System-freezing is absolutely not what I wanted!

Shm is not absolutely necessary. Shm is optional, all audio optimizations are optional.

I also found very little information about it on the Internet. The information I found I posted here.
Therefore I am looking forward to your feedback.

I have been using Gentoo as a distribution with these entries for years.
Depending on the distribution used, is "/dev/shm" or "/dev/run/shm" used?

I always had this message in qjackctl:

Code: Select all

 cannot create /dev/shm/jack-1000 directory (Permission denied)

and i just wanted to solve the ~problem of the realTimeConfigQuickScan

Code: Select all

** Warning: no tmpfs partition mounted on /tmp

;-)
FZ - Does humor belongs in Music?
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
    I don't care about the freedom of speech because I have nothing to say.

Jack Winter
Establlshed Member
Posts: 237
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Postby Jack Winter » Mon Jun 04, 2018 5:50 pm

I don't think that is a problem at all. Normally JACK uses /dev/shm.

IMO a lot of Internet lore is either outdated or plain wrong..:)

AFAIK all a user needs to do is:

Get a lowlatency/realtime kernel.
Get rtprio/memlock capabilities.
Run the soundcard interrupt thread at prio 95.
Run JACK rt at prio 80.

Of course there are other things than can trip it all up depending on the hardware (in no particular order), bad hardware/drivers (wifi/gpu/etc), USB cables/hubs/etc, cpu powersaving, SMBIOS, NMIs, etc, etc. And surely some obscure tweak might fix a problem on some hardware.

Otherwise add this to your /etc/fstab:

tmpfs /tmp tmpfs rw,noatime 0 0

Let me think about "cannot create /dev/shm/jack-1000 directory (Permission denied)". that sounds you don't have permissions to access the needed files, maybe look with ls -l to see what perms they have and who owns them.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

User avatar
khz
Establlshed Member
Posts: 672
Joined: Thu Apr 17, 2008 6:29 am
Location: German

Re: shm tmps

Postby khz » Mon Jun 04, 2018 6:21 pm

I solved both ~problems with these entries. Neither qjackctl nor realTimeConfigQuickScan has this message.

Is there any further technical information/documentation?
jackaudio, wiki.archlinux, wiki.linuxaudio.org, ... are outdated or plain wrong?
How did you do that?
FZ - Does humor belongs in Music?
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
    I don't care about the freedom of speech because I have nothing to say.

User avatar
lilith
Establlshed Member
Posts: 325
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: shm tmps

Postby lilith » Mon Jun 04, 2018 6:35 pm

Run JACK rt at prio 80.


I have this always at 10, what is it doing?

Also, is a lowlatency kernel really needed? I read that after kernel version 2something the default kernel is good enough. (??)

Jack Winter
Establlshed Member
Posts: 237
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Postby Jack Winter » Mon Jun 04, 2018 6:45 pm

khz wrote:I solved both ~problems with these entries. Neither qjackctl nor realTimeConfigQuickScan has this message.

Is there any further technical information/documentation?
jackaudio, wiki.archlinux, wiki.linuxaudio.org, ... are outdated or plain wrong?
How did you do that?


It's just my opinion based on my experience..:)
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

User avatar
khz
Establlshed Member
Posts: 672
Joined: Thu Apr 17, 2008 6:29 am
Location: German

Re: shm tmps

Postby khz » Mon Jun 04, 2018 6:56 pm

These realtime hacks that the kernel team allowed are included in the standard kernel, so not everything but a lot of it.
Realtime kernel is even more, active development, optimized. Realtime is needed in some areas, not just for making music.

JACK rt at prio 80 = jackdbus Realtime priority @ "0 - 99"
IMHO

!Shm is optional, all audio optimizations are optional.!
But this is about the shm/tmps topic.

Jack Winter wrote:It's just my opinion based on my experience..:)

Gladly and cordially welcome! :-)

With the shm entry all audio processes run in RAM and is therefore faster/more stable?
FZ - Does humor belongs in Music?
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
    I don't care about the freedom of speech because I have nothing to say.

Jack Winter
Establlshed Member
Posts: 237
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Postby Jack Winter » Mon Jun 04, 2018 7:10 pm

lilith wrote:
Run JACK rt at prio 80.


I have this always at 10, what is it doing?

Also, is a lowlatency kernel really needed? I read that after kernel version 2something the default kernel is good enough. (??)


The question is what do you need.. The lower latency you use, the more likely you are to get xruns.

There are (for this discussion) 3 kernel configurations, a non preemptable, a preemptable, and a realtime kernel.

If "uname -a" output contains "PREEMPT" or "PREEMPT RT" the kernel is suitable for lower latency. The former is referred to as a lowlatency kernel and the latter as a realtime kernel. A non preemptable kernel will let threads run until they run yield or exceed their time slice. A preemptable kernel will stop threads running in preference to threads at a higher priority. The realtime kernel makes the kernel itself preemptable.

One idea behind JACK audio is based on POSIX realtime threads, which is somewhat irrelevant with multiple cpus.. But the basic idea is that most threads run as SCHED_NORMAL, then there are the interrupt handling threads running SCHED_FIFO (realtime) at priority 50. So if you set the soundcard high, then JACK between the soundcard and the interrupts, the system will prioritize taking care of first the soundcard interrupt, then the jack audio thread, and finally the rest of the system.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

Jack Winter
Establlshed Member
Posts: 237
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Postby Jack Winter » Mon Jun 04, 2018 7:15 pm

khz wrote:With the shm entry all audio processes run in RAM and is therefore faster/more stable?


Not sure about this, but yes all the I/O between the JACK server and the client libs are happening via a RAM filessystem and not some normal FS.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

User avatar
lilith
Establlshed Member
Posts: 325
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: shm tmps

Postby lilith » Mon Jun 04, 2018 7:23 pm

Ok, I have a RT kernel installed and get much more xruns with it. Bluebell observed a similar behavior. Also the system freezed several times while using the RT kernel, maybe it's a problem with the kernel + GPU driver (i915). The crash dump points to this. At the moment I'm using the normal one that came with Debian and I don't see that the performance is worse. But I'm also not going for 2ms latency... 5-10 ms is fine for me.

User avatar
khz
Establlshed Member
Posts: 672
Joined: Thu Apr 17, 2008 6:29 am
Location: German

Re: shm tmps

Postby khz » Mon Jun 04, 2018 7:30 pm

Code: Select all

Processor type and features    --->
    Preemption Model (Preemptible Kernel (Low-Latency Desktop))    --->
 
( ) No Forced Preemption (Server)
( ) Voluntary Kernel Preemption (Desktop)
(X) Preemptible Kernel (Low-Latency Desktop)
( ) Complete Preemption (Real-Time)

"Server Prefix" select "jackdmp"

RAM is everything! :-D
FZ - Does humor belongs in Music?
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
    I don't care about the freedom of speech because I have nothing to say.

Jack Winter
Establlshed Member
Posts: 237
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Postby Jack Winter » Mon Jun 04, 2018 7:41 pm

Code: Select all

(X) Complete Preemption (Real-Time)

Is the way to go if it doesn't cause any issues on your system :)
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

User avatar
khz
Establlshed Member
Posts: 672
Joined: Thu Apr 17, 2008 6:29 am
Location: German

Re: shm tmps

Postby khz » Mon Jun 04, 2018 7:55 pm

@All It is good to go step by step. Then one recognizes the problem originator and can undo thereby the last made. All audio optimizations are optional.
There are several possibilities.
IMHO

@shm Take the entry out, reboot the computer and check if the problem came from there.

Please create a new thread for a new topic. Thank you.
:-)

But this is about the shm/tmps topic.

Code: Select all

;-)
FZ - Does humor belongs in Music?
GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
    I don't care about the freedom of speech because I have nothing to say.

Jack Winter
Establlshed Member
Posts: 237
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Postby Jack Winter » Mon Jun 04, 2018 8:15 pm

Well no need for a rt kernel, nor a new thread. This has all been discussed to death before :)

The only thing is that the kernel scheduling model increasingly schedules threads faster, and in this case slower means a bigger chance of a xrun. I suppose everyone has to make their own decision. I also suspect that YMMW might also apply (probably hardware dependent)..

Edit: But, JACK has supported /dev/shm for years, and distros too, would be weird for a system today to be missing it.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux


Return to “System Tuning and Configuration”

Who is online

Users browsing this forum: No registered users and 8 guests