Is Video RAM a Good Swap Device?
sean4u writes "I use a 'lucky' (inexplicably still working) headless desktop PC to serve pages for a low-volume e-commerce site. I came across a gentoo-wiki.com page and this linuxnews.pl page that suggested the interesting possibility of using the Video RAM of the built-in video adapter as a swap device or RAM disk. The instructions worked a treat, but I'm curious as to how good a substitute this can be for swap space on disk. In my (amateurish) test, hdparm -t tells me the Video RAM block device is 3 times slower than the aging disk I currently use. If you've used this technique, what performance do you get? Is the poor performance report from hdparm a feature of the hardware, or the Memory Technology Device driver? What do you use to measure swap performance?"
Is your adapter an AGP or PCI-Express card? Because PCI-Express has fast lanes both ways, and AGP is not so fast in writing back. That could explain a part of the performance problems.
I'm assuming your ancient system uses an AGP interface for graphics, which has a very fast download rate, but very poor upload. The maximum performance of AGP uploading data from the card memory to the rest of the machine is pretty slow (less than 100MB/sec, IIRC), and it will vary depending on the implementation. This is probably the reason you got such slow benches.
PCIe will likely give you performance more in-line with main memory (most implementations now are hitting 1-2 GB/s).
Man is the animal that laughs.
And occasionally whores for Karma.
How much RAM is in your video card? 64 megabytes? 128? If it's an older machine, probably much less than that. Assuming you have less than a gigabyte of main RAM in your system it's probably much more worthwhile to drop a few dollars on expanding that and running whatever RAM disk you need in there.
But there is a fundamental problem: vidRAM is optimized for writes from main RAM. Not reads. In many cases, reading vidram is extremely slow because the raster generator is busy reading it. Writes are buffered. Reads cannot be.
This doesn't sound like the most stable thing to do especially if your running a server on the same computer. It sounds good on paper but implementing it is a whole different game. From my years in IT never try anything like this on production servers, thats what test servers are for.
It doesn't come across as troll or offtopic, just misinformed. If you can swap out an unused page of code or data to provide more room for disk cache, why not do it? You should take a look at what your OS is actually doing with memory some time.
- None can love freedom heartily, but good men; the rest love not freedom, but license. -- John Milton
Bear in mind the poster is talking about *swap* space. That is, the hard drive. Video RAM is orders of magnitude faster, aside from issues reading back from the video bus.
Today's weirdness is tomorrow's reason why. -- Hunter S. Thompson
Err... Which hdparm timings are you looking at?
One of the biggest advantages of using VRAM for disks is the nearly 0 seek latency.
As a result even if the card is slower than disk on read you are still likely to have an overall performance gain.
In addition to that there is a number of architectural vagaries to consider. AGP is asymmetric. Reading is considerably slower than writing (can't find anywhere by how much. Damn...).
Baker's Law: Misery no longer loves company. Nowadays it insists on it
http://www.sigsegv.cx/
Are you sure the system has video RAM? Doesn't built-in video generally share the system RAM?
I know headless means that the system doesn't have a screen but I still get this idea of a box strapped to a horse, chasing down Ichabod Crane.
Kwisatz Haderach
Sell the spice to CHOAM
This Mahdi took Shaddam's Throne
When our name is on the back of your car, we're behind you all the way!
Heck, I remember RAM expansion cards for ISA slots. I'm sure this is faster, though I didn't get any meaningful boost when I tried this once. Nevertheless, if you're running headless system, it's better IMHO if you get some use of the display hardware, rather than no use. Even if it's a little slow. You shouldn't rely on swap as a memory expansion anyway, it's just a way to gracefully degrade performance when you hit the limit.
I think it's also nice to have swap on a different physical device/bus from your main hard drive. Maybe the swap isn't any faster, but at least it isn't slowing down any other hard drive usage.
Escher was the first MC and Giger invented the HR department.
Dear troll,
You are not very good at this. People on slashdot are more or less immune to trolls that use racial slurs. In troll 101, you should have at least learned to disparage an OS or programming language if you really want to rile people up. This is a good troll, that is also topical:
"Linux is not a very good OS to use for swapping to the video card. It's video bus support is hopelessly dated and slow, though you can use the experimental driver if you patch the kernel."
That simple statement will get you far more responses, and perhaps even get modded up by some clueless folks with mod points. Then you can masturbate feverishly until the next time someone tries to cross your bridge.
Now if you want truly blazing speed, you can track down some of that dual-ported static RAM that came in 40-pin DIPs. Full random access on both ports would let you serve dynamic web pages while you run customer transactions, all with zero wait states on the ISA bus!
Besides, Slashdotters have never bought the "why are you running if you have nothing to hide" argument.
You know, there is a difference between trolling and pointing out the flaws in your reasoning. Just saying.
It's very cool that the memory becomes available so easily with just a couple driver parameters. It's a pity that there's a lot to optimize before it can really shine.
Memory architecture on a GPU is very different from system memory. Memory there is not linear and the video memory controller will go through a lot of remapping to present it as such, something that's probably very slow because of the VBIOS. Then there's the issue of tuning the bus so that reads and writes are using its full bandwidth, and again a poor VBIOS implementation may be the bottleneck.
The best but harder solution would be to have a means to program the video memory controller directly to map pages of system memory and do all the copying and moving itself. Of course, this is hardly ever going to happen, but some improvements can still make it into the VBIOS, some of which will probably happen once GPGPU-style programming starts getting more attention as both nVidia and AMD/ATI are seemingly interested in pushing with things like CUDA and Stream Computing.
The concept as it is now, however, remains extremely cool. It might still be orders of magnitude slower in terms of latency and throughput compared to system memory, but it should be a lot more responsive than a hard drive just because there are no seek times involved. That said, hdparm -t may not be the best tool for measuring performance, so i'd be more interested in a random access benchmark since it may make some use of the parallel memory architecture inherent on a video card.
- Otaku no naka no otaku, otaking da!!!
This sort of brings up another issue he might be happening. A lot of on board video cards use system memory to function properly. If the swap space is actually in system memory, the extra transfer overhear of going up the bus to the controller that then send it back to the memory that is actually sending the stuff to the video ram.. Well, you see what I mean. The extra few steps could be enough latency per read write operation to slow the thing down compared to a direct access method that would be present with an IDE connection as well as video memory built on to the video car itself.
I think the differences might be as noticeable as turning DMA (direct memory access) on and off. And yes, you can see a big bit of difference. It was actually worth me buying new drives just to have DMA access when it first started becoming available. I remember earlier versions of windows 98 and (95 I think), that wouldn't turn it on by default. After making sure the drives supported it and enabling it, people would almost think they had a new computer. There was that much of a difference in performance.
And to think people laughed at me when I bought a shiny new 1GB video card!
You know, there is a difference between trolling and pointing out the flaws in your reasoning. Just saying.
Built in is relevant since nearly all built in adapters do not have their own RAM. They borrow some of the system's RAM to use. As such using it as swap is dumb, since it is just system RAM. A better solution is to turn down the amount of RAM the onboard card gets to reserve (usually the BIOS can control this). Separate graphics adapters almost always include their own RAM, and as such could potentially be useful.
giant, slow, purple monster of a computer that is like 10 years old. It has the name Onyx on the front. i think it has like 1GB of vram.
I also have this 12-15 year-old beater of an Intergraph box. i think it has like 64MB of vram.
Just 'cause it's old doesn't mean it was or is lame.
That beater of an Onyx can still thrash your SLi.
And the Intergraph's video card was EISA or microchannel, i can't remember which.
But mostly i'm just pointing out corner cases because other repliers to the parent felt it necessary to trash old gear. remember, in 10 years today's gear will be bupkus.
"If still these truths be held to be
Self evident."
-Edna St. Vincent Millay
Like this one: http://techreport.com/articles.x/9312
It works wonderfully for Windows swap file! (and better still for Photoshop/Premiere swapfile) It is limited to 4GB (draws power from the PCI bus) and it is driver-less. (works with ANY PC motherboard supported OS)
It connects to the PC using a SATA1 connection (but a continuous 1.5 Gb/s is still better than most HDDs) and it uses 4x 1024MB DDR1 RAM Modules.
There is a future 8GB DDR2 SATA2 3.0 Gb/s model (allegedly) coming out soon that fits in a 5.25" drive bay:
http://techreport.com/discussions.x/10116 (please, oh please, don't be vaporware)
Might be faster if the driver knew about DMA. Your harddrive, even thought it is slow, has DMA. So when you want to swap out pages you can set it and forget it. You're not really in any hurry to swap out, only to swap in. So it seems while a harddrive lets the CPU do other work while it ways for the pages to be copied, the MTD slram driver does not.
There isn't enough memory on a videocard to really make it worth doing the right way either. Mine only has 256M which is not that big compared to systems that have 1G to 2G of system RAM and 1-4G of swap.
“Common sense is not so common.” — Voltaire
Which is, of course, a completely useless and disingenuous answer to a person who already has the graphics memory sitting around, and wants to know if it is better than a hard drive.
You seem to be advocating wasting perfectly good VRAM in favor of buying more system RAM. If the VRAM is essentially free (ie. comes with the system no matter what), there is no good reason not to try to put it to good use.
Also, your "No" is completely unqualified. You offer no details of how VRAM performs worse as swap space than hard drives, let alone actual benchmarks or citations. (And I have the feeling that most graphics memory would be significantly better than your average IDE hard drive for swapping.)
Mod parent overrated.
Since the PlayStation 3 has only a small main memory that's hardwired and nonexpandable (Sony's lamest design decision of all), the Linux that runs on it is severely constrained. PS3 Linux is constantly swapping to compensate for the small memory. But the PS3 does have another small VRAM bank (that's extremely fast XDR). PS3 Linux hackers are working on using VRAM as swap, out of necessity. Their design analysis is probably instructive for anyone considering any platform's VRAM as swap.
--
make install -not war
You are incorrect.
I remember back when I got my first post-ISA graphics card - in order to get better kick my neighbors ass in Descent, IIRC.
Anyway, I distinctly remember having to chose between EISA and VLB (VESA). For whatever reason, I wound up going with a Tseng Labs ET4000 EISA card sporting 1MB of VRAM.
I also recall the salesman's shock at my asking what the speed was of the memory chips. He'd never had anyone ask that before... which was actually a bit surprising since the performance difference between the slow and fast memory chips was quite substantial.
Wikipedia's article on the ET4000 card even mentions an EISA version!
And here is a link to a specific ET4000 EISA card, although not the one I owned (and probably still have in a box in the basement).