Skip to content

perf: compress built-in engine PNG frames with zlib level 1 - #43

Merged
LukeGus merged 1 commit into
Termix-SSH:dev-1.4.2from
ZacharyZcR:perf/png-zlib-level
Nov 16, 2026
Merged

LukeGus merged 1 commit into
Termix-SSH:dev-1.4.2from
ZacharyZcR:perf/png-zlib-level

Conversation

@ZacharyZcR

Copy link
Copy Markdown
Member

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:

Region Before After Encode time
1920x1080 2333 KB (3.1 MB base64) 579 KB (772 KB base64) 22.2 ms → 22.9 ms
960x720 window 805 KB 201 KB 7.8 ms → 8.3 ms
1920x200 scroll band 449 KB 111 KB 3.9 ms → 4.2 ms

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.js is 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.

@termix-triage-bot

termix-triage-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

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 /termix review to run it again.

@ZacharyZcR
ZacharyZcR changed the base branch from main to dev-1.4.1 November 15, 2026 19:28
@termix-ci
termix-ci Bot deleted the branch Termix-SSH:dev-1.4.1 November 15, 2026 19:35
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.
@ZacharyZcR
ZacharyZcR changed the base branch from dev-1.4.1 to dev-1.4.2 November 16, 2026 13:24

@LukeGus LukeGus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LukeGus
LukeGus merged commit bfb7ab3 into Termix-SSH:dev-1.4.2 Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants