HOME

TheInfoList



OR:

Prefetching is a technique used in
computing Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
to improve performance by retrieving data or instructions before they are needed. By predicting what a program will request in the future, the system can load information in advance to reduced wait times . Prefetching is used in various areas of computing, including CPU architectures and
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s. It can be implemented in both hardware and
software Software consists of computer programs that instruct the Execution (computing), execution of a computer. Software also includes design documents and specifications. The history of software is closely tied to the development of digital comput ...
, and it relies on detecting access patterns that suggest what data is likely to be needed soon.


Overview

Prefetching works by predicting which
memory address In computing, a memory address is a reference to a specific memory location in memory used by both software and hardware. These addresses are fixed-length sequences of digits, typically displayed and handled as unsigned integers. This numeric ...
es or
resources ''Resource'' refers to all the materials available in our environment which are Technology, technologically accessible, Economics, economically feasible and Culture, culturally Sustainability, sustainable and help us to satisfy our needs and want ...
will be accessing and load them into faster access storage, like caches. Prefetching may be used: * Hardware-level, such as CPU memory controllers * Software-level, strategies in
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
s, operating systems, logic in
web browser A web browser, often shortened to browser, is an application for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr ...
s or file systems


Hardware

Processors (CPU's) often include prefetching that attempts to reduce cache misses by loading data into cache before it is requested by the running program. This is for programs that access memory in predictable patterns, such as loops that iterate over
arrays An array is a systematic arrangement of similar objects, usually in rows and columns. Things called an array include: {{TOC right Music * In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
. Hardware prefetching is can be done without software involvement and can be found in most modern CPU's. For example,
Intel Intel Corporation is an American multinational corporation and technology company headquartered in Santa Clara, California, and Delaware General Corporation Law, incorporated in Delaware. Intel designs, manufactures, and sells computer compo ...
CPU's feature a variety of prefetch that work across multiple cache levels. * Stride prefetching detects constant-stride memory access patterns (fixed distance between consecutive memory accesses) * Stream prefetching identifies long sequences of contiguous memory accesses (sequential access to a block of memory) * Correlation prefetching learns patterns between cache misses and triggers prefetches based on those patterns


Software

Prefetch instructions can be written into the code by the programmer or by the compiler. Prefetch instructions specify the memory addresses to be prefetched and the desired prefetch distance. In software, there are instructions that can be written with: *prefetch on
x86 architecture x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. T ...
*__builtin_prefetch in the GCC compiler *_mm_prefetch in th
Intel Intrinsics Guide


Operating systems

Operating systems use prefetching to reduce file and memory access latency. * Anticipatory Paging, attempts to prefetch memory pages based on pages in
RAM Ram, ram, or RAM most commonly refers to: * A male sheep * Random-access memory, computer memory * Ram Trucks, US, since 2009 ** List of vehicles named Dodge Ram, trucks and vans ** Ram Pickup, produced by Ram Trucks Ram, ram, or RAM may also ref ...
and not in RAM


Web Browsers

Web browsers apply prefetching techniques to improve perceived performance. Common examples include: * DNS prefetching: resolves
domain name In the Internet, a domain name is a string that identifies a realm of administrative autonomy, authority, or control. Domain names are often used to identify services provided through the Internet, such as websites, email services, and more. ...
s of links likely to be clicked *
Link prefetching Link prefetching allows web browsers to pre-load resources. This speeds up both the loading and rendering of web pages. Prefetching was first introduced in HTML5. Prefetching is accomplished through hints in web pages. These hints are used by the ...
: loads linked
web page A web page (or webpage) is a World Wide Web, Web document that is accessed in a web browser. A website typically consists of many web pages hyperlink, linked together under a common domain name. The term "web page" is therefore a metaphor of pap ...
s or assets before the user clicks them * Resource preloading: fetches critical resources (like
font In metal typesetting, a font is a particular size, weight and style of a ''typeface'', defined as the set of fonts that share an overall design. For instance, the typeface Bauer Bodoni (shown in the figure) includes fonts " Roman" (or "regul ...
s or scripts) in parallel with the current page load


Limitations

Prefetching can significantly improve performance, but it can not always be beneficial if implemented wrong. If predictions are inaccurate, prefetching may waste
bandwidth Bandwidth commonly refers to: * Bandwidth (signal processing) or ''analog bandwidth'', ''frequency bandwidth'', or ''radio bandwidth'', a measure of the width of a frequency range * Bandwidth (computing), the rate of data transfer, bit rate or thr ...
, processing time, or cause
cache pollution Cache pollution describes situations where an executing computer program loads data into CPU cache unnecessarily, thus causing other useful data to be evicted from the cache into lower levels of the memory hierarchy, degrading performance. For e ...
. In systems with limited resources or highly unpredictable workloads, prefetching can degrade performance rather than improve it. Implementing both software and hardware prefetching can also lead to degraded performance because of interactions that might occur between each other from how it was implemented.{{Cite journal , last1=Lee , first1=Jaekyu , last2=Kim , first2=Hyesoon , last3=Vuduc , first3=Richard , date=2012-03-01 , title=When Prefetching Works, When It Doesn't, and Why , url=https://dl.acm.org/doi/10.1145/2133382.2133384 , journal=ACM Trans. Archit. Code Optim. , volume=9 , issue=1 , pages=2:1–2:29 , doi=10.1145/2133382.2133384 , issn=1544-3566


See also

*
Cache (computing) In computing, a cache ( ) is a hardware or software component that stores data so that future requests for that data can be served faster; the data stored in a cache might be the result of an earlier computation or a copy of data stored elsew ...
*
Cache prefetching Cache prefetching is a technique used by computer processors to boost execution performance by fetching instructions or data from their original storage in slower memory to a faster local memory before it is actually needed (hence the term 'prefetc ...
*
Instruction prefetch Instruction or instructions may refer to: A specific direction or order given to someone to perform a task or carry out a procedure. They provide clear guidance on how to achieve a desired outcome. They can be written or verbal, and they typically ...
*
Speculative execution Speculative execution is an optimization (computer science), optimization technique where a computer system performs some task that may not be needed. Work is done before it is known whether it is actually needed, so as to prevent a delay that woul ...
*
Prefetch input queue Fetching the instruction opcodes from program memory well in advance is known as prefetching and it is served by using a prefetch input queue (PIQ). The pre-fetched instructions are stored in a queue. The fetching of opcodes well in advance, pr ...


References

Computer science