\subsection{Caches}

Processors generally improve quicker than memory speed does. Therefore, optimizing memory is necessary, and caches are one such method.

\inlineex The importance of caches can quickly be seen when looking at the memory hierarchy:

\begin{tabular}{llllll}
    \toprule
    \textbf{Cache type}          &
    \textbf{What is cached?}     &
    \textbf{Where is it cached?} &
    \textbf{Latency (cycles)}    &
    \textbf{Managed by}            \\
    \midrule
    Registers                    &
    4/8-byte words               &
    CPU core                     &
    0                            &
    Compiler                       \\

    TLB                          &
    Address translations         &
    On-chip TLB                  &
    0                            &
    Hardware                       \\

    L1 cache                     &
    64-byte blocks               &
    On-chip L1                   &
    1                            &
    Hardware                       \\

    L2 cache                     &
    64-byte blocks               &
    On-chip L2                   &
    10                           &
    Hardware                       \\

    Virtual memory               &
    4\,kB page                   &
    Main memory (RAM)            &
    100                          &
    Hardware + OS                  \\

    Buffer cache                 &
    4\,kB sectors                &
    Main memory                  &
    100                          &
    OS                             \\

    Network buffer cache         &
    Parts of files               &
    Local disk, SSD              &
    1{,}000{,}000                &
    SMB/NFS client                 \\

    Browser cache                &
    Web pages                    &
    Local disk                   &
    10{,}000{,}000               &
    Web browser                    \\

    Web cache                    &
    Web pages                    &
    Remote server disks          &
    1{,}000{,}000{,}000          &
    Web proxy server               \\
    \bottomrule
\end{tabular}
