Prefetching is an optimization technique that fetches data and loads it into memory before that data is actually requested. When successful, prefetching improves performance and reduces latency because an application does not need to read data from a slower storage disk but can instead access it from a faster memory cache. However, it requires that the system accurately predicts what data an application or process needs in advance. Prefetching can lead to wasted resources if the system makes incorrect predictions.
In order to predict what data it needs to prefetch, a computer system analyzes usage patterns to see how users and applications typically request data. They may use simple pattern matching algorithms or advanced machine learning to predict future behavior. Most operating systems use this information to speed up application launch times by preloading data these apps need; this feature is called SuperFetch in Windows and Application Launch Services in macOS. Mobile operating systems like Android and iOS also use prefetching to speed up app launch times.
Software applications and hardware devices can both include built-in prefetching functions. CPUs often use prefetching to load the next set of execution instructions into the cache. GPUs prefetch texture images into VRAM if the system anticipates they are needed to render upcoming frames. Database systems often prefetch data that a query may request before that query is executed. Web browsers can even prefetch data from other webpages that are linked to from the current page, downloading scripts, images, audio, and video to help the next page load faster when you click a link.