Cache memory is a small amount of very fast memory built into or next to the CPU that keeps copies of frequently used data and instructions. It reduces how often the processor must wait for main memory.
Why it matters
RAM is many times slower than the CPU, so caches bridge the gap. Processors use several levels: L1 is smallest and fastest per core, L2 is larger, and L3 is bigger still and usually shared between cores.
A program whose working data fits in cache can run dramatically faster than one that constantly reads from RAM.
Example
$ lscpu | grep cache
L1d cache: 32 KiB
L2 cache: 512 KiB
L3 cache: 16 MiB
A loop over a 20 KiB array fits in L1 and runs fast. The same loop over a 200 MiB array spills out of every level and is limited by RAM speed.
Common mistakes
- Treating cache size as the only measure of CPU quality.
- Confusing CPU cache with a browser or CDN cache, which is a different concept.
- Writing code that jumps randomly through memory and defeats the cache.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.