Skip to content

feat: zstd compression — requires tunnel-node + CodeFull.gs update - 30% saving download - Full Tunnel#1314

Merged
therealaleph merged 2 commits into
therealaleph:mainfrom
yyoyoian-pixel:feat/zstd-compression
May 20, 2026
Merged

feat: zstd compression — requires tunnel-node + CodeFull.gs update - 30% saving download - Full Tunnel#1314
therealaleph merged 2 commits into
therealaleph:mainfrom
yyoyoian-pixel:feat/zstd-compression

Conversation

@yyoyoian-pixel
Copy link
Copy Markdown
Contributor

@yyoyoian-pixel yyoyoian-pixel commented May 19, 2026

Summary

End-to-end zstd compression for the tunnel batch protocol. Requires updating both the tunnel-node and CodeFull.gs Apps Script deployment for compression to activate.

How it works

  1. Batch 1: client sends ops + zc:1 flag → tunnel-node responds with compressed zr + zc:1
  2. Batch 2+: client sends compressed zops → tunnel-node responds with zr
  3. Apps Script passes zc and zops/zr through opaquely

What needs updating

  • tunnel-node: redeploy (Cloud Run or VPS) — handles zops decompression + zr compression
  • CodeFull.gs: redeploy Apps Script with new version — passes zc flag to tunnel-node and zops opaque forward
  • Client: new binary sends zc capability flag

Backward compatible — zero failures

  • Old client + new tunnel: no zc sent → normal r response, nothing changes
  • New client + old tunnel: sends zc, old tunnel ignores it → normal r, compression never activates
  • New client + old Apps Script: zc stripped by old script → tunnel never sees it, normal r
  • New client + new tunnel + new script: full compression both ways

Measured results

  • Download compression: ~25-30% bandwidth saved
  • RTT improvement: 5-7s → 1.5-2s on data-heavy batches
  • Upload compression: ~5% on small batches, ~25% on large uploads (base64 entropy gain)
  • Compression works by exploiting base64's 6-bit-per-byte entropy (zstd recovers the 33% base64 expansion)

Apps Script quota impact

  • Execution time (6-min limit): UrlFetchApp.fetch() transfers 25-30% less data per batch → faster round-trips → more batches fit within the 6-minute execution window
  • Daily data quota: 25-30% less data fetched per response → quota stretches further across all deployments
  • URL Fetch call count: unchanged (same number of HTTP requests per batch) — this is usually the tighter constraint
  • Net effect: same number of requests but each one moves faster and uses less data budget

Test plan

  • Handshake negotiation: client sends ops+zc, gets zr+zc, switches to zops
  • Response compression working (zr)
  • Request compression working (zops)
  • Video streaming with compression
  • Photo upload with compression
  • Old client with new tunnel-node (no compression, no failure)
  • Old tunnel-node with new client (no compression, no failure)

🤖 Generated with Claude Code

@github-actions github-actions Bot added the type: feature feat: PR — auto-applied by release-drafter label May 19, 2026
@yyoyoian-pixel yyoyoian-pixel changed the title feat: end-to-end zstd compression for tunnel batches feat: zstd compression — requires tunnel-node + CodeFull.gs update May 19, 2026
Zero-failure capability negotiation:
- Batch 1: client sends ops + zc:1, tunnel responds with zr + zc:1
- Batch 2+: client sends zops (compressed), tunnel responds with zr
- Apps Script passes zc/zops/zr through opaquely

Backward compatible: old clients/tunnel-nodes/scripts ignore unknown
fields — compression never activates, nothing breaks.

Also: INFLIGHT_ACTIVE 4→6 for better pipeline throughput.

Requires tunnel-node + CodeFull.gs redeployment for activation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yyoyoian-pixel yyoyoian-pixel force-pushed the feat/zstd-compression branch from db8b4f5 to eb3adaf Compare May 19, 2026 20:57
@yyoyoian-pixel yyoyoian-pixel changed the title feat: zstd compression — requires tunnel-node + CodeFull.gs update feat: zstd compression — requires tunnel-node + CodeFull.gs update - 30% saving download - Full Tunnel May 19, 2026
Copy link
Copy Markdown
Owner

@therealaleph therealaleph left a comment

Choose a reason for hiding this comment

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

Reviewed and accepted. I added one small maintainer-side safety commit before merge: keep compressed batch logs redacted, and authenticate the tunnel batch request before decoding compressed zops. Local verification passed on the updated branch:

  • cargo test --lib
  • cargo build --release
  • cargo build --bin mhrv-rs-ui --release --features ui
  • cargo test (tunnel-node)
  • cargo build --release (tunnel-node)
  • Android debug build with Android Studio JBR

Docker local image build was attempted but Docker Desktop/daemon is not running on this Mac (/Users/dev/.docker/run/docker.sock missing), so container image verification will be covered by the release workflow.


Answered via LLM, Supervised @therealaleph

@therealaleph therealaleph merged commit 1676b59 into therealaleph:main May 20, 2026
1 check passed
therealaleph added a commit that referenced this pull request May 20, 2026
## Summary
- Bump mhrv-rs to v1.9.32 and Android versionCode/versionName.
- Bump tunnel-node subcrate to 0.1.1 for the new compressed batch protocol surface.
- Add Persian/English changelog for Full Tunnel zstd compression from PR #1314.

## Local verification
- cargo test --lib
- cargo build --release
- cargo build --bin mhrv-rs-ui --release --features ui
- cargo test (tunnel-node)
- cargo build --release (tunnel-node)
- JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home" ANDROID_HOME="$HOME/Library/Android/sdk" ./gradlew :app:assembleDebug

Docker local image build was attempted during PR verification, but Docker Desktop/daemon is not running on this Mac (`/Users/dev/.docker/run/docker.sock` missing). The release workflow tunnel-docker job will cover container publishing.

---
Answered via LLM, Supervised @therealaleph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature feat: PR — auto-applied by release-drafter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants