Delta Updates
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 provides ready-made support for dynamic and static delta updates. With dynamic delta updates, Rugix Ctrl determines on the device which parts of an update it needs to download and which parts it already has locally. In contrast, with static delta updates, Rugix Ctrl relies on a pre-computed delta between the old and the new version. To this end, Rugix Bundler provides a dedicated subcommand for computing deltas.
Dynamic delta updates are a quick win as they are very easy to implement. They only require an HTTP server supporting range queries, which almost all of them do. For instance, if you are hosting updates in an S3-compatible object store, you should already have everything you need in terms of infrastructure. While static delta updates can be twice as efficient, they are more complex to implement because they require a pre-computation of deltas between all relevant versions and targeted delivery. Unless your devices are on a metered or bandwidth-constrained connection, we recommend using dynamic delta updates. You can use the savings calculator below to estimate the cost savings and the update simulator to benchmark your update scenarios.
Dynamic Delta Updates
Rugix Ctrl supports dynamic delta updates via HTTP range queries. If you are installing an update via HTTP, the server supports range queries, and the bundle and system contain the necessary block indices, then Rugix Ctrl will adaptively download only parts of the update that it does not already have, e.g., within the currently booted system partition.1 While we will improve the workflow in the future, for the moment, dynamic delta updates 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
You can read more about block indices in the advanced section on Update Bundles.
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"
Static Delta Updates
Rugix's static delta updates require the pre-computation of explicit patches to go from the old version to the new version. This is done with Rugix Bundler's delta
subcommand, which takes the old and the new update bundle and computes a patch bundle:
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
slot only. If you want to compute patches for other slots, you can use the --slot
option, to provide a list of slots. Note that 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.
Rugix Bundler as well as the installation of static delta updates with Rugix Ctrl require xdelta3
to be installed on the system.
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.
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 build-in way to initialize the slot database prior to the first update.
Update Simulator
In case you are wondering what the impact of delta updates would be on your specific update scenarios, you can use the update simulator build into Rugix Bundler to estimate the efficiency of different delta update techniques. For details about the different techniques, we refer to our blog post on Efficient Delta Updates. The simulator is available through the subcommand:
rugix-bundler simulator
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. The calculator is based on averages over two years of real-world updates.
Method | Cost (USD/year) | Savings (USD/year) | Tools |
---|---|---|---|
No Delta Updates | 303 | 0 | |
Block-Based, Fixed 4KiB/32KiB | 77 | 226 | ≈RAUC |
Block-Based, Casync 16KiB | 69 | 235 | Rugix, Casync |
File-Based, Deltar 16KiB | 61 | 243 | (≈OSTree, ≈APT) |
Delta Compression (Xdelta) | 36 | 267 | Rugix, Mender, Xdelta |
Footnotes
-
Currently, this requires the system partition to be read-only. We will lift that restriction in the future. However, note that a read-only system partition is recommended in any case and made easy with Rugix Ctrl's state management functionality. For now, if a partition has been modified after creating the index used by an update, the update will simply fail without rebooting. ↩
-
In the future, Rugix Ctrl will create indices automatically based on the indices it finds in the bundle. ↩