this post was submitted on 07 Jul 2023
35 points (97.3% liked)

Selfhosted

38813 readers
456 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

I've heard a lot of people say your swap should be 2x RAM.. but do I really need 32GB of swap?

you are viewing a single comment's thread
view the rest of the comments
[–] eager_eagle@lemmy.world 4 points 1 year ago* (last edited 1 year ago) (2 children)

Personally I don’t think swap partitions are particularly useful any more

This is just wrong. Having swap increases the performance of your applications as it frees up RAM by swapping cold pages out of memory and use that space for caching, which increases hit rates. And this performance increase is both for low and high used memory rates.

[–] SheeEttin@lemmy.world 2 points 1 year ago (1 children)

So once it gets pushed out of RAM, you read it from disk instead of from disk? I'm not sure that that's a benefit. If you're using SSDs, they are fast and don't have seek times, so I don't think that having it in swap is any faster than just from disk. Maybe a little overhead for opening the file.

Assuming that you aren't truly exhausting your RAM, anyway, such that programs start crashing due to being unable to allocate. Or that the data on disk is compressed, for example.

[–] eager_eagle@lemmy.world 4 points 1 year ago* (last edited 1 year ago)

the swap space works as another level of memory hierarchy, the kernel swap pages out before all RAM is used in order to make room for pages that are more likely to be requested. It is very much a benefit, especially when using SSDs.

so I don’t think that having it in swap is any faster than just from disk.

That is still is faster, because even though they have the same physical access times, the data stored in swap space is already mapped to memory pages. By not using swap you are just more likely to face lower hit rates for low memory usage and thrashing for high memory usage. The slowness of the disk won't affect your overall performance as you'll get higher cache hit rates.

Right now for example, roughly half of my RAM is being used for caching and all of my swap is used. If I didn't have swap, most of that space used for caching would instead be used for those cold memory pages.

[–] frustbox@lemmy.world 1 points 1 year ago* (last edited 1 year ago)

I have a swap partition in my current system (64GB), I've had one on my previous system (which was 11 years old, with 16 GB) - I have seen my system¹ swap at most 5 times, and every time it was software misbehaving so badly that it made the system unusable.

I know this is anecdotal evidence - but my experience is that it's getting less and less relevant for most desktop systems.

Edit: ¹my old system, the new one has not swapped at all in the past year.