You are viewing a single thread.
View all comments
85 points

Can someone explain how this works?

permalink
report
reply
11 points

Modern computers are set up so that they can use the SSD/hard drive as extra, much slower RAM. Typically, when normal RAM is full, and you need more, a page of data in RAM will be swapped for a page of data on disk. On Unix, they end up in something called the swap file or swap partition, and on Windows, the equivalent is called the page file. In the screenshot, someone’s mounted their Google Drive as a filesystem, and told their computer to use it as the swap partition, so instead of swapping to disk, it swaps to the cloud. This is obviously way slower, but they’re effectively now using the cloud as RAM.

permalink
report
parent
reply
91 points

So RAM is just memory space that is accessible very quickly by applications that need it. Many applications use it to just temporarily keep information while you have it open. If you have a lot of applications open or you have an application that stores a lot of things even if it doesn’t immediately need it all, you can run out of it quickly.

A swap space is a Linux tool (though there are similar things in Windows) that reserves a spot on your hard disk to move data to and from RAM, to keep data that isn’t actively being used off the RAM and data that is being used on it. That way you’re not as likely to run out of memory from memory-hogging applications.

There’s a separate tool to use Google drive space as a disk in Linux. Then, once it’s configured as a disk, you can make it act as a swap space. Of course, this is very slow even compared to normal hard disks, but the point is it is possible to do it.

permalink
report
parent
reply
33 points

All you need to know is that RAM is all about being extremely fast.

Swap is disk space set aside to be used as virtual Ram (part of your disk become RAM ) for when you have no more real ram. It’s useless on modern computers because RAMs are at worst of worst 100 times faster than the fastest SSD. If you have no ram it’s just best to crash the OS than making it slow down to a crawl or freeze.

This person use their Google drive as swap which make it even far more useless because even the slowest ssd is probably faster than the best commercial internet connection even with a perfect latency.

In short, it’s extremely cursed.

permalink
report
parent
reply
4 points

I’m old enough to remember that my swap drives used to be on spinning drives that were slower than my gigabit fiber. Well, I’m actually older than that but still. If I really needed to run some unoptimized task that required a lot of memory I could consider trying it and walking away.

permalink
report
parent
reply
2 points
*

I’m old enough to remember that my swap drives used to be on spinning drives that were slower than my gigabit fiber.

be me

the year is 2023

have a spinning drive and no gigabit fiber. ( gigabit fiber doesn’t exist where i live )

become sad.

Joke aside, i don’t think swap is worth it because i think nobody is willing to have their computer locked for tens of hours or even days for something to finish considering it’s literally impossible to know if the app is working or is hung ( search the halting problem for more info).

permalink
report
parent
reply
3 points

I’m old enough to remember when my first computer had a 210MB hard drive and 4MB of ram.

permalink
report
parent
reply
12 points

I don’t know about useless.

I’m much happier now that my work laptop slows down when I compile something during a zoom meeting, vs when it used to run out of memory and crash.

permalink
report
parent
reply
6 points
*

If you have no ram it’s just best to crash the OS than making it slow down to a crawl or freeze.

That very much depends on what you’re doing. Even with rather random access patterns (e.g. compiling) swapping out doesn’t crash performance terribly, mostly because my RAM isn’t exactly under-dimensioned (I used the rule of thumb “one gig per hardware thread, round up”). For more regular access patterns such as merging SDXL models (which definitely eats all my 16G) the impact is even less. For, dunno, highly complex and irregular datalog queries over a database four times as large as your RAM – yeah that won’t be nearly as fast.

What you also want to do (under linux) is enable the earlyoom daemon. Those freezes are Linux being way too nice and not killing processes until literally every cached and buffered thing has been purged, also heavily-used ones.

Then you’ll see behaviour such as switching tabs in the browser, or bringing up a minimised terminal or something actually taking a second or two because they got swapped out. But it’s nowhere close to unusable and, due to a 3G/s SSD, a way better experience than in the 90s with a couple megabytes of RAM and swapping to a glorified flywheel.

I could by more RAM, DDR4 prices have pretty much tanked after all, OTOH I swap out like fifteen minutes every other month. Not worth it, I have coffee to make.

permalink
report
parent
reply
1 point

While an interesting read, my comment isn’t directed at advanced users that know their stuff. Also, not everyone own a beast, most users have a medium or low tier PC. Funnily, 16GB of RAM for your usage seems low. Double that and you’ll never need swap unless you want to play with the biggest local LLMs via Llama.ccp. But then, you likely have a GPU beast.

permalink
report
parent
reply
10 points
permalink
report
parent
reply
12 points

Well it does. But its just not practical.

permalink
report
parent
reply
6 points

https://youtu.be/JcJSW7Rprio You might enjoy this, impractical hard drives nobody asked for.

permalink
report
parent
reply
4 points

Here is an alternative Piped link(s):

LTT tried it and explains why

Piped is a privacy-respecting open-source alternative frontend to YouTube.

I’m open-source; check me out at GitHub.

permalink
report
parent
reply
174 points

In a nutshell (eli5) swap is sorta “very slow ram” which is actually just a section of your hard drive /SSD/some other bizarre medium. It is generally used to temporarily store information that might be needed later but would waste valuable “fast ram” which is your actual ram sticks.

What’s going on here is this user mounted Google drive in a way that the operating system can interact more directly with it, and it appears to have a set amount of space. Because we’ve mounted Google Drive we can tell our operating system to use it as swap…very very slow silly swap, but swap nonetheless.

So that’s exactly what they did, they told the operating system to set aside X amount of Google Drive for swap, and when looking at the resource monitor we can see the “swap” appears as “more ram”.

Hope that helps, please ask if I confused you :)

permalink
report
parent
reply
41 points

I’m pretty sure google drive just acts like a syncing tool in the same way as dropbox, so this would still act like a normal swap drive, presumably.

That said, I’ve only used swap partitions so I’m not sure how it works when you point it at a directory, but I guess it depends how this person set it up.

permalink
report
parent
reply
59 points

They’ve used google-drive-ocamlfuse to mount the drive in Linux, which if I recall correctly is direct access, rather than the way it works in Windows

permalink
report
parent
reply
4 points

You’re right, this wouldn’t really work, but it’s still a funny idea.

permalink
report
parent
reply
9 points

Time to use my floppy as a swap space 😎

permalink
report
parent
reply
2 points

Can I watch?

permalink
report
parent
reply
8 points

I’ve used my floppy in a few swap spaces myself if ya know what I mean…

permalink
report
parent
reply
5 points

Thanks <3

permalink
report
parent
reply
20 points

A normal swap space is a partition on a hard drive that is used as overflow for ram. It allows the computer to continue working if all the ram is being used.

As far as using google drive as a swap, i have no idea how that would be implemented, but if it’s real, the computer would just upload overflow memory to g drive.

permalink
report
parent
reply
3 points

Thanks :)

permalink
report
parent
reply
6 points

It’s real, I’ve seen the blog post from them

https://blog.horner.tj/how-to-kinda-download-more-ram/

permalink
report
parent
reply