In computer science, cache coloring (also known as page coloring) is the process of attempting to allocate free pages that are contiguous from the CPU cache's point of view, in order to maximize the total number of pages cached by the processor. Cache coloring is typically employed by low-level dynamic memory allocation code in the operating system, when mapping virtual memory to physical memory. A virtual memory subsystem that lacks cache coloring is less deterministic with regard to cache performance, as differences in page allocation from one program run to the next can lead to large differences in program performance.
Details of operations

A physically indexed CPU cache is designed such that addresses in adjacent physical memory blocks take different positions ("cache lines") in the cache, but this is not the case when it comes to virtual memory; when virtually adjacent but not physically adjacent memory blocks are allocated, they could potentially both take the same position in the cache. Coloring is a technique implemented in memory management software, which solves this problem by selecting pages that do not contend with neighbor pages.
Physical memory pages are "colored" so that pages with different "colors" have different positions in CPU cache memory. When allocating sequential pages in virtual memory for processes, the kernel collects pages with different "colors" and maps them to the virtual memory. In this way, sequential pages in virtual memory do not contend for the same cache line.
Implementations
This code adds a significant amount of complexity to the virtual memory allocation subsystem, but the result is well worth the effort.[1] Page coloring makes virtual memory as deterministic as physical memory with regard to cache performance. Page coloring is employed in operating systems such as Solaris,[2]FreeBSD,[1]NetBSD,[3] and Windows NT.[4]
References
- 12Matthew Dillon. "Page Coloring". Design elements of the FreeBSD VM system. FreeBSD Foundation. Archived from the original on 2007-02-02. Retrieved 2007-02-02.
{{cite web}}: CS1 maint: bot: estado de la URL original desconocido ( enlace ) - ↑ "Novedades del sistema operativo Solaris" . Material de marketing de Solaris . Sun Microsystems, Inc. Consultado el 13 de enero de 2007 .
- ↑ Matt Thomas . "Mejorando NetBSD/mips" (PDF) . Gestión de colores de página . The NetBSD Foundation . Consultado el 24 de septiembre de 2012 .
- ↑ Edouard Bugnion; Jennifer M. Anderson; Todd C. Mowry*; Mendel Rosenblum; Monica S. Lam. "Coloración de páginas dirigida por el compilador para multiprocesadores" . Universidad de Stanford . Consultado el 6 de octubre de 2009 .
Enlaces externos
- " Algoritmos de ubicación de páginas para grandes cachés con índices reales ", por RE Kessler y Mark D. Hill, Universidad de Wisconsin, 1992.
- " Colorable Memory ", de Jochen Liedtke , IBM TJ Watson Center, noviembre de 1996.
- "缓存着色技术", de Maray, Blog tecnológico de CSDN, 2008.
- Caché (informática)