Computer Systems A Programmer's Perspective Second Edition

To this point in our study of systems, we have relied on a simple model of a

computer system as a CPU that executes instructions and a memory system that
holds instructions and data for the CPU. In our simple model, the memory system
is a linear array of bytes, and the CPU can access each memory location in a
constant amount of time. While this is an effective model as far as it goes, it does
not reflect the way that modern systems really work.
 
In practice, a memory system is a hierarchy of storage devices with different
capacities, costs, and access times. CPU registers hold the most frequently used
data. Small, fast cache memories nearby the CPU act as staging areas for a subset
of the data and instructions stored in the relatively slow main memory. The main
memory stages data stored on large, slow disks, which in turn often serve as
staging areas for data stored on the disks or tapes of other machines connected by
networks.
 
Memory hierarchies work because well-written programs tend to access the
storage at any particular level more frequently than they access the storage at the
next lower level. So the storage at the next level can be slower, and thus larger
and cheaper per bit. The overall effect is a large pool of memory that costs as
much as the cheap storage near the bottom of the hierarchy, but that serves data
to programs at the rate of the fast storage near the top of the hierarchy.
 
As a programmer, you need to understand the memory hierarchy because it
has a big impact on the performance of your applications. If the data your program
needs are stored in a CPU register, then they can be accessed in zero cycles during
the execution of the instruction. If stored in a cache, 1 to 30 cycles. If stored in main
memory, 50 to 200 cycles. And if stored in disk tens of millions of cycles!
 
Here, then, is a fundamental and enduring idea in computer systems: if you
understand how the system moves data up and down the memory hierarchy, then
you can write your application programs so that their data items are stored higher
in the hierarchy, where the CPU can access them more quickly.
 
This idea centers around a fundamental property of computer programs
known as locality. Programs with good locality tend to access the same set of
data items over and over again, or they tend to access sets of nearby data items.
Programs with good locality tend to access more data items from the upper levels
of the memory hierarchy than programs with poor locality, and thus run faster. For
example, the running times of different matrix multiplication kernels that perform
the same number of arithmetic operations, but have different degrees of locality,
can vary by a factor of 20!

zero cycles - 1 to 30 cycles - tens of millions of cycles的更多相关文章

  1. RFID 仿真/模拟/监控/拦截/检测/嗅探器

    Sound card based RFID sniffer/emulator (Too tired after recon.cx to do draw the schematics better th ...

  2. 美国风投行业50年数据揭示的10条VC投资秘密法则

    美国风投行业50年数据揭示的10条VC投资秘密法则 来源:金融女王(微信号:FintechQ) 作者:Hatim Tyabji & Vijay Sathe 本文编译自以下外媒文章:  http ...

  3. get back to the slower clock rate that allows it to save more power

    http://www.howtogeek.com/177790/why-you-cant-use-cpu-clock-speed-to-compare-computer-performance/ Wh ...

  4. monit介绍和配置

    1.介绍 monit监控和管理进程.程序.文件.目录和Unix系统的文件的工具.可以进行自动维护和修理,在错误的情况下执行有意义的因果关系的行动.比如,某个进程没有运行启动它:没有响应重启它:占用太多 ...

  5. Linux下monit进程管理操作梳理

    Monit对运维人员来说可谓神器,它是一款功能非常丰富的进程.文件.目录和设备的监测工具,用于Unix平台.它可以自动修复那些已经停止运作的程序,特使适合处理那些由于多种原因导致的软件错误.Monit ...

  6. elasticsearch 口水篇(6) Mapping 定义索引

    前面我们感觉ES就想是一个nosql数据库,支持Free Schema. 接触过Lucene.solr的同学这时可能会思考一个问题——怎么定义document中的field?store.index.a ...

  7. C++ Core Guidelines

    C++ Core Guidelines September 9, 2015 Editors: Bjarne Stroustrup Herb Sutter This document is a very ...

  8. 用monit监控系统关键进程

    原地址: https://feilong.me/2011/02/monitor-core-processes-with-monit monit是一款功能强大的系统状态.进程.文件.目录和设备的监控软件 ...

  9. Mongo Rocks 在SSD盘上表现优秀,专门为SSD盘的优化

    2017 · MongoDB深圳用户组大会全记录 | MongoDB中文社区http://www.mongoing.com/2017/04/24/mongodb-shenzhen-user-group ...

随机推荐

  1. Spark编译安装和运行

    一.环境说明 Mac OSX Java 1.7.0_71 Spark 二.编译安装 tar -zxvf spark-.tgz cd spark- ./sbt/sbt assembly ps:如果之前执 ...

  2. poj 1753

    翻转棋,注意是翻转周围四个的,不是整行列的  汗-_-! 哥的代码风还是不错的 二进制储存状态 Sample Input bwwb bbwb bwwb bwww Sample Output 4 #in ...

  3. JAVA 获取web文件的相对路径

    转自:http://wwwdd2315.blog.163.com/blog/static/66661889201091953350298/ 在JAVA文件中获取该项目的相对路径1.基本概念的理解 绝对 ...

  4. 解决:Google代码achartengine曲线代码报错问题(转)

    原文地址链接 官网:http://code.google.com/p/achartengine/ 下载代码部署项目会报下面的错误: java.lang.NoClassDefFoundError: or ...

  5. Cygwin: connection closed by ::1

    问题描述:在Win7下Cygwin中,使用ssh localhost命令, 出现Connectionclosedby::1的问题. 解决方案:1.我的电脑-管理-找到CYGWINsshd. 2.右键 ...

  6. C#实现UTC时间与Datetime转换

    为了便于传输,通信过程中传输的都是:当前时间跟标准时间相隔的秒数,并且是以16进制字节的形式传输的. public double ConvertDateTimeInt(System.DateTime ...

  7. 转-CSS3 圆角(border-radius)

    CSS3 圆角(border-radius)   前缀 例1 例2:无边框 书写顺序 其它 支持性 值:半径的长度 前缀 -moz(例如 -moz-border-radius)用于Firefox -w ...

  8. jquery.validate.js使用说明——后台添加用户邮箱功能:非空、不能重复、格式正确

    重点内容为:  jQuery验证控件jquery.validate.js使用说明+中文API[http://www.tuicool.com/articles/iABvI3] 简单教程可以参考[jQue ...

  9. 餐厅到店点餐系统app燃尽图

    队友: 郭志豪:http://www.cnblogs.com/gzh13692021053/ 杨子健:http://www.cnblogs.com/yzj666/ 刘森松:http://www.cnb ...

  10. 用java删除文件夹里的所有文件

    import java.io.File; public class Test { public static void main(String args[]){ Test t = new Test() ...