Write Cache-friendly Code
2024-09-15 03:07:23
Computer Systems A Programmer's Perspective Second Edition
In Section 6.2, we introduced the idea of locality and talked in qualitative terms
about what constitutes good locality. Now that we understand how cache memo-
ries work, we can be more precise. Programs with better locality will tend to have
lower miss rates, and programs with lower miss rates will tend to run faster than
programs with higher miss rates. Thus, good programmers should always try to
write code that is
cache friendly
, in the sense that it has good locality. Here is the
basic approach we use to try to ensure that our code is cache friendly.
1.
Make the common case go fast.
Programs often spend most of their time in a
few core functions. These functions often spend most of their time in a few
loops. So focus on the inner loops of the core functions and ignore the rest.
2.
Minimize the number of cache misses in each inner loop.
All other things being
equal, such as the total number of loads and stores, loops with better miss rates
will run faster.
最新文章
- html传值 location.search取
- AS快捷键
- 给li设置float浮动属性之后,无法撑开外层ul的问题。(原址:http://www.cnblogs.com/cielzhao/p/5781462.html)
- SQL注入测试平台 SQLol -6.CHALLENGES挑战
- Windows下Cygwin中使用NCView
- P1011 传纸条//dp优化改进状态表示
- Linux Zynq GPIO中断
- [河南省ACM省赛-第三届] 聪明的kk (nyoj 171)
- 你跟上技术趋势了么? 来看看这10场2017热门it技术会议!
- hihoCoder1310 岛屿 (dfs)
- 【Luogu1876】开灯(数论)
- antd按需加载,配置babel-plugin-import插件,编译后报错.bezierEasingMixin()解决方案
- [原]openstack-kilo--issue(十六) instance can't get ip 虚拟机不能得到ip(1)
- PHP之数组函数
- React学习笔记一:入门知识概览
- code vs 3492 细胞个数
- iOS真机调试出现Development cannot be enabled while your device is locked.
- Arrays.sort和Collections.sort实现原理解析
- intel-FPGA的片内存储器问题
- SqlServer中创建Oracle链接服务器