mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
feat(assets): base's build fetches only the package lists apt installs from
apt.sh begin's update fetched 35.8 MB of lists on arm64, of which the translations (Translation-en, 7.9 MB), AppStream's components (4.8 MB) and command-not-found's metadata are nothing apt installs from, and the image keeps no lists. The build's apt settings now leave them out (Acquire::Languages "none", and DefaultEnabled "false" for the DEP-11 and CNF index targets): 22.8 MB, and apt.sh begin 3.7 s against 6.4 s on the mini (measured). The record still gives back every InRelease and Packages list it used. A layer's apt.sh lists runs after apt.sh end has removed these settings, so its apt is Ubuntu's as it is. Base's and every layer's key change (apt.sh). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4 files changed
+7
-4
No files matched your search
+1
-1
@@ -222,7 +222,7 @@ These changes are on `main` and go out in the next release.
|
||||
|
||||
### Highlights
|
||||
|
||||
- A first run is about a quarter faster: shared tool images build side by side and the tools resolve while base builds, and it downloads less ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-faster-first-run)).
|
||||
- A first run is about a quarter faster: shared tool images build side by side and the tools resolve while base builds, and it downloads about 210 MB less ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-faster-first-run)).
|
||||
- A first run now survives a network that cuts or stalls connections: each download is tried again, and Ubuntu's cloud image and base's and layers' downloads go on from where they stopped ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-first-run-on-a-bad-network)).
|
||||
- devvm keeps Ubuntu's cloud image in its own folder, so Lima's cache no longer grows with each release, and `devvm space` and `devvm gc --caches` show and free it ([details](https://next.devvm.dev/docs/releases/0.2.0/#ubuntus-cloud-image-in-devvms-folder)).
|
||||
|
||||
|
||||
@@ -20,10 +20,13 @@ aside=/etc/apt/devvm-sources
|
||||
|
||||
# build_conf RETRIES: the build's apt settings, with RETRIES tries again of a failed download, each
|
||||
# after a longer wait (apt's own backoff). Package lists kept as they're signed, uncompressed, for
|
||||
# record to give back.
|
||||
# record to give back. Only the lists apt installs from: no translations, AppStream components or
|
||||
# command-not-found metadata, a third of what an update fetches, which the image keeps none of.
|
||||
build_conf() {
|
||||
printf 'Acquire::Retries "%s";\nAcquire::http::Timeout "30";\nAcquire::https::Timeout "30";\nAcquire::GzipIndexes "false";\n' \
|
||||
"$1" > /etc/apt/apt.conf.d/50devvm-build
|
||||
printf 'Acquire::Languages "none";\nAcquire::IndexTargets::deb::DEP-11::DefaultEnabled "false";\nAcquire::IndexTargets::deb::CNF::DefaultEnabled "false";\n' \
|
||||
>> /etc/apt/apt.conf.d/50devvm-build
|
||||
}
|
||||
|
||||
begin() {
|
||||
|
||||
@@ -125,7 +125,7 @@ base's recipe runs `apt.sh begin` as root before `base.sh`, and `apt.sh end` aft
|
||||
- **Every later build of the key replays them.** devvm sends the files the key recorded, from its cache, and `in/Packages`, their entries, each naming its file. `apt.sh begin` moves the image's sources aside and gives apt only that folder, so `base.sh` and the features install exactly what the first build did, with no network for them.
|
||||
- **A `--from` base gets neither.** Its packages come from the container image's own sources as they are when it builds, and they aren't pinned.
|
||||
|
||||
Both ends put the image's own sources back, remove devvm's apt settings, empty apt's cache and delete the package lists, so a first build and a replay make the same image. A VM made from it fetches lists when you run `sudo apt update`, and each layer's recipe starts with `apt.sh lists`, as root, which fetches them from the image's own sources when there are none, so a layer's script installs as it would on any Ubuntu. `apt.sh` makes a source that sends nothing for 30 seconds fail. While it fetches the package lists, it turns apt's retries off, and when no source answers, it exits 75, which the backend reports as `build_sources_unreachable`, not as a script that failed. Once a source has answered, apt tries a package's failed download again three times, each after a longer wait.
|
||||
Both ends put the image's own sources back, remove devvm's apt settings, empty apt's cache and delete the package lists, so a first build and a replay make the same image. A VM made from it fetches lists when you run `sudo apt update`, and each layer's recipe starts with `apt.sh lists`, as root, which fetches them from the image's own sources when there are none, so a layer's script installs as it would on any Ubuntu. `apt.sh` makes a source that sends nothing for 30 seconds fail. While it fetches the package lists, it turns apt's retries off, and when no source answers, it exits 75, which the backend reports as `build_sources_unreachable`, not as a script that failed. Once a source has answered, apt tries a package's failed download again three times, each after a longer wait. A build fetches only the lists apt installs from, with no translations, AppStream components or command-not-found metadata (`Acquire::Languages "none"`, and the `DEP-11` and `CNF` targets off), which is about a third less than an update fetches, and the image keeps none of them.
|
||||
|
||||
The backend sends the build's input into the VM as a tar stream before the first step, and after the last step it hands devvm a tar stream of `out/` and deletes the folder, which is the backend's packages role ([how a backend plugs in](../contributing/extending.md#how-a-backend-plugs-in)). On Lima, both run as root over `limactl shell`. What comes back is the build VM's, so devvm checks it before it keeps anything (`packages_refused`). It takes only regular files named `Packages`, `<64 hex digits>.deb`, `<n>.InRelease` or `<n>.Packages`, each package's content must hash to its name, and each entry must name a file that came back with the size and SHA-256 the entry gives, with no file left over. Each `InRelease` file is at most 4 MiB and all of them 32 MiB, and each package list is at most 512 MiB, with lines of at most 1 MiB and entries of at most 4 MiB, and all the lists 2 GiB. A name that comes back twice is refused.
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ Run `devvm update` in each existing VM's folder, and give the first one several
|
||||
|
||||
A first run with the defaults took about two and a half minutes on a fast link, and a third of that came after base was built. The shared tool images built one after another, and the tools' versions were resolved only once base was done. Now up to four tool images build side by side, each in a build VM of 2 GiB and 2 CPUs. devvm runs only as many as this machine has room for after keeping 6 GiB and 2 CPUs for itself and the memory of devvm's running VMs, and as many as the free disk allows. The tools' versions now resolve while base builds. On an M4 Mac mini the defaults' first run went from 156 to 118 seconds, and on an x86_64 Linux host from 159 to 125 ([building tools](../internals/images.md#building-tools)).
|
||||
|
||||
A first run also downloads less. devvm's own mise comes as its `.tar.gz`, in base and on this machine, a third of the binary's size.
|
||||
A first run also downloads about 210 MB less on arm64 and about 280 MB less on amd64. devvm's own mise comes as its `.tar.gz`, in base and on this machine, a third of the binary's size, and base's build fetches only the package lists apt installs from, with no translations, AppStream components or command-not-found metadata.
|
||||
|
||||
While tool images build side by side, one status line covers them, and each line of a build's commands in the run log starts with its tool's name, such as `[node]`. When one fails, devvm stops the others and shows the end of that tool's own lines. Each build VM has a name of its own on Lima, `devvm-tools-build` and then `devvm-tools-build-2` to `devvm-tools-build-4`, and a later build or `devvm gc` deletes any of them that a killed or failed run left, and gc names each one it deletes.
|
||||
|
||||
|
||||
Reference in new issue
Block a user