ya-webadb icon indicating copy to clipboard operation
ya-webadb copied to clipboard

Support compression in sync push/pull

Open yume-chan opened this issue 2 years ago • 4 comments

Android 11 added support for Brotli compression in sync push/pull, Android 12 further added lz4 and zstd support. Using compression can result in up to 2x transfer speed.

Algorithms:

  • [ ] Brotli https://android-review.googlesource.com/c/platform/system/core/+/1250677
  • [ ] lz4 https://android-review.googlesource.com/c/platform/system/core/+/1276917
  • [ ] Zstd https://android-review.googlesource.com/c/platform/system/core/+/1319091

From https://android-review.googlesource.com/c/platform/system/core/+/1276917, pull speed in MB/s:

           none    brotli    lz4
USB 3.0     120       110    190
USB 2.0      38        75     63

No pure-JS implementations of all three algorithms were found on NPM. Need to create them ourselves.

Android 12 also added a dry-run flag in push/pull for testing. Shouldn't be useful in real situations: https://android-review.googlesource.com/c/platform/system/core/+/1276918

yume-chan avatar Feb 28 '23 07:02 yume-chan

Have to using pure-JS to implement it? How about WebAssembly? It can also be cross-platform and has good performance.

gogogoghost avatar Dec 13 '23 09:12 gogogoghost

WebAssembly is also an option. Do you know any WebAssembly build for those compression algorithms?

yume-chan avatar Dec 14 '23 05:12 yume-chan

Hi @yume-chan

For example, we can use these packages: brotli-wasm, lz4-wasm and zstd-wasm.

kuzalekon avatar Jan 31 '24 22:01 kuzalekon

I had already checked brotli-wasm and lz4-wasm.

brotli-wasm is the most promising one, but it does work (out-of-the-box) with Vite (https://github.com/httptoolkit/brotli-wasm/issues/8), so it can't be used in a library that may be consumed by any bundler.

lz4-wasm doesn't expose streaming compression API so can't be used.

zstd-wasm has 0 documentation so I don't know what it does.

yume-chan avatar Feb 01 '24 02:02 yume-chan