Most active commenters
  • AdieuToLogic(5)
  • buckle8017(3)
  • pkulak(3)

←back to thread

61 points hiAndrewQuinn | 12 comments | | HN request time: 0.609s | source | bottom
Show context
hackyhacky ◴[] No.44392515[source]
Rather than re-write your scripts to store temp files into /dev/shm, you can just mount /tmp using the tmpfs file system and get the same benefit for all your programs. Some distros do this by default.

The relevant line from fstab is:

    tmpfs /tmp            tmpfs    noatime 0       2
Now any program that writes to /tmp will be writing to a RAM disk, thus sparing unnecessary wear on my SSD.
replies(7): >>44392526 #>>44392690 #>>44392745 #>>44392789 #>>44392847 #>>44393129 #>>44393836 #
pkulak ◴[] No.44392745[source]
I did this for a while, but writing files to ram can be dangerous, since most things assume unlimited disk space. I noticed that updates would fail on machines that had 16 gigs of ram unless I logged out of my window manager and did it from the TTY. Took quite a long time to realize it was because of all the compiles writing to /tmp. Much easier to just let the SSD get used.
replies(1): >>44392802 #
1. buckle8017 ◴[] No.44392802[source]
This is why having swap even when you have plenty of memory for normal usage is good.

Swap on an SSD isn't even that slow.

replies(2): >>44392866 #>>44392886 #
2. pkulak ◴[] No.44392866[source]
You know what, your comment actually reminds me that this happened when I also had a bug in my configuration that was causing me to not actually use swap. I assume running out of tmpfs uses swap like anything else? I might give tmpfs another try.
replies(2): >>44393113 #>>44393717 #
3. ◴[] No.44392886[source]
4. AdieuToLogic ◴[] No.44393113[source]
> I assume running out of tmpfs uses swap like anything else?

This is not the case. RAM-based file system capacities are unrelated to process memory usage, of which "swap space" is for the latter.

replies(3): >>44393245 #>>44393314 #>>44393779 #
5. pkulak ◴[] No.44393245{3}[source]
Interesting, thank you. I stand by my original point, downvotes be damned.
replies(2): >>44393330 #>>44400450 #
6. tatref ◴[] No.44393314{3}[source]
That's why on some configurations (RHEL 7 I think), journald will happily fill up your ram via /run/
replies(1): >>44393476 #
7. AdieuToLogic ◴[] No.44393330{4}[source]
> Interesting, thank you.

Glad to help out. Here[0] is more information regarding Linux swap space as it relates to processes and the VMM subsystem.

> I stand by my original point, downvotes be damned.

:-D

0 - https://phoenixnap.com/kb/swap-space

8. AdieuToLogic ◴[] No.44393476{4}[source]
> That's why on some configurations (RHEL 7 I think), journald will happily fill up your ram via /run/

I do not run systemd-based distros, so cannot relate.

9. buckle8017 ◴[] No.44393717[source]
Sibling is wrong tmpfs will swap.

Maybe some other ram disk things won't.

10. buckle8017 ◴[] No.44393779{3}[source]
tmpfs will swap.
replies(1): >>44400424 #
11. AdieuToLogic ◴[] No.44400424{4}[source]
> tmpfs will swap.

We are both wrong to a degree, but you are more correct than I was.

According to the docs[0]:

  tmpfs ... is able to swap unneeded pages out to swap
  space, if swap was enabled for the tmpfs mount.
So `tmpfs` does not unconditionally use swap, but can use it if possible. What I was thinking about is `ramfs`, which doesn't support swap, but that is not the topic of the question to which I replied.

0 - https://www.kernel.org/doc/html/latest/filesystems/tmpfs.htm...

12. AdieuToLogic ◴[] No.44400450{4}[source]
I was wrong in my unconditional assertion that `tmpfs` does not use swap. It can, depending on conditions described here[0].

What I was thinking about is `ramfs`, which does not use/support swap and has other limitations not present in `tmpfs`.

Sorry for confusing the topic.

0 - https://www.kernel.org/doc/html/latest/filesystems/tmpfs.htm...