# Use VRAM as System RAM before actual RAM

## Well.Heeled.Man

Hi Folks,

Just a quick question that I was pondering:

I have an Nvidia 570m with 1.5 GB of VRAM. This is considerably faster than my system RAM, and underutilized in a Gentoo system. Can I set aside say, 1GB of this as system RAM and force the system to use this before the system RAM. In normal usage, it seems that I would never really be in a position where I would need to use the system RAM and I would get a minor performance boost.

I would guess that I would need to set up some kind of block device on my VRAM that is mounted a swap, and use vm.swapiness in sysctl to encourage swapping before RAM usage. However, even with swapiness=100, it will still use my system RAM as I have 16GB of it. Does anyone have any experience/comments/guides RE: this and in particular, a way to force the system to use swap in preference to RAM.

Cheers,

Scott

----------

## eccerr0r

 *Well.Heeled.Man wrote:*   

> 
> 
> I have an Nvidia 570m with 1.5 GB of VRAM. This is considerably faster than my system RAM,

 

I don't quite understand this.  Video graphics card memory has additional latency to access - system RAM is always faster.  Video RAM (with bus latency) however is faster than hard drive, so you can always swap to it with benefit

Swap is swap.  This means the system actually uses real system RAM and then "swaps" it out to secondary storage, whether it be hard disk or video memory.  Of course this is slower than just using real RAM.

However, since you have 16GB RAM there's no need for swap.

Not sure where you see where the performance boost.  At best PCI/PCIe/AGP memory is memory mapped and you can access the mapped area directly without paging...  but as swap you lose any speed benefit as it will need to copy from/to the storage.

----------

## Well.Heeled.Man

Using it a swap was just how I envisaged it working, but I see what you mean. I was not thinking about the additional latency; I was only thinking about the fact that my VRAM is overclocked DDR5 @ 1900mhz and my RAM is DDR3 @ 1333.

Is it possible to directly map the PCIe VRAM? Obviously this would have implications for the GPU, but I am not sure I need more than 0.5GB VRAM for non-gaming workloads.

----------

## eccerr0r

It takes several tens of cycles to access the first byte for PCIe, then the memory controller on the video board has its own latency to deal with, which is probably not much different than DDR3 overall.  The sum of the two will probably be worse than the DDR3 by itself.

This isn't really worth it in my opinion.  The latency will kill overall.  And not even mentioning the bandwidth of PCIe versus a direct memory controller connection.

----------

## NeddySeagoon

Well.Heeled.Man,

With well designed software and a decent amount of on chip CPU cache, you rarely get a CPU stall waiting for main memory.

Instead the cache hit ratio is over 95% and CPU cache is full CPU core speed.

It may not be possible to cache VRAM in th CPU. That would mean the CPU has to snoop on what the GPU does to its VRAM, which sounds expensive in terms of bus bandwidth

----------

## ToeiRei

I once used the Graphic cards memory as a block device for keeping swap files... Wouldn't that solve your problem somehow?

The howto I used back in 2006: http://my.stargazer.at/2006/04/10/graphikspeicher-als-storage-verwenden/

maybe that helps

----------

## boerKrelis

The VRAM is wicked fast *from the perspective of the GPU*. From the CPU, writing to it isn't quick and reading is even slower (it's not really a use case to read textures *back* from VRAM).

----------

## depontius

I've heard that from a cost perspective, you may just be ahead to get a small SSD for use as a swap device.

----------

## i92guboj

Any of the specs that you read for your graphics vram is referred only to it working in conjunction with your gpu, not the main cpu. In any chain, the strength of it is defined by the strength or the weakest link, in this case, the bus. If your reasoning was right, then there'd be no sense in having memory slots. We'd just plug the ram into the pcie or agp slots and be done with it.

----------

