惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
H
Help Net Security
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
A
About on SuperTechFans
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
I
InfoQ
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
U
Unit 42
The Cloudflare Blog
Y
Y Combinator Blog

博客园 - 融化了的朱古力

AJAX Automated Testing Object design Professional asp.net 2.0 server control and component development Online dictionary ASP.NET 2.0服务器控件与组件开发高级编程 Professional asp.net 2.0 Server Control and Component Development .NET组件程序设计 .NET组件程序设计0723 .NET组件程序设计0721 .NET组件程序设计 never draw to an inside straight Per say Agile Principles, Patterns, and Practices in C# MapControl MapPoint Helpful Links 20060827 20060812 20060806 20060802
what is locality of reference?
融化了的朱古力 · 2006-08-12 · via 博客园 - 融化了的朱古力

In addition, in a majority of cases value type arrays exhibit much better locality of reference. 
                                                                                                                                -Framework Design Guidelines

locality of reference(http://www.answers.com/topic/locality-of-reference

Also known as "locality in space" and "spatial locality," it refers to the fact that most instructions in a program are in routines that are executed over and over, and that these routines are in a reasonably confined area. It also refers to data fields in close proximity to each other.

This is the principle behind memory and disk caches, in which data or instructions are placed in higher-speed memory and get read many times before the memory is overwritten by another set. See cache.

Wikipedia
In computer science, locality of reference, sometimes also called the principle of locality, is a concept which deals with the process of accessing a single resource multiple times. There are three basic types of locality of reference: temporal, spatial and sequential:

Temporal locality
The concept that a resource that is referenced at one point in time will be referenced again sometime in the near future.
Spatial locality
The concept that likelihood of referencing a resource is higher if a resource near it was just referenced.
Sequential locality
The concept that memory is accessed sequentially.

The reason these concepts are true is due to the manner in which computer programs are created. Generally, data that are related are stored in consecutive locations in memory. One common pattern in computing is that processing is performed on a single item and then the next. This means that if a lot of processing is done that the single item will be accessed more than once, thus leading to temporal locality of reference. Furthermore, moving to the next item implies that the next item will be read, hence spatial locality of reference, since memory locations are typically read in batches.

Increasing and exploiting locality of reference are common techniques for optimization. This can happen on several levels of the memory hierarchy. Paging obviously benefits from spatial locality. A cache is a simple example of exploiting temporal locality, because it is a specially designed faster but smaller memory area, generally used to keep recently referenced data and data near recently referenced data, which can lead to potential performance increases. Data in cache does not necessarily correspond to data that is spatially close in main memory; however, data elements are brought into cache one cache line at a time. This means that spatial locality is again important: if one element is referenced, a few neighbouring elements will also be brought into cache. Finally, temporal locality plays a role on the highest level, since results that are referenced very closely together can be kept in the registers. Programming languages such as C allow the programmer to suggest that certain variables are kept in register.