r/computerscience • • Dec 30 '23

WTF does ram actually do?

I know that RAM stores data for quick use for the CPU. But I want to know more, what does RAM actually do when its storing data. Like when I'm playing a game is RAM responsible for keeping track of how many bullets I shoot. If there are any game developers reading this please let me know. What kind of information does RAM store and how and when does it use it. The main thing I use my pc for is gaming and recording/video editing so how would RAM play a role in those things?

263 Upvotes

97 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Dec 31 '23

If theoretically we are able to achieve hard disk data read/write speeds comparable to RAM, would that eliminate the need of RAM itself?

The only advantage RAM offers is high speeds for data read and write. If a hypothetical memory device has the same speeds wont we just create a partition and run with it?

2

u/TheCloudfather Oct 05 '24

Yes, that would generally be correct. There are RAM Drives that allocate a certain amount of RAM to be used as a very high speed storage drive, and there is Virtual Memory which allocates a certain amount of storage drive space to be used as additional RAM. The tradeoffs are pretty severe though, a RAM Drive is going to be very small in size (a couple of GB max) and virtual memory is going to be very slow.

There are more differences between a disk drive and RAM that are being glossed over though. RAM is connected directly to the CPU by a high speed bus, so the CPU can read and write directly to memory locations in the RAM. Disk drives are not directly connected to CPUs, they have a separate controller which is in between them and the cpu that coordinates communication and is a bottleneck as far as speed is concerned. So in a nutshell, if a theoretical high speed disk drive was available we wouldn't be able to use it like you are describing, a whole new computer architecture would need to be designed for it.

1

u/[deleted] Oct 05 '24

I understand we have to revamp the whole heirarchial structure we have with CPU registers > RAM > Hard drive. This hypothetical storage would greatly simplify the bus and general cpu architecture right? will there be any significant improvement out of this?

1

u/P-Jean Dec 31 '23

That’s a really good question. That’s a bit beyond my understanding, but I know that you can use your HDD as RAM in the form of virtual memory. I think it’s limited by the bus speed to the drive. I’ve wondered why SSDs aren’t used in this way. A partition, like you said, would make sense if the speed is comparable to stuff like RAM and cache.

Maybe someone here who deals more with hardware can chime in. I only know the basics of memory management from a software perspective, and even then, there’s always exceptions.

2

u/[deleted] Jan 01 '24

Yeah I was actually thinking of VRAM, only with entire RAM in memory.

Maybe the very frequent read/writes in SSD would potentially decrease the lfiespan and won't be that fast?

1

u/P-Jean Jan 01 '24

It would decrease the lifespan of a platter RAID drive for sure.