Friday, 18 May 2018

cache - Can we run linux in something faster than RAM?


This is perhaps a silly question, and may be the result of a misunderstanding. I'm studying CPU's right now, and memory in particular. I was just reading about how much faster SRAM is than DRAM but more expensive. SRAM is very expensive: I shopped for a bit and found a battery powered SRAM card with 16 MB for around $400.


Recently a friend mentioned he has been running puppy linux in RAM, and that it is fast. I noticed, though, that tiny core linux can be even smaller... as small as 8 MB! This got me thinking: can we run linux in SRAM? Is that question even well-formed?


Googling this question proved ineffective, but it raised yet more questions. Could one run linux in L3 Cache? Intel Core i7 can have an L3 Cache big enough to fit the 8MB... but am I making a categorical error? What is the difference between this and 'embedded' linux?


That's the question: can we run linux in SRAM or L3 Cache? Is there anything faster? How fast can we linux!?


z.



Answer



Linux, or any other OS does not know how the RAM works. As long as the memory controller is properly configured (e.g. refresh rates set for non-SRAM) then the OS does not care is it runs on plain dynamic memory (plain RAM), fast page mode RAM (FP RAM, from the C64-ish times), Extended data out mode RAM (EDO) , synchronious RAM (SDRAM), any of the double data rate SDRAMS (DDR 1/2/3) whatever.


All of those support reading and writing from random places. All will work.


Now cache is a bit different. You do not have to write to it for the contents to change. That will get in the way. Still, it is somewhat usable. I know that coreboot uses the cache as a sort of memory during boot, before the memory controller is properly configured. (For the details, check out the videos from the coreboot talks during FOSDEM 2011).


So in theory yes, you could use it.


BUT: For practical tasks a system with 1 GB 'regular' 'medium speed' memory will perform a lot better than with only a few MB super fast memory. Which means you have three choices:



  1. Build things the normal 'cheap' way. If you need more speed add a few dozen extra computers (all with 'slow' memory)

  2. Or build a single computer with a dozen times the price and significantly less then a dozen times the performance.


Except in very rare cases the last is not sensible.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...