Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,20 @@ jobs:
# The same checklist a developer runs: fmt, clippy -D warnings, rustdoc -D warnings, tests,
# documentation links, no video or personal path tracked, then the release executable (with its
# commit and third-party notices inside) and its checksum. One script, so CI and a developer's
# machine cannot drift apart.
# machine cannot drift apart. A pull request builds it with the release-fast profile (thin LTO on
# every core, minutes faster); main, after each merge, with the published fat LTO profile, so the
# profile a tag uses is built on every change before any release.
- name: Test and build the release executable
shell: pwsh
run: .\scripts\build.ps1 release
run: .\scripts\build.ps1 release ${{ github.event_name == 'pull_request' && '-Fast' || '' }}

# Pull requests can read main's cache but never write their own when the key matches exactly (same
# Cargo.lock), and release-fast compiles its dependencies with other settings than release. So main
# compiles them too, into the cache it saves: pull requests then only rebuild the application.
- name: Warm the cache for pull requests (release-fast dependencies)
if: github.event_name != 'pull_request'
shell: pwsh
run: cargo build --profile release-fast --locked

- name: Read the version
id: version
Expand Down
9 changes: 8 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ tests/pipeline.rs end to end on synthetic clips examples/transcode.rs

```powershell
.\scripts\build.ps1 # fmt, clippy -D warnings, rustdoc -D warnings, tests, doc links, no video / personal path
.\scripts\build.ps1 build # + release build
.\scripts\build.ps1 build # + optimized build, release-fast profile (thin LTO, ~20 s)
.\scripts\build.ps1 release # + clean tree, notices, the .exe, SHA256SUMS.txt and notes.md in dist\ (needs cargo-about)
```

- **Two optimized profiles.** `release` (fat LTO, one codegen unit: the smallest, best-optimized exe,
but one thread, ~1 min 45 s) is what users get: tags, main's CI. `release-fast` (thin LTO, 16 units,
~20 s, exe ~12 % larger) is for checks: `build.ps1 build` and pull request CI (`release -Fast`). Never
publish a `-Fast` build. Measured 2026-11-23 on a Ryzen 9 9950X3D: fat LTO cannot use more threads.
CI caches are scoped: a pull request reads main's cache and never saves its own on an exact key match,
so main's CI also builds `release-fast`, only to put its dependencies in the cache.

- **One file.** A release is `quick-video-transcoder.exe` alone: static C runtime, icon, third-party
notices (`--licenses`, *About*) inside. FFmpeg stays outside, found on the `PATH` or installed with
winget on the user's request. Keep it that way: nothing a user must unpack or install beside it.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FFmpeg on the `PATH` for the end-to-end test. Before committing, run the same ch

```powershell
.\scripts\build.ps1 # fmt, clippy, rustdoc, tests, doc links, no video or personal path tracked
.\scripts\build.ps1 build # the same, then a release build
.\scripts\build.ps1 build # the same, then an optimized build (release-fast profile: thin LTO, about 20 s)
.\scripts\build.ps1 release # from a clean tree: the same, then the release .exe and its checksum in dist\
```

Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ codegen-units = 1
strip = "symbols"
# Panics keep unwinding: a worker thread that fails must not take the window down.

# For checks, not for users: local builds and pull request CI. Fat LTO runs on one thread (1 min 43 s on
# a 16-core CPU after each commit); thin LTO spreads over the cores (22 s), for an executable about 12 %
# larger. Published releases always use `release` (scripts/build.ps1 release without -Fast).
[profile.release-fast]
inherits = "release"
lto = "thin"
codegen-units = 16

