Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Outline
layout pattern
title Data Locality
folder data-locality
permalink /patterns/data-locality/
categories Other
tags
Java
Difficulty-Intermediate
Performance

Intent

Accelerate memory access by arranging data to take advantage of CPU caching.

Modern CPUs have caches to speed up memory access. These can access memory adjacent to recently accessed memory much quicker. Take advantage of that to improve performance by increasing data locality keeping data in contiguous memory in the order that you process it.

Applicability

  • Like most optimizations, the first guideline for using the Data Locality pattern is when you have a performance problem.
  • With this pattern specifically, you’ll also want to be sure your performance problems are caused by cache misses.

Real world example

  • The Artemis game engine is one of the first and better-known frameworks that uses simple IDs for game entities.

Credits

Morty Proxy This is a proxified and sanitized view of the page, visit original site.