> Built for laptops with soldered memory and no upgrade path. If you have an RTX card sitting there with 8GB of VRAM and you're getting swapped to SSD, this puts that VRAM to work. Well, that does at least answer my immediate question about why I would ever swap from expensive RAM to really expensive RAM:) Feels niche, but when you want it it's a good idea.
Use your Nvidia GPU's VRAM as swap space on Linux
121–130 of 142 posts
Re: Use your Nvidia GPU's VRAM as swap space on Linux
#122Earlier quoted context omitted.
I am catching up on comments The reason I wrote this is I run this laptop in hybrid (AMD display + NVIDIA as swap). So all at VRAM was going to waste. On your question re: switchable swap. It's on my to-do list ;)
Wouldn't this prevent the nvidia GPU from being power gated since it's never "idle"? So like your battery life regresses?
Re: Use your Nvidia GPU's VRAM as swap space on Linux
#123Earlier quoted context omitted.
I am catching up on comments The reason I wrote this is I run this laptop in hybrid (AMD display + NVIDIA as swap). So all at VRAM was going to waste. On your question re: switchable swap. It's on my to-do list ;)
Wouldn't this prevent the nvidia GPU from being power gated since it's never "idle"? So like your battery life regresses?
Re: Use your Nvidia GPU's VRAM as swap space on Linux
#124Earlier quoted context omitted.
Wouldn't this prevent the nvidia GPU from being power gated since it's never "idle"? So like your battery life regresses?
Is VRAM not directly accessible by the system then? Since it's mapped directly into the CPU's address space, I had assumed that there's a simple DMA controller managing said access and I would then also naively assume that said controller is separate (or at least on a separate power plane) from the actual GPU.
Re: Use your Nvidia GPU's VRAM as swap space on Linux
#125Nice idea, but something has gone very wrong here: >Sequential throughput: ~1.3 GB/s [on a RTX 3070 Laptop] This RTX 3070 chip is on PCIe 4.0 x16 which should give 64GB/s. The 8GB of GDDR6 is 448GB/s. Swapping to an NVMe drive would be twice as fast, but with higher latency.
Gen 4.0 x16 is 32 GB/s in each direction, but the way this is implemented is not the way you'd go about this if you wanted high performance. Edit: Their benchmarks are also run using ZRAM, which compresses pages before writing to swap. Not sure what the performance overhead of that is, but it's probably quite a bit. First of all, it's a userspace program hooking the nbd driver, which is known for being slow. It also…
Even if the swap system overhead drops to just a data copy, the memory management layer prevents swap from scaling to higher bandwidths. The issue is not data movement; it is in the page unmapping step (which requires expensive TLB shootdowns). Larger kernel changes are required.
My group wrote a paper on this: https://dl.acm.org/doi/10.1145/3731569.3764842
Linux's swap system is undergoing some large refactors lately. Hopefully some insights either from our work or Hermit (NSDI '23) can make it in to the mainline. I think Hermit's `rmap` optimization in particular is a candidate for upstream use.
Re: Use your Nvidia GPU's VRAM as swap space on Linux
#126Re: Use your Nvidia GPU's VRAM as swap space on Linux
#127Re: Use your Nvidia GPU's VRAM as swap space on Linux
#128Re: Use your Nvidia GPU's VRAM as swap space on Linux
#129Why does my Apple Sillicon Mac with 32gb of RAM use (or even create?!) a swapfile, when 20gb is still unused/"free"? Why can I not just enter a simple command to entirely-disable swapfile, like with Linux's: >>>>swapoff -a Seems kind of silly, unless the point is intentionally to wear-down the SSD's lifespan . Having a GUI swapfile-disable system preference would be awesome. It would also be awesome if Apple finally…
The principle of a paging system is that main memory is just a cache for secondary memory, and the concept of "free memory" ideally rather means something like "memory that can be quickly reclaimed for another purpose". Sometimes anonymous memory will be of less us occupying main memory at some given time than would be letting cached file contents take their place.
----
>I have 20GB of RAM free (me)
>>~need to have quick access to main memory
>I have 20GB of RAM free (still me)
>>~yeah but "quickly reclaimed for another purpose"
>I have 20GB of RAM free (!m!e!)
//of//32GB//ttl//
----
In linuxland, I'd just type `sudo swapoff -a` and be done with it. That machine has 96GB of RAM, so it would have ~84GB of RAM free (if, hypothetically, the same hardare/configuration were operating that system).
Does. not. need. a swapfile.
The operating system, during bootup, should think "hey I have dozens of gigabytes of RAM, won't be needing any swapfiles" – behind the scenes and without input.