Repository navigation
perf: build x264 with patches that skip unchanged macroblocks - #116
Merged
Merged
Conversation
DarrenBaldwin07
added a commit
that referenced
this pull request
Nov 19, 2026
## What Bumps voxl from 0.3.5 to 0.4.0 in `Cargo.toml`, `Cargo.lock` and `default.nix`. Once this merges, pushing the `v0.4.0` tag on the merge commit publishes the crate to crates.io and creates the GitHub release, with generated notes and the crate attached (`release.yml`). Changes since the `v0.3.5` tag: - perf: build x264 with patches that skip unchanged macroblocks (#116) - feat(web): add a trackpad mode for touch screens (#115) - build: declare rust-version 1.86, the Rust the Linux CI job builds with (#107) The `v0.3.5` tag points at #99 (the optional `pulseaudio` feature), so that change is already in 0.3.5 and isn't repeated here. ## Testing - `cargo metadata --locked` passes, so `Cargo.lock` matches `Cargo.toml`. <br /> > Want tembo to make any changes? Add a comment with `@tembo` and i'll get back to work! <a href="https://app.tembo.io/sessions/75ad8969-8072-458a-973b-b4f3cec3bbac"><picture><source media="(prefers-color-scheme: dark)" srcset="https://internal.tembo.io/static/view/tembo-dark.png?v=3"><source media="(prefers-color-scheme: light)" srcset="https://internal.tembo.io/static/view/tembo-light.png?v=3"><img alt="View on Tembo" src="https://internal.tembo.io/static/view/tembo-light.png?v=3" width="134" height="28"></picture></a> <a href="https://app.tembo.io/reviews/redirect?sessionId=75ad8969-8072-458a-973b-b4f3cec3bbac"><picture><source media="(prefers-color-scheme: dark)" srcset="https://internal.tembo.io/public/tembo-button/review?theme=dark&v=3"><source media="(prefers-color-scheme: light)" srcset="https://internal.tembo.io/public/tembo-button/review?theme=light&v=3"><img alt="Review in Tembo" src="https://internal.tembo.io/public/tembo-button/review?theme=light&v=3" width="145" height="28"></picture></a> <a href="https://app.tembo.io/settings/models"><picture><source media="(prefers-color-scheme: dark)" srcset="https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-5-5:xhigh?theme=dark&v=12"><source media="(prefers-color-scheme: light)" srcset="https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-5-5:xhigh?theme=light&v=12"><img alt="View Agent Settings" src="https://internal.tembo.io/public/agent-button/claudeCode:claude-opus-5-5:xhigh?theme=light&v=12" height="28"></picture></a> <a href="https://tembo-io.slack.com/archives/C08S9PXF1KJ/p1795122498696389"><picture><source media="(prefers-color-scheme: dark)" srcset="https://internal.tembo.io/public/vendor-button/slack?theme=dark&v=2"><source media="(prefers-color-scheme: light)" srcset="https://internal.tembo.io/public/vendor-button/slack?theme=light&v=2"><img alt="View on slack" src="https://internal.tembo.io/public/vendor-button/slack?theme=light&v=2" height="28"></picture></a>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the x264 work Ryan Kuba (thelamer) linked in #66 (pixelflux 8483a53) to voxl, and adds two fixes it needed.
voxl already gives x264 a per-macroblock "unchanged" map from X damage (
mb_info). Stock x264 still copies the whole input frame, filters the whole lowres picture, and loads and analyses every macroblock, so on a 2560×1600 screen a frame where a small window moved costs nearly as much as a full-screen change. These patches make x264 skip that work for macroblocks marked unchanged. The output is the same bitstream; only the encode time changes.These are means of 4–10 alternating runs of the same voxl binary with stock or patched
libx264.soon a 16 vCPU AMD EPYC 9334 VM. Bitrate and FPS are the same with both. voxl's ownencode_costbench (a 640×360 change, hints on) drops from 6.3–6.9 to 3.2–3.6 ms wall and from 15–16 to 8–9 ms of CPU per frame. Stock x264 barely gains from the hints (6.6 vs 6.9 ms); with the patches they halve the cost.Changes
patches/x264/0001–0004: pixelflux's patches 2–5, unchanged apart from the numbering in their subjects. They apply cleanly to nixpkgs' x264 (373697b, the version voxl already builds with):mb_infofast skip wouldpatches/x264/0005: fix. Under VBV at an emergency QP (above 51), x264's fast skip compares against the QP after it's clamped to 51, so it never takes the skip there. The patch compared against the unclamped QP and coded P_SKIP where stock x264 codes P_L0, so the stream no longer matched stock. The voxl config hits this with its 1.25-frame VBV buffer. The patch now compares against the clamped QP.patches/x264/0006: fix, crash. The changed-macroblock copy widened luma runs to 32 bytes for x264's SIMDplane_copy. On CPUs with AVX-512 that resolves tox264_plane_copy_avx512, which stores 64-byte aligned and ends each row with a full 64-byte store. The result was a SIGSEGV on the first hinted frame where a change started on an odd macroblock pair, and it could also have zeroed input pixels after a run. Runs now widen to 4 macroblocks (64 bytes); pixelflux was tested on a Zen 3, which has no AVX-512. Pixelflux carries the same bug upstream.x264.nixapplies them to nixpkgs' x264, anddefault.nix(which the Computer preview builds) andshell.nix(dev and CI) use it.cargo installagainst a system x264, macOS (brew) and Windows (vcpkg) build and behave as before, just without the savings.Verification
psz_dump_yuv) frame for frame, with both libraries and 4 scenes, so the decoder doesn't drift.cargo test --releasepasses against the patched x264.nix-buildofdefault.nixlinks it. oxfmt and alejandra are clean.Full suite (
suite.sh+cpusuite.sh)Three interleaved reps of voxl's suite, plus two of
cpusuite.sh, with patched and stock x264 under the same voxl binary, on a 16 vCPU EPYC 9334 like the README's. The README's voxl column and CPU row now come from the patched runs (best of three, as before).CPU, voxl + Xvfb (mean of 2): patched 0.00 / 1.54 / 1.44 / 2.00 cores (idle / 1080p / scroll / full screen), stock 0.00 / 1.56 / 1.52 / 1.94.
On these workloads the two are within run-to-run noise. The suite changes large areas every frame (a 1600×950 browser window, a 1080p window, the whole screen), where the patches save little; the savings show on smaller changes (the table above). Scroll latency moves in whole-frame (~17 ms) steps between runs with either library, from Chromium's frame pipeline, so the 37 ms scroll best is a lucky run, not the patches. Both libraries measured more CPU in this session than the README's previous voxl row (1.39 / 1.33 / 1.68), so the README now says voxl's numbers come from a later session than the other servers'.
Follow-ups (not in this PR)
v0.3.5in the monorepo flake, so it picks this up after a release and a bump.apps/cli/build-linux-libs.shin the monorepo) builds x264 itself; it'd need to applypatches/x264too.