Chart RS-26 · FN-09 2026-11-26 · 3 min read
Chart lighting

Field note FN-09

Fitting useful data into 16 KB

How the data behind my Garmin apps is packed: compact records instead of JSON objects, choosing units, decoding in small steps, and the one place real compression paid off.

Project · Silva Dev Labs →

The budget is three budgets

“Fit it in 16 KB” sounds like one constraint. In practice it’s three, and they fail differently.

  • Bytes on the wire. Too big a response and the request fails. There is no official limit, so I design for the low end of what people report.
  • Memory while parsing. The response becomes Monkey C objects, and every object has overhead. This bites in watch faces’ background processes, which get very little memory.
  • Instructions per callback. Decoding is code that runs under the watchdog, like everything else.

Open Dial, the customisable watch face, hit all three in one week. A 4 KB design sent as JSON ran a watch’s background process out of memory. Packed into one string, twice that size went through. That’s because 340 small values become 340 objects, and one string is one object. Nearly everything below follows from that.

Records, not objects

The default format is a fixed-size binary record per item, base64’d into a single JSON string. An earthquake in Tremor is 22 bytes, with the place names in a separate string. Because every record has the same size, the watch can jump straight to any one of them. There’s no parsing step, no per-item object, and nothing to walk past to reach the hundredth quake.

Most of the size saving isn’t clever encoding. It’s choosing the coarsest unit that’s still invisible to the user. Positions are stored to about a metre, which is finer than GPS on a wrist. Terrain heights are rounded to steps that keep the error under one pixel in the panorama. When the data has a natural origin, like a ski resort’s corner, points can be stored as small offsets from it.

Decoding everything upfront would bring back the memory cost of objects. So most apps keep the bytes and decode on demand. True Sunset’s skyline stays packed, so it costs next to nothing in memory. The exception is data that gets searched: Refill decodes positions once, because finding the nearest water point reads every position on every GPS update. When the decode itself is big, it’s spread across timer ticks so no single callback comes close to the watchdog.

When compression pays: terrain

Only one dataset uses real compression, and it’s the one where the alternative was the server doing all the work.

Peak Horizon can work offline: the watch computes the panorama itself from downloaded terrain. The other design was to precompute panoramas on a grid and download those. The measurement that settled it: an area’s precomputed panoramas took 19.4 MB even compressed, and a coarser grid was wrong by several degrees. The same area’s terrain tiles were 185 KB. Sending the raw material and spending the watch’s CPU is about a hundred times smaller.

Each height is predicted from its neighbours, and only the small error is stored, which makes a tile about three times smaller. The watch decoder works through a tile in small steps across timer ticks, and can resume in the middle of one. It’s tested against the Python reference on a real Zermatt tile.

Degrade, don’t fail

Every format has a plan for too much data, and none of them is “send an error”:

  • Tremor keeps the newest quakes, but reserves slots for the strongest older ones, so a busy day of small quakes doesn’t push out the big one.
  • Wrist Map simplifies a tile harder, then drops whole classes of feature, buildings first. It’s covered in the maps note.
  • Skyward lets the watch decide how many aircraft it can afford. The Worker just clamps the number.

A watch can also run an old version of an app for months, so formats need to cope with both directions. Several start with a version byte, and Wrist Map refuses a tile whose version it doesn’t know rather than misreading it. In Open Dial, newer designs still draw on older faces because unknown parts are skipped. And since an out-of-range read can’t be caught on Connect IQ, Open Dial’s reader returns zeros past the end rather than crash the face at every start.

In numbers

Earthquake / water point 22 B / 14 B
Panorama (360 × 15) 10,800 B
Terrain tile, raw → compressed 7.2 KB → ≈ 2.3 KB
Offline terrain vs precomputed panoramas 185 KB vs 19.4 MB
Base64 overhead 4/3 (12 KB → 16 KB)

Request
clearance