`
dogasshole
  • 浏览: 843230 次
文章分类
社区版块
存档分类
最新评论

Cache in action

 
阅读更多

cache这个东西在游戏开发中绝对是扮演超级巨星的角色。

在处理器(cpu,gpu)发展如此神速的今天,几乎ALU计算很难成为瓶颈,而数据访问则常常成为问题所在。

cache是一个硬件上的结构(virtual memory则是由操作系统来控制),是对processor访问memory的一种优化。

概率问题在软硬件设计中起了很大作用像cache这个依照space和时间上的重用高概率,像swizzle格式的texture遵守texture访问在块状(而不是线性的)上的高概率。

cache就是对物理内存最近常用的部分做备份,以cache line为单位(类似virtual memory以page为单位),cacheline是硬件决定的。

其中有n-way associative和write through/back等需要注意的地方。

所有这些性质决定了写程序时候会产生非常大的效率差别。

先来个powerpc的例子吧(见到什么说什么,也不局限于cache了)


InstructionUnit

  • L1 cache----32k, 2way associative, 128B cache line(cache line大小和page没关系的,一个是硬件的事情,一个是操作系统的事情)
  • 64 entry, 2way associative, TLB-----page table的cache
  • 4k*2 branch hitory table-----有根据历史记录预测branch的能力呃
  • out of order completion of load cache miss instructions----会导致processor级别的读乱序,必要时候注意多线程同步呃,参见前面lockless programming处理情况。sync系列函数搞定。
  • 12 stage issue queue for separate handling of VXU/FPU instructions----(应该是instruction pipeline)

FixedPoint and Load/store execution Unit

  • 32k, 4way, 128B cache line, write through
  • 64 entry, 2way, TLB
  • 8 load miss queue, 16 store queue,

Vector/Scaler Unit(VSU)

  • no L1 cache


提升cache性能的一些方法,只总结开发者可控部分吧,类似增加cache size,增加cache level这种是硬件开发者的事情,就飘过。

  • 数据的alignment----这个可以保证数据会占用尽可能少的cache line,cache performance也会变小
  • 压缩数据----bitfield替换bool,尽可能小的数据格式,编译时候选择最小size而不是最优化(优化instruction cache)都是不错的选择
  • 常访问的数据集中化
  • prefetch,在知道后面要用这个数据了,就先把数据读进来

最后要说的就是现在硬件过于复杂,在某个平台上开发经验有限的情况下,general的知识最好只做指导方向用,真正优化还是要跟着硬件手册和profile结果来,而不是主观推测。

假设经常出错呃。

分享到:
评论

相关推荐

    Manning.Spring.in.Action.4th.Edition.2014.11.epub

    Praise for the Third Edition of Spring in Action Preface Acknowledgments About this Book 1. Core Spring Chapter 1. Springing into action 1.1. Simplifying Java development 1.1.1. Unleashing the power ...

    Erlang and OTP in Action MEAP May 2010

    Erlang and OTP in Action Martin Logan, Eric Merritt, and Richard Carlsson MEAP Began: August 2008 Softbound print: May 2010 (est.) | 500 pages ISBN: 1933988789 Part One: Getting Past Pure Erlang; ...

    OSGI in Action

    Debugging in action 261 ■ Making things right with HotSwap 266 CONTENTS xi 8.2 Solving class-loading issues 271 ClassNotFoundException vs. NoClassDefFoundError 272 ■ Casting problems 274 ■ Using ...

    swarm 的帮助文档

    actionCache - Variable in class swarm.simtoolsgui.GUISwarmImpl ActionCache - interface swarm.simtoolsgui.ActionCache. A class to manage threads and Swarms.. ActionCacheC - interface swarm....

    Geoserver Beginner`s Guide

    Time for action – loading data in PostGIS and publishing them in GeoServer 116 Configuring raster data sources 120 ArcGrid 120 GeoTiff 120 Gtopo30 121 ImageMosaic 121 WorldImage 121 Configuring an ...

    BURNINTEST--硬件检测工具

    - Updated Level 2 and Level 3 CPU cache information for newer Intel CPU's. - Updated the detection of Hyperthreading and the number of logical CPUs for a new Intel CPU. Release 5.3 build 1025 WIN32...

    Bloodshed Dev-C++

    he added in the cache) at his fingertips. If, for example, the user adds "windows.h", he gets all the WinAPI! If he adds "wx/wx.h", he gets all of wxWindows! You get the picture... * Removed "Only ...

    HelloData数据库框架v1.1

    webcache缓存 。框架可以扩展。异常捕捉,调试更加方便 /// /// 自定义视图 /// public cms_user viewtestModel() { using (SelectAction action = new SelectAction("")) { action.SqlClomns = "_cms_...

    Oracle P/L SQL实现发送Email、浏览网页等网络操作功能

    Execute Immediate 'Create Sequence SYS_RAND_ID minvalue 1 maxValue 99999999999999999 Start With 1 increment by 1 cache 5 cycle order'; End; / --1、创建类型 Create Or Replace Type Strcat_type As ...

    Scala的Web框架Xitrum.zip

    xitrum 是一个 Scala ... In-process and distribued cache using Hazelcast, you don't need separate cache servers. Scalable Comet, you can scale Comet to multiple servers. 标签:Xitrum Web框架

    php.ini-development

    user_ini.cache_ttl = 300 ;;;;;;;;;;;;;;;;;;;; ; Language Options ; ;;;;;;;;;;;;;;;;;;;; ; Enable the PHP scripting language engine under Apache. ; http://php.net/engine engine = On ; This directive...

    google api php client

    [!... ... The Google API Client Library enables you to...use Cache\Adapter\Filesystem\FilesystemCachePool; $filesystemAdapter = new Local(__DIR__.'/'); $filesystem = new Filesystem($filesystemAdapter)...

    Service.Worker.Development.Cookbook.1786465299

    Get straight into the action with step-by-step recipes that show you how to put Service Workers to work Find out what Service Workers can do for your app, then do it! Get the first in-depth look at ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    When true then in ftmPanning mode the whole document image cache created in currect scale. - FIX: Support for the Import/Export modules that can't work with Streams. Added TFlexFileFormat....

    分析Cache 在 Ruby China 里面的应用情况

    流量高的那些页面 (Action) 访问量搞的几个 Action 的情况: TopicsController#show UsersController#show (比较惨,主要是 GitHub API 请求拖慢) PS: 在发布这篇文章之前我有稍加修改了一下,GitHub 请求放到...

    端口查看工具

    o Added new option: Ask before any action. (If you uncheck this option, CurrPorts won't ask you any question before closing ports/applications) * Version 1.55: o Added number of remote ...

    金蝶BOSV6.1_业务组件API参考手册

    com.kingdee.bos.util.backport.concurrent.locks Interfaces and classes providing a framework for locking and waiting for conditions that is distinct from built-in synchronization and monitors....

    understanding linux network internals

    Processing the NET_RX_SOFTIRQ: net_rx_action Chapter 11. Frame Transmission 帧传输 Section 11.1. Enabling and Disabling Transmissions Chapter 12. General and Reference Material About Interrupts ...

    甘豆影评 React Native 版本 yingping_rn.zip

     react-native run-iosor Open Yingping/ios/Yingping.xcodeproj in Xcode Hit the Run buttonTo run your app on Android:Have an Android emulator running (quickest way to get started), or a device ...

    上网监控工具

    - DNS Cache for fast hostname resolution - Log XNS activity to file / Log Manager - Feature-Centric customizable toolbar - ViewBar & System Tray Access - Remote Access thru X-NetStat Web Server - ...

Global site tag (gtag.js) - Google Analytics