Layman's Guide to Computing

Articles tagged with cache

Issue 39: Caches and caching

Your computer and browser speed up a lot of lookups by caching information that is unlikely to change from the last view. When the same information is requested, your computer or browser will first look in the cache to find that information, and retrieve it from cache if it is there, otherwise it will load the information (and store it in cache if allowed to). There are usually ways to bypass a cache if the information is stale or no longer correct.

Published:

By J S Ng

Issue 57: Cache, the CPU’s working space

The CPU stores data for ready access in the CPU cache. Accessing data from the CPU cache is much faster than accessing data from memory. When the CPU needs data from a memory address, it looks in the cache first. If the data is not there (a cache miss), it will load the data from the memory address, and store a copy in the cache for faster reference in future. The CPU cache is managed by the CPU and is invisible to the OS. Programs that need to ensure the data in the cache is “fresh” can perform a cache flush and reload.

Published:

By J S Ng

Issue 58: CPU Optimisation Part 1 – Out-of-Order Processing

The CPU comprises different types of execution units. All the execution units can run at the same time, but they may execute instructions over different numbers of clock cycles. To minimise wait time, CPU instructions are carried out in an order that keeps the execution units busy as often as possible.

Published:

By J S Ng

Issue 59: Meltdown

A set of instructions can trick a CPU into reordering load instructions so that the data is temporarily loaded into the cache before the instructions are retired. The cache can then be snooped to retrieve the data.

Published:

By J S Ng

Issue 60: CPU Optimisation Part 2 – Speculative Execution and Spectre

Speculative execution is a feature that let’s the CPU speed up execution if it correctly predicts a decision point. The CPU carries out the operations along the predicted decision branch and loads the results if it predicts correctly.

Published:

By J S Ng

Issue 61: Mapping the cache

A cache miss is slow, and a cache hit is fast. This difference in cache reading speed can be used to transmit secrets out from the cache, which cannot be read directly by programs.

Published:

By J S Ng

Issue 62: Cache snooping

Published:

By J S Ng

Issue 63: Limitations of Meltdown and Spectre

For Meltdown and Spectre to work, they need two things: (1) Permission to carry out instructions (i.e. run programs) on the OS, and (2) knowledge of where the kernel address space is.

Published:

By J S Ng

Issue 65: Memory Sharing in the Operating System

Shared memory helps to reduce the amount of memory needed by all the applications running on an operating system. It also allows applications to send data to each other, and to communicate.

Published:

By J S Ng

Issue 73: The Heart of Darkness (Header Bidding)

When a page loads advertisements through header bidding, it sends your cookie along with other information to an ad exchange. The ad exchange conducts automated bidding among the ad-buyers, determines the winner(s), and sends the winning code(s) back to your browser. Your browser then sends these codes to the CDN, which sends back the winning ads for your page to render in your browser.

Published:

By J S Ng

Issue 78: uMatrix: voyuering the voyeurs

Modern webpages rely on many third-party resources for their functionality. Blocking access to some domains may cause these webpages to break and stop working.

Published:

By J S Ng

Issue 93: What's in a web app?

Web apps have limited access to the device’ storage, and can only store data in browser-managed databases. Progressive Web Apps (PWAs) can additionally register service workers that run in the background. Because they are so cleanly sandboxed, they can be easily removed by clearing the browser cache and storage, and deregistering any service workers manually.

Published:

By J S Ng

Issue 94: Why do web browsers take up so much memory?

Web apps require the browser to request memory on their behalf, and thus their memory usage shows up under the browser process in the OS Task Manager. Web apps use this data to store a more convenient (but larger) representation of the webpage document, and to store the data needed by the app.

Published:

By J S Ng

Issue 98: Temporary files

Apps generally handle three categories of files: its own (permanent) app files, (shared) user files, and (ephemeral) temporary files.

Published:

By J S Ng

Issue 109: Speeding up data operations

Fast writes dump the data to a write cache (in computer memory), then update the file table to look like the file is already written to disk. However, if power is cut before all data is properly moved from the write cache to disk, the data in memory is lost, and file corruption usually results.

Published:

By J S Ng

Issue 131: What do early CPUs and startup founders have in common?

CPUs have limited throughput, since there is a max frequency they can operate at, and a limit to the number of wires they can be connected to (throughput = no. of wires × frequency). Later designs of early computers increased the capability of computers by delegating more work to secondary chips.

Published:

By J S Ng

Issue 166: A cause of system slowdown: caches

Caches speed up app operations by storing temporary data on the device’s storage. This assumes that access to storage is much faster than access to the file’s original source. On Android, users can clear an app’s cache, but not the system cache.

Published:

By J S Ng

Issue 167: Database fragmentation

Fragmentation is likely a contributor of system slowdown, particularly for mobile devices: the databases used by most mobile apps tend to store data in many small chunks rather than fewer big chunks, which slows down data search operations. The most effective measure for improving device responsiveness is usually to clear the app cache, so the app does not attempt to read previous data from storage.