CPU Cache Flushing Fallacy

简介:

Even from highly experienced technologists I often hear talk about how certain operations cause a CPU cache to “flush”.  This seems to be illustrating a very common fallacy about how CPU caches work, and how the cache sub-system interacts with the execution cores.  In this article I will attempt to explain the function CPU caches fulfil, and how the cores, which execute our programs of instructions, interact with them.  For a concrete example I will dive into one of the latest Intel x86 server CPUs.  Other CPUs use similar techniques to achieve the same ends.

Most modern systems that execute our programs are shared-memory multi-processor systems in design.  A shared-memory system has a single memory resource that is accessed by 2 or more independent CPU cores.  Latency to main memory is highly variable from 10s to 100s of nanoseconds.  Within 100ns it is possible for a 3.0GHz CPU to process up to 1200 instructions.  Each Sandy Bridge core is capable of retiring up to 4 instructions-per-cycle (IPC) in parallel.  CPUs employ cache sub-systems to hide this latency and allow them to exercise their huge capacity to process instructions.  Some of these caches are small, very fast, and local to each core; others are slower, larger, and shared across cores.  Together with registers and main-memory, these caches make up our non-persistent memory hierarchy.

Next time you are developing an important algorithm, try pondering that a cache-miss is a lost opportunity to have executed ~500 CPU instructions!  This is for a single-socket system, on a multi-socket system you can effectively double the lost opportunity as memory requests cross socket interconnects.


文章转自 并发编程网-ifeve.com

相关文章
|
11月前
|
存储 缓存 人工智能
图解操作系统-cpu cache
不同物理器件的访问速度不一:速度快的代价高、容量小;代价低且容量大,速度较慢。 为充分发挥各种器件优点,计算机存储数据的物理器件不会只选择一种,而是以CPU为核心,由内而外地组建一整套存储体系结构。它将各种不同的器件组合成一个体系,让各种器件扬长避短,从而形成一种快速、大容量、低成本的内存系统。 写高性能程序,须理解存储体系结构并运用好。
126 0
|
存储
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。(3)
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。(3)
167 0
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。(3)
|
存储 缓存
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。(2)
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。(2)
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。(2)
|
存储 缓存 算法
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。
185 0
面试官:谈谈 CPU Cache 工作原理,Cache 一致性?我懵了。。
|
存储 缓存 固态存储
天啦噜!知道硬盘很慢,但没想到比 CPU Cache 慢 10000000 倍
存储器的层次结构、层次关系、存储器之间的实际价格和性能差距
天啦噜!知道硬盘很慢,但没想到比 CPU Cache 慢 10000000 倍
|
存储 缓存 C++
7个示例科普CPU CACHE(zz)
原贴:https://coolshell.cn/articles/10249.html CPU cache一直是理解计算机体系架构的重要知识点,也是并发编程设计中的技术难点,而且相关参考资料如同过江之鲫,浩瀚繁星,阅之如临深渊,味同嚼蜡,三言两语难以入门。
1134 0
|
SQL 运维 Oracle
【故障处理】序列cache值过小导致CPU利用率过高
【故障处理】序列cache值过小导致CPU利用率过高 1  BLOG文档结构图       2  前言部分 2.
1188 0
cpu cache信息查看
近期的工作中需要对cpu的结构做更多的了解,项目中见到比较多cpu cache的信息,想对其做一个基本的了解。 第一步肯定是希望知道哪里能看到cpu cache的信息呢? 有多种办法,lscpu, cat /proc/cpuinfo等。
1094 0

热门文章

最新文章