liveBook · Manning

Data locality

As explained in Fast Python: High performance techniques for large datasets

Data locality describes the relationship between where data is located and where or how it is accessed or processed, including proximity, reuse, and location constraints.

Data locality concerns how data placement affects processing cost. Keeping needed information close to the CPU can reduce waiting for slower memory; storage and network access costs also vary widely. In virtual machines, cache conditions may be unpredictable, limiting the reliability of cache-aware optimizations. section 1.2.1 section 1.2.3 section 6.1.3

Compression and locality

Processing compressed data can be faster than processing raw data when the compressed block fits in CPU cache: decompression can use cycles otherwise spent waiting for RAM. A NumPy array representation choice can also affect cache locality and processing speed. section 1.2.1

Table 1.1 Memory hierarchy with sizes and access times for a hypothetical, but realistic modern desktop (view table figure)

Type

Size

Access time

CPU

L1 cache

256 KB

2 ns

L2 cache

1 MB

5 ns

L3 cache

6 MB

30 ns

RAM

DIMM

8 GB

100 ns

Secondary storage

SSD

256 GB

50 µs

HDD

2 TB

5 ms

Tertiary storage

NAS - Network Access Server

100 TB

Network dependent

Cloud proprietary

1 PB

Provider dependent

Compare the capacities and access times shown across CPU caches, RAM, disks, and network storage. section 1.2.1

How Fast Python: High performance techniques for large datasets covers it

How deep it goes
Explains memory-hierarchy costs, cache proximity, and virtualization caveats, but gives no optimization procedure.
Examples
Uses NumPy array representation, on-the-fly decompression, and access-time comparisons across memory and storage tiers.
What you can do after
Evaluate placement trade-offs by comparing access costs and keeping needed information close to the CPU, ideally in L1 cache.
How it connects
Connects cache locality with CPU caches, memory hierarchy, NumPy arrays, compression, storage, and cloud computing.

Also explained in

Compare how 4 books explain data locality →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast Python: High performance techniques for large datasets. The section links point to the parts of the book it draws on.