perf(virtual-browser): tune Selkies encoding defaults for UI workloads - #466
Draft
june-hua wants to merge 1 commit into
Draft
perf(virtual-browser): tune Selkies encoding defaults for UI workloads#466june-hua wants to merge 1 commit into
june-hua wants to merge 1 commit into
Conversation
Selkies' shipped defaults are tuned for full-motion cloud gaming: 60fps, with audio and microphone capture running. The virtual browser template renders a JupyterLab UI, which is static the majority of the time, so those defaults spend CPU and egress on frames that are visually identical to the previous one. That CPU competes with the user's analysis work on the same VM, and the egress is billable. Set encoding defaults appropriate for a text/UI workload: - SELKIES_FRAMERATE=20: down from the built-in 60fps default. Must be a single fixed value; a range is discarded in favour of the 60fps default. A fixed value also hides the framerate slider in the Selkies UI. - SELKIES_H264_CRF=28: fewer bits for moving content. Paint-over re-sends static content at high quality once motion stops, so settled text stays crisp. Kept above the paint-over CRF (18), which is the documented precondition for paint-over activating at all. - SELKIES_USE_PAINT_OVER_QUALITY=true: pin the paint-over pass on, since the higher motion CRF above depends on it. - SELKIES_AUDIO_ENABLED / SELKIES_MICROPHONE_ENABLED=false: neither is used by this workload. Set unlocked rather than removed so a deployment can re-enable either without a rebuild. Verified by running the image with these values and reading back the resolved settings Selkies logs at startup. Deliberately not changing SELKIES_ENCODER: the default full-frame x264enc path is already damage-gated, and the striped encoder is documented as only benefiting pre-AVX2 CPUs while forfeiting hardware encode. Left as a measure-first follow-up rather than a default.
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.
Sets five Selkies encoding defaults suited to a text/UI workload rather than the full-motion default.
Stacks on #463. One file, +25 lines.
First, a correction to the premise
I started from the assumption that a still page was being encoded as full-motion video and that
enabling damage-based encoding would be the big win. That assumption was wrong. This image runs
the Wayland damage-tracking path (
PIXELFLUX_WAYLAND=trueis baked in), which already spins theencoder down to zero when nothing changes. Per LinuxServer: "we only encode the frames that need to
be sent."
So idle cost was already low, and there is no damage-encoding switch to flip. The remaining savings
are in motion periods and in the audio pipeline, which is a constant cost paid even in
silence. The knobs that would tune damage behaviour directly (
paint_over_trigger_frames,damage_block_threshold,damage_block_duration) are hardcoded at 15/10/20 and exposed by no envvar.
What's set
SELKIES_FRAMERATE20SELKIES_H264_CRF28SELKIES_USE_PAINT_OVER_QUALITYtrueSELKIES_AUDIO_ENABLEDfalseSELKIES_MICROPHONE_ENABLEDfalseAudio and mic are set unlocked, so they can be re-enabled per deployment without a rebuild.
Verified by runtime readback in the built container:
framerate: (20,20),h264_crf: (28,28),audio_enabled: (False, …),encoder: 'x264enc', no errors.Three traps worth knowing
8-20still boots at 60fps. Only a fixed value takeseffect.
USE_PAINT_OVER_QUALITYdeactivates ifH264_CRF≤ 18 (documented precondition). 28 is safe,but lowering CRF later would silently disable paint-over.
sending an unchanged screen.
Considered and rejected
SELKIES_ENCODER=x264enc-striped— I had this as the headline change and backed it out. Full-frame isalso damage-gated so the win was largely already delivered; LSIO dropped striped from their default
deliberately ("it really only sees benefits on these older CPUs", pre-AVX2, and our VMs are modern);
and it forfeits hardware encode, since Selkies forces
use_cpu=Truefor striped. Worth an A/B, not adefault.
Encoder preset is not tunable and needs no tuning — pixelflux bundles its own libx264 already running
ultrafast+zerolatency.Decision needed before this leaves draft
SELKIES_FRAMERATE=20hides the framerate slider from users. In this Selkies version a fixedvalue is the only way to change the default, and setting one removes the control. If we'd rather users
keep it, drop the framerate change and treat it purely as an A/B.
Savings are unmeasured — deliberately no invented percentages. Measurement notes exist separately;
watch
docker statson the browser container, comparing a static page against sustained scrolling.Overlaps #463's compose file; hunk placed clear of
CHROME_CLIto reduce conflict with the concurrentpolicy PR (#464).