Saturday, June 21, 2008

Pushing On a String (RAM vs. CPU)

I found a disturbing text file on a user's computer...the user had a P-IV 2.8 ghz CPU and a GeForce 8800GTX. An excerpt:
Day 458 of my captivity. Life continues to be an immense, boring string of idle pauses, punctuated with drawing tasks way below my dignity. I am a GeForce 8 - why doesn't anyone here respect that? And yet when the user is playing "X-Plane" I spend long milliseconds with nothing to do while that infernal Pentium IV thinks carefully about what triangle I should draw next. Life is so dull. That Pentium IV must be the dumbest chip to come out of the fab plant - surely he is the runt of his wafer. Sometimes I become so despondent that I consider turning my fan off and cooking myself to death to end my misery. Perhaps I will intentionally blue screen the operating system...
Okay, so I made that up. But I'm sure that if you put a GeForce 8 into a P-4 system, that's about what the card would be thinking - it would be bored silly. Even the fastest Pentium 4s can't feed data rendering instructions to a GeForce 8 fast enough to utilize the hardware.

And in this sense, hardware can be like pushing on a string. Even if putting worse hardware in your machine would lower fps, putting better hardware in it may not improve fps. If you have a P-IV and a Geforce 8, putting a Geforce 2 MX in its place will lower fps, but upgrading to a GeForce 9800 won't - it will just leave your graphics card even more bored and angry than it was before.

This is because the slowest component in the graphics pipeline determines fps. Improving the speed of the other components just leaves them idle more of the time.

Why RAM Isn't like CPU.

When your system is limited by CPU, the change in performance is somewhat linear - get a 20% faster CPU and you get 20% more FPS.

RAM isn't like that...usually you either have more RAM than you need (and life is good) or you have too little, and your framerates is so bad you want to pull your hair out. Why is that?

Well, the difference between RAM and CPU lies in how we use the resource. If the sim needs more CPU than the computer has, the CPU plows through the work - it just takes longer.

But what happens when you run out of RAM? The backup for RAM is your hard disk, which isn't even the same substance. A RAM chip might be able to come up with some data for the CPU in 4 nanoseconds; a hard drive might be able to seek to data in 4 ms. That would be a diference of 1,000,000! (By comparison, the difference between flying across the country and walking might only be 150x.)

In other words, when we run out of RAM, we can't degrade gracefully, we degrade catastrophically.

(It gets worse: when we run out of virtual memory, we don't have anything to fall back on - we're just dead!)

Interestingly, it used to be that way for VRAM (back in the days of X-Plane 6); if we had to substitute system RAM for VRAM, framerate died. These days, however, the graphics bus is so much faster that that substitution is almost tolerable - thus you can start to run out of VRAM and not have a slide-show.

We Can't Use All of Your RAM

A user emailed us to inquire why X-Plane wasn't using more of his RAM - he had a machine with 8 GB running a 64-bit OS. X-Plane could have had 3 GB memory but was only using a fraction of that.)

The answer is partly in the nature of RAM - because RAM fails catatrophicaly, users are likely to set X-Plane to never get near the edge of running out of memory. Our engine is designed to simply minimize memory usage (since the penalty for running out of virtual memory is fatal) rather than try to gain incremental benefit from incremental RAM. (There are scenery packs that you need a lot of RAM for, but usually you can either run them or you can't.)

For most users, RAM is like pushing on a string - if you have enough memory that you can run without paging, adding more won't help. If you have 4 GB you really don't need more memory. If you have 2 GB, you probably don't need memory unless you're running with almost everthing else maxed out, due to a really fast CPU and GPU.

1 comment:

Anton said...

Hi Ben,

This is an interesting topic. I'm sure more knowledgeable users try to find a balance in their hardware selections and rendering options, but it's usually difficult to actually determine where your bottleneck might be and how much of a problem they are.

I don't know if this would be feasible or not, but I think it would be useful to have a profiling tool within the program that could measure actual CPU, HDD and GPU throughput, so users could spot performance bottlenecks right away, and tune rendering options accordingly in order to get a balanced system.

Just an idea.

Anton