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.
 
 

Write Cache-friendly Code的更多相关文章

  1. c/c++性能优化--- cache优化的一点杂谈

    之前写了一篇关于c/c++优化的一点建议,被各种拍砖和吐槽,有赞成的有反对的,还有中立的,网友对那篇博客的的评论和吐槽,我一个都没有删掉,包括一些具有攻击性的言论.笔者有幸阅读过IBM某个项目的框架代 ...

  2. Page.Cache

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.page.cache?view=netframework-4.8 Gets the ...

  3. jodd cache实现缓存超时

    public class JoddCache { private static final int CACHE_SIZE = 2; private final static Cache<Obje ...

  4. Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core

    本文内容为转载,重新排版以供学习研究.如有侵权,请联系作者删除. 转载请注明本文出处:Professional C# 6 and .NET Core 1.0 - 40 ASP.NET Core --- ...

  5. [译]Vulkan教程(24)索引buffer

    [译]Vulkan教程(24)索引buffer Index buffer 索引buffer Introduction 入门 The 3D meshes you'll be rendering in a ...

  6. SDWebImage源码解读之SDWebImageDownloaderOperation

    第七篇 前言 本篇文章主要讲解下载操作的相关知识,SDWebImageDownloaderOperation的主要任务是把一张图片从服务器下载到内存中.下载数据并不难,如何对下载这一系列的任务进行设计 ...

  7. Spring缓存机制的理解

    在spring缓存机制中,包括了两个方面的缓存操作:1.缓存某个方法返回的结果:2.在某个方法执行前或后清空缓存. 下面写两个类来模拟Spring的缓存机制: package com.sin90lzc ...

  8. 前端学PHP之错误处理

    × 目录 [1]错误报告 [2]错误级别 [3]错误处理[4]自定义错误[5]错误日志[6]异常处理[7]自定义异常 前面的话 错误处理对于程序开发至关重要,不能提前预测到可能发生的错误,不能提前采取 ...

  9. Cache-Aside Pattern(缓存模式)

    Load data on demand into a cache from a data store. This pattern can improve performance and also he ...

随机推荐

  1. 监控Spark应用方法简介

    监控Spark应用有很多种方法. Web接口每一个SparkContext启动一个web UI用来展示应用相关的一些非常有用的信息,默认在4040端口.这些信息包括: 任务和调度状态的列表RDD大小和 ...

  2. 解决:jquery-1.11.1.min.js红叉问题

    工程中导入jquery-1.11.1.min.js,工程正常运行.但是jquery-1.11.1.min.js一直显示红叉. 解决方法如下: 红叉的原因是:myeclipse没有去验证它! 选中js文 ...

  3. 史上最全JS表单验证封装类

    转自:http://www.cnblogs.com/linjiqin/p/3429919.html /************************************************* ...

  4. android 获取路径目录方法以及判断目录是否存在,创建目录

    Environment 常用方法: * 方法:getDataDirectory()解释:返回 File ,获取 Android 数据目录.* 方法:getDownloadCacheDirectory( ...

  5. PHP 表单提交多行数据,显示多个submit

    echo "<table border=1 class="imagetable" >"; //使用表格格式化数据echo "<for ...

  6. js:语言精髓笔记8--对象系统

    封装: 一把对象系统,封装是由语法解析来实现的,即语法作用域:但js是动态语言,因此只能依赖变量作用域: js的变量作用域只有表达式,函数,全局三种:所以js只能实现public和private两种封 ...

  7. QUnit使用笔记-2同步与异步处理方式

    同步: 有时候如果我们想判断方法执行的次数,可以通过间接设置expect(n);//可以将expect的参数放到test的第二参数来简化: QUnit.test("expect test&q ...

  8. linux gdb 没有符号表被读取。请使用 "file" 命令。

    使用gdb时遇到这个问题,刚开始接触linux下使用gdb调试程序,其原因是生成的二进制可执行文件没有使用-g选项. gcc中-g选项是为了获得有关调试信息,要用gdb进行调试,必须使用-g生成二进制 ...

  9. POJ 1651 (区间DP)

    题目链接: http://poj.org/problem?id=1651 题目大意:加分取牌.如果一张牌左右有牌则可以取出,分数为左牌*中牌*右牌.这样最后肯定还剩2张牌.求一个取牌顺序,使得加分最少 ...

  10. 洛谷 P1019 单词接龙 Label:dfs

    题目描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次),在两个单词相连时,其重合 ...