Live data from Hacker News

VRAMfs – VRAM based file system for Linux

github.com

1–10 of 26 posts

Re: VRAMfs – VRAM based file system for Linux

#2
Ideally then one should be able to use spare VRAM as a second level RAM - an area to page out things to before disk.

I've played a bit with the different memory compression tools on Linux, zram, zswap, and zcache, and they all behave in interesting ways on workloads whose active set is well over 2x available RAM. I played with compiling the Glasgow Haskell Compiler on small and extra small instances of cloud services, I wager this would work for the GPU instances on EC2 to increase their capacity a little.

The transcendental memory model in Linux is interesting for exploring these ideas, and it's one of the things I really like about the kernel. However the last time I played with it (Kernel version ~3.10) I had some lockup issues where the kernel would take up almost all of the CPU cycles with zswap. That was kind of a nasty issue.

Re: VRAMfs – VRAM based file system for Linux

#4

Ideally then one should be able to use spare VRAM as a second level RAM - an area to page out things to before disk. I've played a bit with the different memory compression tools on Linux, zram, zswap, and zcache, and they all behave in interesting ways on workloads whose active set is well over 2x available RAM. I played with compiling the Glasgow Haskell Compiler on small and extra small instances of cloud services…

> Ideally then one should be able to use spare VRAM as a second level RAM - an area to page out things to before disk.

It's already possible on Linux. You can use SWAP file instead of partition and there also SWAP priorities available.

Re: VRAMfs – VRAM based file system for Linux

#5
It's a cool idea; as other posters have mentioned, there have been other projects mapping VRAM for swap, etc.

I'd personally be wary of putting anything too important into VRAM. About five years ago I did a bunch of work testing consumer GPU memory for reliability [1, 2]. Because until that time GPUs were primarily used for error-tolerant applications (graphics) storing only short-lived data (textures) in memory, there wasn't a whole lot of pressure to make sure the memory was as reliable as that found on the main system board. We found that indeed, there was a persistent, low level of memory errors that could be triggered depending on access pattern. I haven't followed up for recent generations, but the fact that the "professional" GPGPU boards both clock their memory slower and include hardware ECC is possible cause for concern with leaving anything too important on the GPU for a long time.

There's code [3,4], too, but I haven't actively worked on it in a few years, so no guarantees on how well it runs nowadays...

[1] http://cs.stanford.edu/people/ihaque/papers/gpuser.pdf

[2] http://cs.stanford.edu/people/ihaque/talks/gpuser_lacss_oct_...

[3] https://github.com/ihaque/memtestG80

[4] https://github.com/ihaque/memtestCL

Re: VRAMfs – VRAM based file system for Linux

#6
The concept is not new - I remember some utilities that would let DOS use the VRAM on a VGA (256KB available, but slightly less than 4KB actually needed in 80x25 text mode - and 256KB was a big amount in those days), back in the early 90s. There were some demos that used this to their advantage too.

Re: VRAMfs – VRAM based file system for Linux

#7
Could anybody please explain to me why there is a need for a special treatment of VRAM compared to a regular system RAM in this use case? Assuming, we can perform an allocation in VRAM (probably using OpenCL API), why can't we use tmpfs/ramfs code? Do I understand correctly that PCI maps VRAM to a certain memory region and it is accessible via regular CPU instructions? Is it because CPU caching is different or VRAM is uncacheable? Or is it something else?

Re: VRAMfs – VRAM based file system for Linux

#8
post #7

Could anybody please explain to me why there is a need for a special treatment of VRAM compared to a regular system RAM in this use case? Assuming, we can perform an allocation in VRAM (probably using OpenCL API), why can't we use tmpfs/ramfs code? Do I understand correctly that PCI maps VRAM to a certain memory region and it is accessible via regular CPU instructions? Is it because CPU caching is different or VRAM i…

VRAM is not mapped to the same memory space as your normal RAM and it is not directly accessible via regular CPU instructions. It's wholly owned by the GPU, and that's who the CPU has to talk to to use it.

This is in fact a (if not the) major limiting factor to expanded use of GPUs for general purpose calculations: you always have to copy input and results between video RAM and normal RAM.

Re: VRAMfs – VRAM based file system for Linux

#9
post #7

Could anybody please explain to me why there is a need for a special treatment of VRAM compared to a regular system RAM in this use case? Assuming, we can perform an allocation in VRAM (probably using OpenCL API), why can't we use tmpfs/ramfs code? Do I understand correctly that PCI maps VRAM to a certain memory region and it is accessible via regular CPU instructions? Is it because CPU caching is different or VRAM i…

VRAM is not mapped to the same memory space as your normal RAM and it is not directly accessible via regular CPU instructions. It's wholly owned by the GPU, and that's who the CPU has to talk to to use it. This is in fact a (if not the) major limiting factor to expanded use of GPUs for general purpose calculations: you always have to copy input and results between video RAM and normal RAM.

Yes, it's owned by the GPU, but you can map it to the regular space. In fact, this is exactly how textures and other data gets loaded to the video card. See http://en.wikipedia.org/wiki/Memory-mapped_I/O

Re: VRAMfs – VRAM based file system for Linux

#10
post #9

Earlier quoted context omitted.

VRAM is not mapped to the same memory space as your normal RAM and it is not directly accessible via regular CPU instructions. It's wholly owned by the GPU, and that's who the CPU has to talk to to use it. This is in fact a (if not the) major limiting factor to expanded use of GPUs for general purpose calculations: you always have to copy input and results between video RAM and normal RAM.

Yes, it's owned by the GPU, but you can map it to the regular space. In fact, this is exactly how textures and other data gets loaded to the video card. See http://en.wikipedia.org/wiki/Memory-mapped_I/O

True -- you can use (in OpenCL) clEnqueueMapBuffer to get something that looks like memory-mapped IO, but the consistency guarantees are different from regular host-based MMIO. Specifically, if you map a GPU buffer for writes, there's no guarantee on what you'll get when you read that buffer until you unmap the region. (You can think of it as buffering up writes in host memory until you unmap the region, at which point it's DMAed over to the GPU.)

See the "Notes" section in https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/c...

Post reply on HN