[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"
Expand Down
12 changes: 12 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ statically (`.cargo/config.toml`). The script then asks the built executable for
notices, and writes the executable, `SHA256SUMS.txt` and `notes.md` (the changelog section) to `dist\`.
`release.yml` runs it on a `v*` tag, requires `notes.md`, attests `SHA256SUMS.txt` and publishes.

Build time (Ryzen 9 9950X3D, 16 cores, rustc 1.98, 2026-11-23, after a commit, dependencies cached):

| Profile | Final step | Exe |
| --- | --- | --- |
| `release`: fat LTO, 1 codegen unit (published) | 1 min 43 s | 18.7 MB |
| fat LTO, 16 codegen units | 2 min 09 s | 19.5 MB |
| `release-fast`: thin LTO, 16 codegen units (checks) | 22 s | 21.0 MB |

Fat LTO merges the whole program and its dependencies into one LLVM module optimized on one thread; more
codegen units only make the merge slower, and a faster linker (`rust-lld`) saves under a second. So the
published profile stays fat, and checks (`build.ps1 build`, pull request CI) use `release-fast`.

When FFmpeg is missing and winget runs, the *FFmpeg is needed* window offers to run
`winget install --id Gyan.FFmpeg --exact --silent` with the package and source agreements accepted (the
window says so), then checks again with the `PATH` re-read.
32 changes: 22 additions & 10 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
# drift apart.
#
# .\scripts\build.ps1 # test (the default)
# .\scripts\build.ps1 build # test, then the release build
# .\scripts\build.ps1 release # test, notices, release build, the .exe and its checksum in dist\ (from a clean tree outside CI)
# .\scripts\build.ps1 build # test, then an optimized build with the release-fast profile (thin LTO)
# .\scripts\build.ps1 release # test, notices, the published build (fat LTO), the .exe and its checksum in dist\
# .\scripts\build.ps1 release -Fast # the same with release-fast: pull request CI
#
# A release is built from a clean tree outside CI, always without -Fast.
#
# Never pipe it into Select-Object -First: that stops the pipeline mid-run, and a truncated run can look
# like a success. Read the whole output, or the last line.

param(
[ValidateSet('test', 'build', 'release')]
[string] $Task = 'test'
[string] $Task = 'test',
# release only: build with the release-fast profile (thin LTO, every core) instead of the published
# one. For pull request CI, which checks the packaging without the minutes of a fat LTO.
[switch] $Fast
)

$ErrorActionPreference = 'Stop'
Expand Down Expand Up @@ -157,7 +163,7 @@ function Invoke-Tests {

# A release build embeds the third-party notices: generated here by cargo-about into target\, handed to
# build.rs through QVT_NOTICES. A plain build embeds a placeholder.
function Invoke-Build([switch] $WithNotices) {
function Invoke-Build([string] $CargoProfile, [switch] $WithNotices) {
if ($WithNotices) {
Step "Third-party notices"
if (-not (Get-Command cargo-about -ErrorAction SilentlyContinue)) {
Expand All @@ -169,8 +175,8 @@ function Invoke-Build([switch] $WithNotices) {
Write-Host " $([math]::Round((Get-Item $notices).Length / 1KB)) KB"
$env:QVT_NOTICES = $notices
}
Step "Release build"
try { Run 'cargo' @('build', '--release', '--locked') } finally { Remove-Item Env:\QVT_NOTICES -ErrorAction SilentlyContinue }
Step "Optimized build ($CargoProfile profile)"
try { Run 'cargo' @('build', '--profile', $CargoProfile, '--locked') } finally { Remove-Item Env:\QVT_NOTICES -ErrorAction SilentlyContinue }
}

# Starts the built executable with one argument and returns what it printed. A windowed program:
Expand Down Expand Up @@ -202,10 +208,10 @@ function Assert-CleanTree {
# documentation inside (About, --licenses, --version). Its name carries no version, so replacing the file
# updates it and the Send to shortcut keeps working. Next to it in dist\: SHA256SUMS.txt, and notes.md
# (the changelog section) when the version has a dated one.
function Invoke-Package {
function Invoke-Package([string] $CargoProfile) {
$version = Get-Version
$dist = Join-Path $root 'dist'
$exe = Join-Path $root 'target\release\quick-video-transcoder.exe'
$exe = Join-Path $root "target\$CargoProfile\quick-video-transcoder.exe"

# Asked of the executable rather than of git: it is what users run.
Step "The executable names its commit and carries its notices"
Expand Down Expand Up @@ -243,7 +249,13 @@ function Invoke-Package {

if ($Task -eq 'release') { Assert-CleanTree }
Invoke-Tests
if ($Task -eq 'build') { Invoke-Build }
if ($Task -eq 'release') { Invoke-Build -WithNotices; Invoke-Package }
if ($Fast -and $Task -ne 'release') { Fail "-Fast only applies to the release task" }
if ($Task -eq 'build') { Invoke-Build 'release-fast' }
if ($Task -eq 'release') {
$cargoProfile = if ($Fast) { 'release-fast' } else { 'release' }
Invoke-Build $cargoProfile -WithNotices
Invoke-Package $cargoProfile
if ($Fast) { Write-Host " built with release-fast: a check, not an executable to publish" -ForegroundColor Yellow }
}
Write-Host ""
Write-Host "$Task OK" -ForegroundColor Green