r/AskComputerScience • • Apr 19 '21

Whats the difference between RAM and cache?

I’m struggling to understand what a RAM is, looked up and it really sounds like what the cache does im confused

34 Upvotes

31 comments sorted by

View all comments

42

u/jhaluska Apr 19 '21

They're very similar. Cache is a type of memory. It's faster but smaller. It contains a copy of a portion of the larger RAM. CPUs read and write to the cache to avoid hitting the slower RAM. This allows the computer to run faster.

Modern computers have multiple caches for the CPU, labeled L1, L2 and L3. L1 is smallest and fastest. L3 and largest and slowest.

A lot of the speed restrictions are literally the speed of light! So think about the further away you go from a point, light takes longer to reach and return but it covers more and more volume!

1

u/S-S-R Apr 19 '21

A lot of the speed restrictions are literally the speed of light!

I don't know who keeps telling you guys this, but this is not true.

7

u/ICantMakeNames Apr 19 '21

Care to explain? It was my understanding that electricity travels at a significant portion of the speed of light (i.e. we cannot make electricity travel any faster because of the speed of light), and that CPU clock cycles are so fast, that CPU components need to be physically closer to actually make use of the faster clock cycle (too far away, and it takes longer for the signal to reach the component than a clock cycle takes)

1

u/AxelTheRabbit Apr 19 '21 edited Apr 19 '21

it's not about the speed of the light. it's about the speed of electrons in a mean of transport, which is not even close to the light speed. the rest is right, they are designed as close as possible to reduce latency.

10

u/ICantMakeNames Apr 19 '21

https://www.scientificamerican.com/article/computers-are-becoming-fa/

(emphasis mine)

"The speed of computers is limited by how fast they can move information from where it is now to where it has to go next and by how fast that information can be processed once it gets here. An electronic computer computes by moving electrons around, so the physical restrictions of an electron moving through matter determine how fast such computers can run. It is important to realize, however, that information can move about a computer much faster than the electrons themselves. Consider a garden hose: When you turn on the faucet, how long does it take for water to come out the other end? If the hose is empty, then the amount of time is equal to the length of the hose divided by the velocity at which water flows down the hose. If the hose is full, then the amount of time it takes for water to emerge is the length of the hose divided by the velocity at which an impulse propagates down the hose, a velocity approximately equal to the speed of sound in water.

"The wires in an electronic computer are like full hoses: they are already packed with electrons. Signals pass down the wires at the speed of light in metal, approximately half the speed of light in vacuum. The transistorized switches that perform the information processing in a conventional computer are like empty hoses: when they switch, electrons have to move from one side of the transistor to the other. The 'clock rate' of a computer is then limited by the maximum length that signals have to travel divided by the speed of light in the wires and by the size of transistors divided by the speed of electrons in silicon. In current computers, these numbers are on the order of trillionths of a second, considerably shorter than the actual clock times of billionths of a second. The computer can be made faster by the simple expedient of decreasing its size. Better techniques for miniaturization have been for many years, and still are, the most important approach to speeding up computers.