Repository navigation
perf: compress built-in engine PNG frames with zlib level 1 - #43
Merged
Merged
Conversation
|
AI review | Looks safe to merge Changes PNG compression in the Rust engine from fast Huffman-only to zlib level 1 to reduce frame size with minimal CPU overhead. Adds a regression test for compression ratio and updates the WASM source hash. No security or stability risks found. Partial review: 1 file(s) could not be read, a maintainer should look at them. Reviewed 6672384. AI can be wrong, a maintainer still decides. Comment |
ZacharyZcR
force-pushed
the
perf/png-zlib-level
branch
from
November 15, 2026 19:28
1de571c to
fdfe9cc
Compare
PNG frames used png's Fast compression, which runs fdeflate without LZ matching. Text and UI therefore barely shrank: a 1080p desktop of text came out at 2.3 MB, 3.1 MB once base64 encoded, for every full repaint the client then had to download and decode. zlib level 1 takes about the same time in the WASM engine (22.2 ms to 22.9 ms for that frame) and sends 579 KB, about a quarter. A 960x720 window drops from 805 KB to 201 KB. Rebuilt the bundled engine.
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.
A user reported RDP feeling sticky (about 200 ms) through a Termix server on the same LAN, and only slightly better with guacd.
One measurable cost is frame size. PNG frames used
png::Compression::Fast, which runs fdeflate without LZ matching, so text and UI barely shrink. Measured with the bundled WASM engine in Node, using a 1080p desktop-like frame of repeated glyphs on a flat background:zlib level 1 costs roughly the same time in WASM and sends about a quarter of the bytes, which the client then also decodes. Higher levels shrink more but cost about 2x (level 3) to 5x (Balanced) the time natively.
This rebuilds the bundled engine with wasm-bindgen 0.2.104, as pinned.
engine.jsis unchanged.This is unlikely to be the whole 200 ms. The decode, encode and client decode pipeline remains. Separately, at level 1 PNG is now smaller and faster than JPEG q80 for such content (1128 KB, 29.7 ms), which may be worth revisiting in the lossy heuristic.
Validation: a new test asserts that a repeating pattern compresses below a quarter of its raw size. It fails with the previous engine (153 KB of 196 KB) and passes with this one (23 KB). Native Rust tests, all 561 plugin tests (1 skipped), typecheck, build, manifest validation and formatting passed.