shm tmps

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

shm tmps

Post by khz »

<EDIT>

This is not necessary.

Both Jack1 and Jack2 uses shm (RAM-backed storage) by default. >> https://wiki.linuxaudio.org/wiki/system ... ilesystems

Verifiable with:

Code: Select all

ls -alFh /dev/shm

Code: Select all

du -h /dev/shm/*

Code: Select all

df -h | grep shm

Code: Select all

mount | grep shm

But resizing is possible by "size=".

  • Jack Winter wrote:

    /dev/shm is a tmpfs even if you haven't mounted it so in fstab, it's automatic nowdays, and as all tmpfs by default it gets a maximum of half your ram.

https://www.cyberciti.biz/tips/what-is- ... usage.html

Code: Select all

┌───────────┬──────────────┬────────────────┐
│ /dev/shm  │ always tmpfs │ Linux specific │
├───────────┼──────────────┼────────────────┤
│ /tmp      │ can be tmpfs │ FHS 1.0        │
├───────────┼──────────────┼────────────────┤
│ /var/tmp  │ never tmpfs  │ FHS 1.0        │
└───────────┴──────────────┴────────────────┘

https://superuser.com/a/1030777

<EDIT>

khz wrote: Thu Dec 08, 2022 7:14 pm

I had a total of 8 GB RAM installed in the computer.

With the shm entry in the fstab [1] he shows me this:

khz wrote: Wed Jan 02, 2019 5:48 pm

Code: Select all

 ~ $ df -h
shm             7,4G    155M  7,2G    3% /dev/shm
tmpfs           7,4G     12K  7,4G    1% /tmp

Without the shm entry in the fstab [1] he shows me this:

khz wrote: Wed Jan 02, 2019 8:21 pm

Code: Select all

 ~ $ df -h
shm             5,9G    102M  5,8G    2% /dev/shm

[1]

Code: Select all

shm		/dev/shm		tmpfs			nodev,nosuid,noexec,size=7500M		0 0

</EDIT>
</EDIT>

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,size=7500M		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/Pu ... n_a_chroot

/dev/shm should also be mounted for efficiency and good performance.

https://www.spinics.net/lists/linux-aud ... 29692.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.

- JACK/Audio2RAM is everything! ;-) -

@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 ... ilesystems

Both Jack1 and Jack2 now use /dev/shm/ so mounting /tmp/ to tmpfs is not necessary anymore.

EDIT:
https://superuser.com/questions/45342/w ... 5509#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.

<EDIT>Removed</EDIT>

. . . 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
Established Member
Posts: 181
Joined: Tue May 08, 2018 9:02 pm
Contact:

Is that needed?

Post by protozone »

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
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: shm tmps

Post by khz »

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
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Post by Jack Winter »

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
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: shm tmps

Post by khz »

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
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: shm tmps

Post by lilith »

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
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Post by Jack Winter »

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
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: shm tmps

Post by khz »

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
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Post by Jack Winter »

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
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Post by Jack Winter »

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
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: shm tmps

Post by lilith »

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
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: shm tmps

Post by khz »

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
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Post by Jack Winter »

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
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: shm tmps

Post by khz »

@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
Established Member
Posts: 381
Joined: Sun May 28, 2017 3:52 pm

Re: shm tmps

Post by Jack Winter »

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
Post Reply