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. Mac OS X 上的安装Lisp开发环境

    到网站:https://common-lisp.net/project/lispbox/ 下载lispbox 解压下载下来的包,找到Emacs 测试: 我们也可以使用homebrew来安装lisp的解 ...

  2. 如何将消息发送给Whatsapp联系人

    如何将消息发送给Whatsapp联系人 (由于本人喜欢word文档编辑,不喜欢网络编辑,所以仍然提供pdf版文档,方便查阅http://files.cnblogs.com/franksunny/sen ...

  3. ☆☆配置NDK环境

    1 前提是 已经配置好 安卓SDK开发环境. 2 下载 android-ndk64-r10-windows-x86_64,可以从官方网站下载,这里有一个现成的. http://pan.baidu.co ...

  4. .net winform软件自动更新

    转载自 http://dotnet.chinaitlab.com/DotNetFramework/914178.html 关于.NET windows软件实现自动更新,本人今天写了一个DEMO,供大家 ...

  5. android native开发时:java.lang.UnsatisfiedLinkError: Native method not found的处理

    这个异常一般是由于JNI的链接器不能正常识别C++的函数名造成的.处理的方法是用exern "C" {},来包裹需要export的C++的native方法. 如果native的方法 ...

  6. Android 编程下短信监听在小米手机中失效的解决办法

    相信很多人写的短信监听应用在小米手机上是拦截不到短信的,这是因为小米对短信的处置权优先分给了系统.我们可以在短信的[设置]→[高级设置]→[系统短信优先]中发现短信的优先处理权默认是分给系统的,只要关 ...

  7. html和text的区别

    1.html <div id="divShow"><b><i>Write Less Do More</i></b>< ...

  8. haohantechsoft-PDA软件,PDA管理软件,PDA管理系统,仓库PDA销售开单盘点软件

    为了更好服务于广大服装客户群体进行销售.盘点.调拨配送等.推出基于无线网络版移动PDA销售开单盘点软件系统.该系统支持无线3G.WIFI.GPRS系统,用户可以手持PDA在无线网络连接状态下进行销售. ...

  9. Codeforces Round #329 (Div. 2)

    推迟了15分钟开始,B卡住不会,最后弃疗,rating只涨一分...   水(暴力枚举) A - 2Char /******************************************** ...

  10. LMT 装机记录

    老毛桃是一个存在很久的文物了,当年在大学的时候,学习委员还专门做了一个PPT来讲老毛桃,现在想想,有点后悔那是不去试一下. 但万幸的是,最近终于彻底理解了工作流程: 1)安装一个LMT的软件,从其官网 ...