Skip to main content
Documentation

Delta Updates

Preview
You're viewing the Next docs — a rolling preview of in-development changes. The current release docs may differ.

Delta updates can reduce the amount of data transferred and the time required to install a new version by reusing locally available parts of the old version of a system. This is especially useful for devices on metered or bandwidth-constrained connections. Delta updates are particularly effective when there are frequent updates with small changes. According to our benchmarks, they can reduce the amount of data transferred by up to 90%.

Rugix is the only open-source OTA solution that ships with ready-made support for both dynamic and static delta updates.

Dynamic vs. Static

There are two ways to compute the delta between an old and a new version, and Rugix Ctrl supports both.

Dynamic delta updates let Rugix Ctrl decide on the device which parts of the new bundle it already has locally and which it still needs to download. Under the hood, this is HTTP range queries against the bundle, driven by the block index that every Rugix bundle carries. The server only needs to support range requests. Almost every HTTP server does, including S3-compatible object stores. Nothing has to be pre-computed.

Static delta updates rely on a pre-computed patch between two specific versions. rugix-bundler delta OLD NEW PATCH produces a patch bundle that the device installs in place of the full bundle. Static deltas can be roughly twice as efficient as dynamic ones for the same update, but the operational cost is real: you have to compute deltas for every relevant version pair and route the right patch to the right device.

Cost Savings Calculator

Based on our benchmarks, we developed a savings calculator to help you estimate the cost savings achievable through different delta update techniques for different update cadences.

Dynamic Delta Updates

When you install an update via HTTP, the server supports range queries, and the bundle and system contain the necessary block indices, Rugix Ctrl adaptively downloads only the parts of the update that it does not already have, e.g., within the currently booted system partition.1

Server Requirements

Any HTTP server that supports byte-range requests works. This includes virtually every standard HTTP server, all S3-compatible object stores, and most CDNs. No special infrastructure is required.

Slot Indices

While we will improve the workflow in the future, dynamic delta updates currently require the manual creation of system block indices, for instance with:2

rugix-ctrl slots create-index boot-a casync-64 sha512-256
rugix-ctrl slots create-index system-a casync-64 sha512-256

The update bundles built with Rugix Bakery use the parameters casync-64 and sha512-256 by default. If you want to use dynamic delta updates right now, just create the indices before installing the update bundle via HTTP. If the currently active system is A, then create an index for system-a and boot-a. If the currently active system is B, then create an index for system-b and boot-b. You can use rugix-ctrl system info to query whether the currently booted system is A or B.

Here is an example script for installing an update:

#!/usr/bin/env bash

set -euo pipefail

URL=$1

ACTIVE_SYSTEM=$(rugix-ctrl system info | jq -r ".boot.activeGroup")

if [ "$ACTIVE_SYSTEM" == "a" ]; then
    rugix-ctrl slots create-index boot-a casync-64 sha512-256
    rugix-ctrl slots create-index system-a casync-64 sha512-256
else
    rugix-ctrl slots create-index boot-b casync-64 sha512-256
    rugix-ctrl slots create-index system-b casync-64 sha512-256
fi

rugix-ctrl update install "$URL"

For background on what block indices are and how they work, see Update Bundles reference: Block Encoding.

Static Delta Updates

A static delta is a patch bundle, computed ahead of time from the old and new update bundles with Rugix Bundler’s delta subcommand:

rugix-bundler delta OLD NEW PATCH

If you are using Rugix Bakery, you can use ./run-bakery bundler delta instead.

By default, Rugix Bundler will compute a patch for the system and boot slots, respectively. As the boot partition is usually modified by Rugix, the delta for the boot slot is computed against the system slot of the old version. If you want to compute patches for other slots, use the --slot option to provide a list of slots. You can use the syntax new:old to compute a patch for the new slot of the new version against the old slot of the old version.

Slots must be immutable for static delta updates to work.

Rugix Bundler will include a hash of the old slot data in the patch bundle. This hash is used by Rugix Ctrl when installing the update to determine whether the required source for applying the patch is actually installed. In addition, it also includes a hash of the new slot data which is used to check the integrity of the new version after installing it.

Targeting

You can either track versions yourself (outside Rugix) to target updates for specific versions, or you can query Rugix’s slot database through rugix-ctrl system info to get information about what is installed to determine which update to use.

Limitations

Static delta updates currently only work after the first update has been installed, as this is when the slot database is populated. There is currently no built-in way to initialize the slot database prior to the first update.

Update Simulator

To estimate the impact of different delta update techniques on your specific update scenarios, use the simulator built into Rugix Bundler. For details about the different techniques, see our blog post on Efficient Delta Updates:

rugix-bundler simulator

Footnotes

  1. Block reuse is best-effort: a block is taken from a slot only if it still matches the index. If a slot has changed since its index was created, the changed blocks are downloaded from the server instead, so the update still succeeds, just with less bandwidth saved. A read-only system partition maximizes reuse and is recommended in any case; Rugix Ctrl’s state management makes one easy.

  2. In the future, Rugix Ctrl will create indices automatically based on the indices it finds in the bundle.