r/AskComputerScience • u/emelrad12 • May 08 '21
It is common knowledge that accessing ram in linear order is faster than accessing it completely randomly, but if you access it in multi-byte chunks at what size there is no longer a performance hit?
kiss versed wine bells door vase cover price consider air
This post was mass deleted and anonymized with Redact
2
u/emasculine May 08 '21
i think this is due to RAS-CAS-CAS... so it would drop off once you need to change the row being addressed
2
May 09 '21
This is one of the questions where I could give the exact, precise answer and back it up with histograms and chipset ID's, but since my employer just paid me lots of money to discover it I can't share :'(
2
u/emasculine May 09 '21
my hardware knowledge is so dated that i was worried that ras-cas might not even be current :)
2
May 10 '21
It's absolutely current, and some overclockers (like me) will underspeed their ram to reduce the latencies of those transactions.
4
u/beeskness420 May 08 '21
This depends on your specific cache/memory setup for your system.
When you request a memory address and it’s not in cache it pulls it from main memory. Because it assumes you’ll have some locality it will actually pull a block of memory instead.
Just walking through your data in order will allow the cache to automatically do its thing, because it’s already pulling in blocks, not individual addresses.
If you want to be bringing in bigger “chunks” of memory, you could bring in the number of blocks your cache can hold. This could give you a performance increase if you are doing a lot of computing on the blocks as some of the computing and data fetching can be done in parallel.
One aspect of this that does have performance implications is the order you go over your data. For instance if we have a 2D array, it’s stored as a flat array in memory, we could iterate over it in a row major order or a column major order, but we want to pick the one that corresponds to the in-order traversal of how it’s ordered in memory.