Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

256 KB in cache size is really 256 KiB?

So, I am confused regarding the whole KB /KiB concept. I read in a datasheet that a specific L2 cache has 256KB capacity. From other sources I have read the size to be 256 kB.

Sometimes when people write KB, or kB, they mean KiB, and sometimes not. My limited knowledge about memory leads me to believe that cache sizes should be a power of two bytes.

In the context of cache size, is it more likely that the size of the memory is 256 000 bytes or 2^10*256= 262 144 bytes?

Edit: Not the actual datasheet, but as an example have a look at the L1 cache on this AMD processor.

http://en.wikipedia.org/wiki/File:AMD_A64_Opteron_arch.svg

like image 730
belln Avatar asked Nov 26 '13 17:11

belln


People also ask

What is the actual cache size in KIB?

A kilobyte is 1024 bytes. 256 kilobytes is 262,144 bytes. The 262144 number is more likely, although (very unlikely) some non functional memory could be unused to increase yield.

How is cache line size calculated?

Each cache line/slot matches a memory block. That means each cache line contains 16 bytes. If the cache is 64Kbytes then 64Kbytes/16 = 4096 cache lines. To address these 4096 cache lines, we need 12 bits (212 = 4096).

What should my cache size be?

The higher the demand from these factors, the larger the cache needs to be to maintain good performance. Disk caches smaller than 10 MB do not generally perform well. Machines serving multiple users usually perform better with a cache of at least 60 to 70 MB.

What is the size of cache memory?

Its size is often restricted to between 8 KB and 64 KB. L2 and L3 caches are bigger than L1. They are extra caches built between the CPU and the RAM.


Video Answer


1 Answers

You've got:

  • RAM (always comes in powers of 2 sizes)
  • "256" (a power of 2)
  • capital K in "KB" (the standard is lowercase k = 1000, so capital K often implies the non-standard units)

All 3 of these things imply binary sizes, so yes, it's safe to assume they meant 256 kilobinary bytes = 256 KiB = 256×1024 B = 262,144 bytes.

Yes, writing it as "KB" is non-standard and confusing and wrong, but it's unfortunately common, so you need to use context to figure out what is actually meant.

like image 113
endolith Avatar answered Sep 24 '22 07:09

endolith