diff --git a/.devcontainer/arduino/devcontainer.json b/.devcontainer/arduino/devcontainer.json index 669b3e4..ebc68da 100644 --- a/.devcontainer/arduino/devcontainer.json +++ b/.devcontainer/arduino/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Arduino / PlatformIO", "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/cargo/devcontainer.json b/.devcontainer/cargo/devcontainer.json index d3a8cc6..0300d34 100644 --- a/.devcontainer/cargo/devcontainer.json +++ b/.devcontainer/cargo/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Rust", "image": "mcr.microsoft.com/devcontainers/rust:1-1-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/cocoapods/devcontainer.json b/.devcontainer/cocoapods/devcontainer.json index ff5ddde..9cabd20 100644 --- a/.devcontainer/cocoapods/devcontainer.json +++ b/.devcontainer/cocoapods/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — CocoaPods", "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/conan/devcontainer.json b/.devcontainer/conan/devcontainer.json index 40a52eb..978c056 100644 --- a/.devcontainer/conan/devcontainer.json +++ b/.devcontainer/conan/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — C / C++ (Conan)", "image": "mcr.microsoft.com/devcontainers/cpp:1-debian-12", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/go/devcontainer.json b/.devcontainer/go/devcontainer.json index 805fe12..77ed1d2 100644 --- a/.devcontainer/go/devcontainer.json +++ b/.devcontainer/go/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Go", "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/hex/devcontainer.json b/.devcontainer/hex/devcontainer.json index 89c5012..69ce504 100644 --- a/.devcontainer/hex/devcontainer.json +++ b/.devcontainer/hex/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Elixir / Erlang", "image": "hexpm/elixir:1.15.7-erlang-26.2.1-debian-bookworm-20231009-slim", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/maven/devcontainer.json b/.devcontainer/maven/devcontainer.json index e800f99..a317643 100644 --- a/.devcontainer/maven/devcontainer.json +++ b/.devcontainer/maven/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Java / Kotlin / Scala", "image": "mcr.microsoft.com/devcontainers/java:1-21-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/npm/devcontainer.json b/.devcontainer/npm/devcontainer.json index a70187f..1035846 100644 --- a/.devcontainer/npm/devcontainer.json +++ b/.devcontainer/npm/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — JavaScript / TypeScript", "image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm", + "hostRequirements": { + "cpus": 4 + }, "onCreateCommand": "node scripts/prepare-demo.mjs npm && npm --prefix demos/npm install --no-audit --no-fund && npm install -g @usedrift/cli", "waitFor": "onCreateCommand", "postAttachCommand": "drift analyze", diff --git a/.devcontainer/nuget/devcontainer.json b/.devcontainer/nuget/devcontainer.json index e2e02f6..bfb59e1 100644 --- a/.devcontainer/nuget/devcontainer.json +++ b/.devcontainer/nuget/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — .NET", "image": "mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/opam/devcontainer.json b/.devcontainer/opam/devcontainer.json index fb8ec40..a220e2c 100644 --- a/.devcontainer/opam/devcontainer.json +++ b/.devcontainer/opam/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — OCaml", "image": "ocaml/opam:debian-12-ocaml-4.14", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/packagist/devcontainer.json b/.devcontainer/packagist/devcontainer.json index e1287dc..7534964 100644 --- a/.devcontainer/packagist/devcontainer.json +++ b/.devcontainer/packagist/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — PHP", "image": "mcr.microsoft.com/devcontainers/php:1-8.2-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/pub/devcontainer.json b/.devcontainer/pub/devcontainer.json index 7aec71c..0c6639b 100644 --- a/.devcontainer/pub/devcontainer.json +++ b/.devcontainer/pub/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Dart / Flutter", "image": "dart:3.3", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/pypi/devcontainer.json b/.devcontainer/pypi/devcontainer.json index 74e6ee7..a16103f 100644 --- a/.devcontainer/pypi/devcontainer.json +++ b/.devcontainer/pypi/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Python", "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/rubygems/devcontainer.json b/.devcontainer/rubygems/devcontainer.json index 4a2ff2a..c762af8 100644 --- a/.devcontainer/rubygems/devcontainer.json +++ b/.devcontainer/rubygems/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Ruby", "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/swift/devcontainer.json b/.devcontainer/swift/devcontainer.json index 3609ea3..1fd972e 100644 --- a/.devcontainer/swift/devcontainer.json +++ b/.devcontainer/swift/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — Swift", "image": "swift:5.9-jammy", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/.devcontainer/vcpkg/devcontainer.json b/.devcontainer/vcpkg/devcontainer.json index 25c4311..1f60756 100644 --- a/.devcontainer/vcpkg/devcontainer.json +++ b/.devcontainer/vcpkg/devcontainer.json @@ -5,6 +5,9 @@ { "name": "Drift demo — C / C++ (vcpkg)", "image": "mcr.microsoft.com/devcontainers/cpp:1-debian-12", + "hostRequirements": { + "cpus": 4 + }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts" diff --git a/docs/browser-demo.md b/docs/browser-demo.md index 302737e..60f4d9a 100644 --- a/docs/browser-demo.md +++ b/docs/browser-demo.md @@ -103,6 +103,26 @@ npm install on the images that get Node from a feature rather than the base image (opam, pub, swift, hex) and whether `postAttachCommand` output lands where these notes claim it does. +## Startup time + +A demo is judged on how long it takes to show something, and a cold Codespace +spends that budget before Drift has run at all: building the container, +installing the extension, then `onCreateCommand` — which the editor waits for, +deliberately, so the dependency change is already in place when startup analysis +runs. + +Two levers exist, and only one of them is free: + +- **`hostRequirements: { cpus: 4 }`** — set on every demo. Codespaces then offers + the 4-core machine as the smallest that qualifies. It spends the visitor's own + allowance twice as fast (30 hours a month on the free tier rather than 60), + which is the right trade for something opened once for ten minutes. +- **Prebuilds** — not configured, and a deliberate omission rather than an + oversight. A prebuild per devcontainer means *sixteen* of them, each consuming + Actions minutes and storage billed to the `trydrift` organisation, which + currently configures no billing at all. Turning them on is a cost decision, not + a technical one: GitHub repository settings → Codespaces → Set up prebuild. + ## Cost Codespaces are created under the visitor's own GitHub account and count against diff --git a/scripts/lib/devcontainer-spec.mjs b/scripts/lib/devcontainer-spec.mjs index b31c93a..6c5597c 100644 --- a/scripts/lib/devcontainer-spec.mjs +++ b/scripts/lib/devcontainer-spec.mjs @@ -97,6 +97,16 @@ export function buildDevcontainer(demo, allDemos) { return { name: `Drift demo — ${demo.label}`, image: spec.image, + // A demo is judged on how long it takes to show something, and the default + // 2-core machine spends that budget building a container and installing an + // extension before Drift has run at all. Asking for 4 cores makes + // Codespaces offer the 4-core machine as the smallest that qualifies. + // + // It costs the visitor's own allowance twice as fast — 30 hours a month on + // the free tier rather than 60 — which is the right trade for something + // opened once for ten minutes, and would be the wrong one for a container + // somebody works in all day. + hostRequirements: { cpus: 4 }, ...(Object.keys(features).length > 0 ? { features } : {}), // Runs once at creation, after checkout and before the editor starts, so // the dependency change is already in place when Drift's startup analysis