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. Visual Studio从此走入非Windows程序猿家

    (此文章同时发表在本人微信公众号"dotNET每日精华文章") 在Build 2015大会上,微软放了很多大招,其中一个让普通(不管是微软生态还是非微软生态的)程序猿都密切关注的就 ...

  2. java写入文件的几种方法分享

    转自:http://www.jb51.net/article/47062.htm 一,FileWritter写入文件 FileWritter, 字符流写入字符到文件.默认情况下,它会使用新的内容取代所 ...

  3. cocos2dx游戏开发——微信打飞机学习笔记(九)——BulletLayer的搭建

    一.创建文件~ BulletLayer.h BulletLayer.cpp 二.How to do? (1)实例化BulletLayer方法的实现~ Bullet(PlayerLayer* temp) ...

  4. AngularJS 'Controller As'用法

    AngularJS 1.2版本中提供了Controller As语法,简单说就是可以在Controller中使用this来替代$scope,使得Controller更像一个传统的JS类,相对于$sco ...

  5. isnull的使用方法

    is null 查看列数据为空 select*from lrb where lrid is null   ISNULL使用指定的替换值替换 NULL. 语法ISNULL ( check_express ...

  6. Web开发中运行环境的配置:(Tomcat7.0.59)和开发环境的配置

    第一部分:运行环境的配置 1.下载压缩包,解压即可 2.配置系统变量JAVA_HOME为jdk的安装路径 3.如有需要修改端口号,比如8080已被占用的时候,可以将其改为9080等 apache-to ...

  7. http://blog.sina.com.cn/s/blog_5f103c9c0101atny.html

    http://blog.sina.com.cn/s/blog_5f103c9c0101atny.html http://www.oschina.net/question/117304_51525

  8. stack UVA 442 Matrix Chain Multiplication

    题目传送门 题意:给出每个矩阵的行列,计算矩阵的表达式,如果错误输出error,否则输出答案 分析:表达式求值,stack 容器的应用:矩阵的表达式求值A 矩阵是a * b,B 矩阵是b * c,则A ...

  9. ZOJ 3603 DP LCS

    已经5年没有做OJ了, 曾经沧海难为水,除去巫山不是云" 准备每周刷1-2题! 题目大意:给出N个字符串,且各个字符串都包含唯一的字母,即不存在"ABCA"(A重复了), ...

  10. Open Xml SDK Word模板开发最佳实践(Best Practice)

    1.概述 由于前面的引文已经对Open Xml SDK做了一个简要的介绍. 这次来点实际的——Word模板操作. 从本质上来讲,本文的操作都是基于模板替换思想的,即,我们通过替换Word模板中指定元素 ...