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.
OS overhead may well overshadow any gains from nanoseconds saved in the video RAM.
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.
This might come off as a troll or offtopic, but you shouldn't be swapping. Buy more main memory.
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.
VRAM speed is optimized for access by the GPU.
In addition, AGP buses will provide much faster writes than readback. PCIe devices should have less of this problem.
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
Video card memory is much more expensive than normal RAM for a reason, as it has to support crazy throughputs for things like alpha blending. This throughput advantage does not apply when the host (CPU) accesses the memory. PCI Express is a lot faster than AGP, but it's still a bottleneck that makes it much slower than native RAM. Like the person above me already states, you're much better off just buying some extra RAM.
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/
Yes, and that's why they want to kill whitey.
Are you sure the system has video RAM? Doesn't built-in video generally share the system RAM?
No.
It's an interesting hack to use it as such, but in terms of performance you're better off investing in more RAM and a faster HDD.
s/niggers/trolls/g
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!
I, for one, pick Direct Rendering...
In other words, this is useless.
Finally! A practical use for those ATI video cards that have 1 GB of video RAM!
I have never used the ram on my graphics card for swap or as a ramdisk however that is an interesting idea. I use ram as ramdisk for some of the directories on my gentoo stations. It seems to make some processes work faster. I would have to do some down and dirty testing to see if the overall performance increase is worth the amount of ram used by the ramdisk. I currently have no less than 4 gigs in any machine that I am doing this with thus it is not a big issue however if you are running on 512 or even 1 gig and are using quite a bit of space for your ramdisk it will end up causing it to be slower than normal due to the shrinking in the amount of ram available.
I do also agree that agp is a slower technology and that most older graphics cards only contain small amounts of memory in comparison to the mass amounts of ram that can be bought today for little money.
Who knows... It might work great... I may have to test this out tonight and see what I come up with...
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.
Once again I'm sad funroll-loops.org is only available via internet archive. This would make a prefect addition.
http://web.archive.org/web/20061004200708/http://www.funroll-loops.org/
But his server is headless, as servers should be. What is he going to be directly rendering to?
He also stated the videocard was built in, so he cant even put it to good use in another machine.
http://spamdecoy.net - free throwaway anonymous email - avoid spam!
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!
How can you say this about teh Linuxxxx!!!
Why does /. even allow AC posting still? Seems like a flame/troll enabler.
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.
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.
Onboard video still uses the same bus structure as available for expansion (believe I saw 1 board with all PCI slots & an ISA onboard video but it was fucked from the get go). Most of the chipsets will simply load the data on the bus & be done with it - the BIOS cuts out the onboard at POST when another video card is detected. A few of the boards seem to route through the onboard in a serial rather than true bus fashion(greatly reduced framerates on boards with the same video card & similar chipsets w/ & w/out the onboard video).
Alot of sever boards have low end pci video cards built into with other i/o on the same pci bus. So this will not work that good in a setup like that.
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!!!
0) AGP performance sucks for this ;)
1) How sure are you that they test video ram well enough to use for that purpose? Some people might not notice a few display artifacts due to video ram having one bit stuck at zero or one, but for swap that's not good.
2) Just buy more _real_ ram, nowadays for normal usage, I recommend setting a small swap partition, that's only purpose is to tell you that you're running out of ram (by making the machine more sluggish). Set the swap too big and you have the entire machine running from swap which nowadays is about as good as powering the machine off abruptly (since that's what everyone does rather than wait weeks or more). Hard drives are too many magnitudes slower than real RAM for users to want to recreate the "Drum memory" era. Who sets their ssh and tcp timeouts to 1 month?
3) If you need more ram than the old machine can get you, buy a new machine, the last I checked PC hardware is cheap, they're amongst the cheapest things in the world for the technology and materials you get. Use the old machine for something else or give it away.
you get really crappy read speed even with pcie atleast with nvidia 7600, the write works nice but really usless. Someone should make a pcie card with slots for ddr/pc133 so we could these gigs that just lays in the drawer this would be far more usefull.
Since it's an old machine with onboard video it's quite possible it's using system RAM as graphics RAM. So, check out the BIOS, there might be a setting to reduce the amount of memory allocated to the graphics adapter in the fist place. More efficient than trying to swap through some obscure hack :)
Connection closed by foreign host.
Why does /. even allow twitter to continue posting? Seems like a flame/troll enabler moreso than an AC
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.
Thats not quite correct. Traditionally Windows OpenGL and Direct3D drivers has had poor readback speed, but linux less so. I just tested and got 825/625 MB/s (glDrawPixels/glReadPixels) on a FireGL X2 (R350) on AGP.
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.
Dear trolled,
You were so riled-up about some lame comment about niggers that you felt compelled to strike back by assaulting the GP AC's trollhood, anonymously no less.
YHB so T.
You only have to sacrifice direct rendering if you're using a blob in which you can't control the amount (or regions) of memory to use. Which should be an extremely trivial option to support.
Why would you want direct rendering anyway? There isn't really much to play.
I use to have a disk copy tool for a mac that used video ram when duplicating floppies to try and make it faster... It made a bunch of nice garbage on the screen while it was working too. That was 15 years ago, I'm not impressed...
It wasn't really that practical back then, and it's certainly not practical at all today...
Dear troll,
and that's the whole problem with the "omg troll" mentality -- small-minded cretins assume they know the motives behind a post merely because its content goes against accepted social standards.
to assume a post is a "troll" or "flamebait" assumes that the poster desires responses, or to cause arguments, but there are an infinite amount of other possible motivations for posting rude, nonsensical, or off-colour posts.
perhaps posting racial slurs on slashdot eases some psychological burden. perhaps the poster is insulting his own race in an attempt to normalize the taboo words. perhaps the posts are a form of performance art. perhaps they are intended to pollute slashdot and drive posters away in disgust. perhaps they are intended to keep posters at slashdot by discouraging browsing at certain levels. perhaps they are inside jokes intended to amuse a certain group of people.
it isn't a binary world. viewing such important and critical matters such as nigger posts so myopically is criminally irresponsible.
i think you need to issue a retraction.
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
On a sane OS (like Linux) you're right. He's probably a Windows user.
Windows is not sane, allow a swapfile and Windows will use it to free up RAM for caching, often harming performance by swapping things that would have fit in RAM otherwise. On a WinXP system with enough RAM disabling swapping can give noticeable speed improvements.
On Linux it makes no noticeable difference and there's no point disabling it.
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
@Bert64 RTFA, I wasn't talking about 'him'. I was talking about me.
And @AC, you obviously haven't got a clue about the state of the 3d drivers for GNU/Linux, do you? As in, they're all blobs. Also, your knowledge of gaming on this platform is from the jolly 1990s.
One of the best things you could possibly do to speed up an Windows 9x or NT4 machine was to limit the disk cache.
.... the whole system ran a lot better when you prevented the disk cache from swapping programs out to disk.
No more juddering, no more half-burnt CDs because you dared to move the mouse around while it was burning
Guess which feature they took out of XP?
That's right - the ability to limit the size of the disk cache!
So we're back to using stone-age machines which grind to a halt for half a minute when you open a window which was closed for a while.
No sig today...
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
try again
In the time it takes you to post this question and read the replies, you could have gotten a job at McDonald's and earned enough money to buy some real hardware.
A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
Mod parent up!
Here we have a perfect example of some hardware (memory) which was specialised to better support a specific application (video), but then some users decided they wanted to do something else with it (swap) and found that they would be better off if they had general-purpose hardware for all system functions rather than specialist hardware for every function.
Perhaps hardware manufacturers should invest their time in optimising and speeding up general-purpose hardware (memory), rather than designing specialist hardware that "lock" the user into particular usages (video RAM).
Another poster has described the evolution of GPU devices to GPGPU and the need for symmetrical bus speeds. The concept of having the video subsystem server as a swap device is brilliant. The RAM speeds are high, and the GPU can mediate the operation. I'm going to assume that this becomes the norm in the near future. I know that HTPCs usually have some nice graphics hardware, and that some people are already using two high-end video cards in their systems for gaming/CAD. Seems like a smart board designer will pick up on the idea and integrate a swap device on the video subsystem.
Best regards.
Hi,
I've also been doing this on my laptop for about 2 years now. I have
no use of the 64 MB video RAM on it, and I could dedicate 56 of them
to the swap. While it has a very low read speed (8 MB/s), write speed
is fast, and seek times are NULL. You have to remember that when you
are swapping to a disk, you're very lucky if you can even reach 8 MB/s,
as all the time is lost in seeks. Swapping is one of the most random
patterns on disks, and disks are extremely slow at this job.
I really see a speed difference between VRAM swap and disk swap, but
I try to use them very rarely anyway.
Willy
If the server operates within some form of high availability setup where a second server can take its place if the primary server gets broken, then just do a real-life test: Enable the videoRAM swap and write down how long it takes it to satisfy every Web request, whether its mail queue gets clogged up easily, etc. Then enable the HD swap and do the same.
If, however, the server is not in high availability setup and is important for you, then just don't touch it :)
I've been reading Love's new book on systems programming and it talks about Linux read-ahead strategies. If this RAM disk was faster than RAM, wouldn't your performance get killed by Linux caching your data read from the faster video RAM (if it is faster) into regular RAM? Would you ever hit the RAM disk for frequently used data (and if it wasn't frequently used why bother)? I went back and read the question again, but don't see any indication of what is going to be stored on the RAM disk. What it seems like Linux would do is keep anything you use often enough to put on a RAM disk in its memory disk buffers anyway. They'd be accessed so often they'd never get old enough to be deleted from memory. (Obviously this would be read-only. You wouldn't store anything volatile on this RAM disk!) Might be a neat hack, but it doesn't seem to have much practical value. Most video card memories are sort of small, a few MB, and anything you would put in that RAM disk would fit into the disk cache anyway, so if you put something frequently used onto the RAM disk, that data would be read from the cache. I'd bump your system memory to 2GB and let Linux's caching do its thing. I don't think I've swapped a memory page all year.
Because we most definitely are not getting ~80MB/s from the outside of the platters with the AAK firmware. That crap's got an artificial limit in it.
He is comparing with a hard drive that will be connected to the same or a slower bus than the graphics board.
Anyone got any screenshots? :)
; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
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).
I've had a very similar situation, like what poster of the story describes.
The computer with which I tested the "video-swap", is a Celeron 433, with Intel 815 chipset. It had 128 MB of main RAM.
The videocard is ATI Radeon 9000 with 64 MB of RAM. Of these 64, I configured 56 megabytes to be used as swap.
It worked absolutely fine, even with X (which was hardlocked in config file to the bottom 8 MB).
However, the speed of read/write access to the video RAM was not great at all.
Reads were about 4.5 megabytes/sec, and writes about 11.2 megabytes/sec.
In addition, during reads or writes even at these low speeds, the process named "mtdblockd" was chewing up 99% of CPU.
I tried both slram and phram modules, they both worked, performance of both was the same.
I believe something somewhere code along the code path (phram|slram -> mtdblock -> mtd ) is poorly optimized for this type of task, because 11.2 or 4.5 megabytes is too large of a difference from 1066 megabytes/sec AGP 4x (at which rate my videocard worked), theoretically allows.
Also, 99% CPU load while accessing video-RAM through mtdblock device is a serious issue which may limit its usefulness for swapping.
I stand corrected. Tseng labs, wow, haven't heard that name in a while I remember when some of their cards came out, they were hot stuff. Didn't know they ever made an EISA version of those.
As a rock-in-roll Physicist once said, No matter where you go, there you are.
Isn't that an Oxymoron like jumbo shrimp or Microsoft Works? Shouldn't the proper terminology be "x is one half the speed of y" or "x is one third the speed of y"?
No one seems to be asking the question as to why swap is even being used these days. I have dozens of servers and the swap space is barely touched. Main memory is cheap so just forget about swap. It's a hack from the days when memory wasn't cheap.