How does one pick an optimal block size for a cache with a specific size limit? For example, if I have a size limit of 900 bits for the whole cache, including tags and validity bits and everything, how do I choose the best block size to maximize utilized space? I assume it's different for directly-mapped caches vs. set-associative vs. fully-associative.

Brute forcing would be guessing and checking, but that seems inefficient. Is there a formula or something?

  • $\begingroup$ There is no simple answer, the best cache is the one that will give the highest performance to your CPU, and the trade offs may be different between an instruction, a data or a mixed I+D cache, and it depends on memory latency, and write-back vs write through, and the software you are running. Ideally, you have representative benchmarks and simulate the system with the different cache options, and more complex caches (multiple ways, write back...) can reduce CPU frequency, heat more... $\endgroup$ – TEMLIB Dec 1 '16 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.