From b41e117c156958e9830cdf18e32a34d46365ad87 Mon Sep 17 00:00:00 2001 From: sisong Date: Sat, 11 Nov 2023 10:35:32 +0800 Subject: [PATCH] update readme cn; --- README.md | 56 +++++---- README_cn.md | 327 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 361 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 97713999..f7467974 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,44 @@ -# [HDiffPatch](https://github.com/sisong/HDiffPatch) +# [HDiffPatch] [![release](https://img.shields.io/badge/release-v4.6.8-blue.svg)](https://github.com/sisong/HDiffPatch/releases) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls) [![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues) - [![release](https://img.shields.io/github/downloads/sisong/HDiffPatch/total?color=blue)](https://github.com/sisong/HDiffPatch/releases) [![Build Status](https://github.com/sisong/HDiffPatch/workflows/ci/badge.svg?branch=master)](https://github.com/sisong/HDiffPatch/actions?query=workflow%3Aci+branch%3Amaster) [![Build status](https://ci.appveyor.com/api/projects/status/t9ow8dft8lt898cv/branch/master?svg=true)](https://ci.appveyor.com/project/sisong/hdiffpatch/branch/master) + english | [中文版](README_cn.md) -a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch. +[HDiffPatch] is a C\C++ library and command-line tools for **diff** & **patch** between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch. -HDiffPatch defines its own patch file format, this lib is also compatible with the [bsdiff4](https://daemonology.net/bsdiff) patch format and partially compatible with the [open-vcdiff](https://github.com/google/open-vcdiff) and [xdelta3](https://github.com/jmacd/xdelta) patch file format VCDIFF(RFC 3284). - -if need patch (OTA) on embedded systems,MCU,NB-IoT..., see demo [HPatchLite](https://github.com/sisong/HPatchLite) (+ [tinyuz](https://github.com/sisong/tinyuz)), can run on 1KB RAM devices! +[HDiffPatch] defines its own patch file format, this lib is also compatible with the [bsdiff4] patch file format and partially compatible with the [open-vcdiff] and [xdelta3] patch file format [VCDIFF(RFC 3284)]. -update your own Android Apk? Jar or Zip file diff & patch? try [ApkDiffPatch](https://github.com/sisong/ApkDiffPatch), to create smaller delta/differential! NOTE: *ApkDiffPath can't be used by Android app store, because it requires re-signing apks before diff.* +if need patch (OTA) on embedded systems,MCU,NB-IoT..., see demo [HPatchLite], +[tinyuz] decompressor can run on 1KB RAM devices! -[sfpatcher](https://github.com/sisong/sfpatcher) not require re-signing apks (like [archive-patcher](https://github.com/google/archive-patcher)), is designed for Android app store, patch speed up by a factor of xx than archive-patcher & run with O(1) memory. +update your own Android Apk? Jar or Zip file diff & patch? try [ApkDiffPatch], to create smaller delta/differential! NOTE: *ApkDiffPath can't be used by Android app store, because it requires re-signing apks before diff.* -if you not have the old versions(too many or not obtain or have been modified), thus cannot create the delta in advance. you can see demo [hsynz](https://github.com/sisong/hsynz) (like [zsync](http://zsync.moria.org.uk)), the new version is only need released once and the owners of the old version get the information about the new version and do the diff&patch themselves. hsynz support zstd compressor & run faster than zsync. +[sfpatcher] not require re-signing apks (like [archive-patcher]), is designed for Android app store, patch speed up by a factor of xx than archive-patcher & run with O(1) memory. + +if you not have the old versions(too many or not obtain or have been modified), thus cannot create the delta in advance. you can see sync demo [hsynz] (like [zsync]), the new version is only need released once and the owners of the old version get the information about the new version and do the diff&patch themselves. hsynz support zstd compressor & run faster than zsync. NOTE: *This library does not deal with file metadata, such as file last wirte time, permissions, link file, etc... To this library, a file is just as a stream of bytes; You can extend this library or use other tools.* + +[HDiffPatch]: https://github.com/sisong/HDiffPatch +[hsynz]: https://github.com/sisong/hsynz +[ApkDiffPatch]: https://github.com/sisong/ApkDiffPatch +[sfpatcher]: https://github.com/sisong/sfpatcher +[HPatchLite]: https://github.com/sisong/HPatchLite +[tinyuz]: https://github.com/sisong/tinyuz +[bsdiff4]: http://www.daemonology.net/bsdiff/ +[xdelta3]: https://github.com/jmacd/xdelta +[open-vcdiff]: https://github.com/google/open-vcdiff +[archive-patcher]: https://github.com/google/archive-patcher +[zsync]: http://zsync.moria.org.uk +[VCDIFF(RFC 3284)]: https://www.rfc-editor.org/rfc/rfc3284 + --- ## Releases/Binaries -[Download from latest release](https://github.com/sisong/HDiffPatch/releases) : Command line app for Windows, Linux, MacOS; and .so patch lib for Android. -( release files build by projects in path `HDiffPatch/builds` ) +[Download from latest release](https://github.com/sisong/HDiffPatch/releases) : Command line app for Windows, Linux, MacOS; and .so patch lib for Android. use cmdline to create a delta: `$hdiffz -m-6 -SD -c-zstd-21-24 -d oldPath newPath outDiffFile` if file is very large, try changing `-m-6` to `-s-64` @@ -37,10 +50,12 @@ apply the delta: ### Linux or MacOS X ### Try: `$ make LZMA=0 ZSTD=0 MD5=0` -bzip2 : if the build fails with `fatal error: bzlib.h: No such file or directory`, use your system's package manager to install the libbz2 package and try again. install bzip2: `$ apt-get install libbz2` or `$ sudo apt-get install libbz2-dev` or `$ yum -y install bzip2` or `$ brew install bzip2` ... -Alternatively, get the optional library headers (+bzip2 library) and build completely: `$ git clone https://github.com/sisong/bzip2.git ../bzip2 && pushd ../bzip2 && make && sudo make install && popd` - -if need lzma zstd md5 support, Try: +bzip2 : if the build fails with `fatal error: bzlib.h: No such file or directory`, use your system's package manager to install the libbz2 package and try again; or download & make with libbz2 source code: +``` +$ git clone https://github.com/sisong/bzip2.git ../bzip2 +$ make LZMA=0 ZSTD=0 MD5=0 BZIP2=1 +``` +if need lzma zstd & md5 support, Try: ``` $ git clone https://github.com/sisong/libmd5.git ../libmd5 $ git clone https://github.com/sisong/lzma.git ../lzma @@ -67,7 +82,6 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2 --- -### command line usage Chinese version: [命令行使用说明中文版](README_cmdline_cn.md) ## **diff** command line usage: diff usage: **hdiffz** [options] **oldPath newPath outDiffFile** @@ -282,7 +296,7 @@ all **diff**&**patch** function in file: `libHDiffPatch/HDiff/diff.h` & `libHDif * **patch_single_stream_mem()** * **patch_single_compressed_diff()** * **patch_single_stream_diff()** -#### hpatch lite API, optimized hpatch on MCU,NB-IoT... (demo [HPatchLite](https://github.com/sisong/HPatchLite)): +#### hpatch lite API, optimized hpatch on MCU,NB-IoT... (demo [HPatchLite]): * **create_lite_diff()** * **hpatch_lite_open()** * **hpatch_lite_patch()** @@ -294,7 +308,7 @@ all **diff**&**patch** function in file: `libHDiffPatch/HDiff/diff.h` & `libHDif * **create_vcdiff()** * **create_vcdiff_stream()** * **vcpatch_with_cache()** -#### hsynz API, diff&patch by sync (demo [hsynz](https://github.com/sisong/hsynz)): +#### hsynz API, diff&patch by sync (demo [hsynz]): * **create_sync_data()** * **create_dir_sync_data()** * **sync_patch()** @@ -305,7 +319,7 @@ all **diff**&**patch** function in file: `libHDiffPatch/HDiff/diff.h` & `libHDif * **sync_local_patch_...()** --- -## HDiffPatch vs BsDiff & xdelta: +## [HDiffPatch] vs [bsdiff4] & [xdelta3]: case list([download from OneDrive](https://1drv.ms/u/s!Aj8ygMPeifoQgUIZxYac5_uflNoN)): | |newFile <-- oldFile|newSize|oldSize| |----:|:----|----:|----:| @@ -447,8 +461,8 @@ case list: **sfpatcher -1 zstd** v1.1.1 diff with `-o-1 -c-zstd-21-23 -m-1 -step-3m -lp-512k -p-8 -cache -d {old} {new} {pat}` **sfpatcher -2 lzma2** diff with `-o-2 -c-lzma2-9-4m -m-1 -step-2m -lp-8m -p-8 -cache -d {old} {new} {pat}` sfpatcher patch with `-lp -p-8 {old} {pat} {new}` -adding test hpatchz&hsynz&sfpatcher on Android, CPU Kirin980(2×A76 2.6G + 2×A76 1.92G + 4×A55 1.8G) -( [archive-patcher](https://github.com/google/archive-patcher), [sfpatcher](https://github.com/sisong/sfpatcher) optimized diff&patch between apk files ) +adding test hpatchz&hsynz&sfpatcher on Android, arm CPU Kirin980(2×A76 2.6G + 2×A76 1.92G + 4×A55 1.8G) +( [archive-patcher], [sfpatcher] optimized diff&patch between apk files ) **test result average**: |Program|compress|diff mem|speed|patch mem|max mem|speed|arm Kirin980| diff --git a/README_cn.md b/README_cn.md index 0eec18c7..40368113 100644 --- a/README_cn.md +++ b/README_cn.md @@ -1,5 +1,88 @@ -# [HDiffPatch](https://github.com/sisong/HDiffPatch) 命令行使用说明中文版 +# [HDiffPatch] +[![release](https://img.shields.io/badge/release-v4.6.8-blue.svg)](https://github.com/sisong/HDiffPatch/releases) +[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls) +[![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues) +[![release](https://img.shields.io/github/downloads/sisong/HDiffPatch/total?color=blue)](https://github.com/sisong/HDiffPatch/releases) +[![Build Status](https://github.com/sisong/HDiffPatch/workflows/ci/badge.svg?branch=master)](https://github.com/sisong/HDiffPatch/actions?query=workflow%3Aci+branch%3Amaster) +[![Build status](https://ci.appveyor.com/api/projects/status/t9ow8dft8lt898cv/branch/master?svg=true)](https://ci.appveyor.com/project/sisong/hdiffpatch/branch/master) + 中文版 | [english](README.md) +[HDiffPatch] 是一个C\C++库和命令行工具,用于在二进制文件或文件夹之间执行**diff**(创建补丁)和**patch**(打补丁);跨平台、运行快、创建的补丁小、支持巨大的文件并且可控制diff和patch时的内存占用量。 + +[HDiffPatch] 定义了自己的补丁包格式,同时这个库也完全兼容了 [bsdiff4] 的补丁包格式,并部分兼容 [open-vcdiff] 和 [xdelta3] 的补丁包格式 [VCDIFF(RFC 3284)]。 + +如果需要在嵌入式系统(MCU、NB-IoT)等设备上进行增量更新(OTA), 可以看看例子 [HPatchLite], +[tinyuz] 解压缩器可以在1KB内存的设备上运行! + +需要更新你自己的安卓apk? 需要对Jar或Zip文件执行 diff & patch ? 可以试试 [ApkDiffPatch], 可以创建更小的补丁! 注意: *ApkDiffPath 不能被安卓应用商店作为增量更新使用,因为该算法要求在diff前对apk文件进行重新签名。* + +[sfpatcher] 不要求对apk文件进行重新签名 (类似 [archive-patcher]),是为安卓应用商店专门设计优化的算法,patch速度是 archive-patcher 的xx倍,并且只需要O(1)内存。 + +如果你没有旧版本的数据(或者旧版本非常多或者被修改),因此不能提前创建好所有补丁包。那你可以看看使用同步算法来进行增量更新的例子 [hsynz] (类似 [zsync]),新版本只需要发布处理一次,然后旧版本数据的拥有者可以根据获得的新版本的信息自己执行diff和patch。hsynz 支持 zstd 压缩算法并且比 zsync 速度更快。 + +注意: *本库不处理文件元数据,如文件最后写入时间、权限、链接文件等。对于这个库,文件就像一个字节流;如果需要您可以扩展此库或使用其他工具。* + + +[HDiffPatch]: https://github.com/sisong/HDiffPatch +[hsynz]: https://github.com/sisong/hsynz +[ApkDiffPatch]: https://github.com/sisong/ApkDiffPatch +[sfpatcher]: https://github.com/sisong/sfpatcher +[HPatchLite]: https://github.com/sisong/HPatchLite +[tinyuz]: https://github.com/sisong/tinyuz +[bsdiff4]: http://www.daemonology.net/bsdiff/ +[xdelta3]: https://github.com/jmacd/xdelta +[open-vcdiff]: https://github.com/google/open-vcdiff +[archive-patcher]: https://github.com/google/archive-patcher +[zsync]: http://zsync.moria.org.uk +[VCDIFF(RFC 3284)]: https://www.rfc-editor.org/rfc/rfc3284 + +--- +## 二进制发布包 +[从 release 下载](https://github.com/sisong/HDiffPatch/releases) : 命令行程序分别运行在 Windows、Linux、MacOS操作系统。 .so库文件用于安卓。 +用命令行创建一个补丁: +`$hdiffz -m-6 -SD -c-zstd-21-24 -d oldPath newPath outDiffFile` +如果文件非常大,可以试试将 `-m-6` 改为 `-s-64` +打补丁: +`$hpatchz oldPath diffFile outNewPath` + +## 自己编译 +`$ cd /HDiffPatch` +### Linux or MacOS X ### +试试: +`$ make LZMA=0 ZSTD=0 MD5=0` +bzip2 : 如果编译失败,显示 `fatal error: bzlib.h: No such file or directory`,请使用系统的包管理器安装libbz2,然后再试一次;或者下载并使用libbz2源代码来编译: +``` +$ git clone https://github.com/sisong/bzip2.git ../bzip2 +$ make LZMA=0 ZSTD=0 MD5=0 BZIP2=1 +``` +如果需要支持 lzma、zstd 和 md5,试试: +``` +$ git clone https://github.com/sisong/libmd5.git ../libmd5 +$ git clone https://github.com/sisong/lzma.git ../lzma +$ git clone https://github.com/sisong/zstd.git ../zstd +$ make +``` +提示:你可以使用 `$ make -j` 来并行编译。 + +### Windows ### +使用 [`Visual Studio`](https://visualstudio.microsoft.com) 打开 `builds/vc/HDiffPatch.sln` 来编译之前,先将第三方库下载到同级文件夹中,如下所示: +``` +$ git clone https://github.com/sisong/libmd5.git ../libmd5 +$ git clone https://github.com/sisong/lzma.git ../lzma +$ git clone https://github.com/sisong/zstd.git ../zstd +$ git clone https://github.com/sisong/zlib.git ../zlib +$ git clone https://github.com/sisong/bzip2.git ../bzip2 +``` + +### libhpatchz.so for Android ### +* 安装 [Android NDK](https://developer.android.google.cn/ndk/downloads) +* `$ cd /HDiffPatch/builds/android_ndk_jni_mk` +* `$ build_libs.sh` (或者 Windows下执行 `$ build_libs.bat`, 就可以得到 \*.so 安卓库了) +* 在你的安卓项目中添加 `com/github/sisong/HPatch.java` (所在路径 `HDiffPatch/builds/android_ndk_jni_mk/java/`) 和 .so 文件, java 代码就可以调用 libhpatchz.so 中的 patch 函数了。 + + +--- + ## diff 命令行用法和参数说明: 创建新旧版本间的补丁: **hdiffz** [options] **oldPath newPath outDiffFile** 压缩一个文件或文件夹: **hdiffz** [-c-...] **"" newPath outDiffFile** @@ -177,3 +260,245 @@ 输出命令行帮助信息 (该说明)。 ``` +--- +## 库 API 使用说明: +所有 **diff**和**patch** 函数在文件: `libHDiffPatch/HDiff/diff.h` & `libHDiffPatch/HPatch/patch.h` +**dir_diff()** 和 **dir patch** 在: `dirDiffPatch/dir_diff/dir_diff.h` & `dirDiffPatch/dir_patch/dir_patch.h` +### 使用方式: +* **create diff**(in newData,in oldData,out diffData); + 发布 diffData 来升级 oldData。 +* **patch**(out newData,in oldData,in diffData); + ok,得到了 newData。 +### v1 API, 未压缩补丁: +* **create_diff()** +* **patch()** +* **patch_stream()** +* **patch_stream_with_cache()** +### v2 API, 压缩的补丁包: +* **create_compressed_diff()** +* **create_compressed_diff_stream()** +* **resave_compressed_diff()** +* **patch_decompress()** +* **patch_decompress_with_cache()** +* **patch_decompress_mem()** +### v3 API, 在文件夹间 **diff**&**patch**: +* **dir_diff()** +* **TDirPatcher_\*()** functions with **struct TDirPatcher** +### v4 API, 单压缩流补丁包: +* **create_single_compressed_diff()** +* **create_single_compressed_diff_stream()** +* **resave_single_compressed_diff()** +* **patch_single_stream()** +* **patch_single_stream_mem()** +* **patch_single_compressed_diff()** +* **patch_single_stream_diff()** +#### hpatch lite API, 为 MCU,NB-IoT... 优化了的 hpatch (例子 [HPatchLite]): +* **create_lite_diff()** +* **hpatch_lite_open()** +* **hpatch_lite_patch()** +#### bsdiff 兼容包装 API: +* **create_bsdiff()** +* **create_bsdiff_stream()** +* **bspatch_with_cache()** +#### vcdiff 兼容包装 API: +* **create_vcdiff()** +* **create_vcdiff_stream()** +* **vcpatch_with_cache()** +#### hsynz API, 同步 diff&patch (例子 [hsynz]): +* **create_sync_data()** +* **create_dir_sync_data()** +* **sync_patch()** +* **sync_patch_...()** +* **sync_local_diff()** +* **sync_local_diff_...()** +* **sync_local_patch()** +* **sync_local_patch_...()** + +--- +## [HDiffPatch] vs [bsdiff4] & [xdelta3]: +测试例子([从 OneDrive 下载](https://1drv.ms/u/s!Aj8ygMPeifoQgUIZxYac5_uflNoN)): +| |newFile <-- oldFile|newSize|oldSize| +|----:|:----|----:|----:| +|1|7-Zip_22.01.win.tar <-- 7-Zip_21.07.win.tar|5908992|5748224| +|2|Chrome_107.0.5304.122-x64-Stable.win.tar <-- 106.0.5249.119|278658560|273026560| +|3|cpu-z_2.03-en.win.tar <-- cpu-z_2.02-en.win.tar|8718336|8643072| +|4|curl_7.86.0.src.tar <-- curl_7.85.0.src.tar|26275840|26030080| +|5|douyin_1.5.1.mac.tar <-- douyin_1.4.2.mac.tar|407940608|407642624| +|6|Emacs_28.2-universal.mac.tar <-- Emacs_27.2-3-universal.mac.tar|196380160|257496064| +|7|FFmpeg-n_5.1.2.src.tar <-- FFmpeg-n_4.4.3.src.tar|80527360|76154880| +|8|gcc_12.2.0.src.tar <-- gcc_11.3.0.src.tar|865884160|824309760| +|9|git_2.33.0-intel-universal-mavericks.mac.tar <-- 2.31.0|73302528|70990848| +|10|go_1.19.3.linux-amd64.tar <-- go_1.19.2.linux-amd64.tar|468835840|468796416| +|11|jdk_x64_mac_openj9_16.0.1_9_openj9-0.26.0.tar <-- 9_15.0.2_7-0.24.0|363765760|327188480| +|12|jre_1.8.0_351-linux-x64.tar <-- jre_1.8.0_311-linux-x64.tar|267796480|257996800| +|13|linux_5.19.9.src.tar <-- linux_5.15.80.src.tar|1269637120|1138933760| +|14|Minecraft_175.win.tar <-- Minecraft_172.win.tar|166643200|180084736| +|15|OpenOffice_4.1.13.mac.tar <-- OpenOffice_4.1.10.mac.tar|408364032|408336896| +|16|postgresql_15.1.src.tar <-- postgresql_14.6.src.tar|151787520|147660800| +|17|QQ_9.6.9.win.tar <-- QQ_9.6.8.win.tar|465045504|464837120| +|18|tensorflow_2.10.1.src.tar <-- tensorflow_2.8.4.src.tar|275548160|259246080| +|19|VSCode-win32-x64_1.73.1.tar <-- VSCode-win32-x64_1.69.2.tar|364025856|340256768| +|20|WeChat_3.8.0.41.win.tar <-- WeChat_3.8.0.33.win.tar|505876992|505018368| + + +**测试 PC**: Windows11, CPU R9-7945HX, SSD PCIe4.0x4 4T, DDR5 5200MHz 32Gx2 +**参与测试的程序和版本**: HDiffPatch4.6.3, hsynz 0.9.3, BsDiff4.3, xdelta3.1, zstd1.5.2 +**参与测试程序的参数**: +**zstd --patch-from** diff with `--ultra -21 --long=24 -f --patch-from={old} {new} -o {pat}` + zstd patch with `-d -f --memory=2047MB --patch-from={old} {pat} -o {new}` +**xdelta3** diff with `-S lzma -e -9 -n -f -s {old} {new} {pat}` +**xdelta3** patch with `-d -f -s {old} {pat} {new}` +& adding **hpatchz** test: `hpatchz -m -f {old} {xdelta3-pat} {new}` +**xdelta3 -B** diff with `-S lzma -B {oldSize} -e -9 -n -f -s {old} {new} {pat}` +**xdelta3 -B** patch with `-B {oldSize} -d -f -s {old} {pat} {new}` +& adding **hpatchz** test: `hpatchz -m -f {old} {xdelta3-B-pat} {new}` +**bsdiff** diff with `{old} {new} {pat}` +**bspatch** patch with `{old} {new} {pat}` +& adding **hpatchz** test: `hpatchz -m -f {old} {bsdiff-pat} {new}` +**hdiffz -BSD** diff with `-m-6 -BSD -d -f -p-1 {old} {new} {pat}` +**hdiffz zlib** diff with `-m-6 -SD -d -f -p-1 -c-zlib-9 {old} {new} {pat}` +**hdiffz lzma2** diff with `-m-6 -SD -d -f -p-1 -c-lzma2-9-16m {old} {new} {pat}` +**hdiffz zstd** diff with `-m-6 -SD -d -f -p-1 -c-zstd-21-24 {old} {new} {pat}` +**hdiffz -s zlib** diff with `-s-64 -SD -d -f -p-1 -c-zlib-9 {old} {new} {pat}` +**hdiffz -s lzma2** diff with `-s-64 -SD -d -f -p-1 -c-lzma2-9-16m {old} {new} {pat}` +**hdiffz -s zstd** diff with `-s-64 -SD -d -f -p-1 -c-zstd-21-24 {old} {new} {pat}` +& adding all **hdiffz** test with -p-8 +**hpatchz** patch with `-s-3m -f {old} {pat} {new}` +**hsynz** test, make sync info by `hsync_make -s-2k {new} {out_newi} {out_newz}`, +client sync diff&patch by `hsync_demo {old} {newi} {newz} {out_new} -p-1` +**hsynz p1 zlib** run hsync_make with `-p-1 -c-zlib-9` +**hsynz p8 zlib** run hsync_make with `-p-8 -c-zlib-9` (run `hsync_demo` with `-p-8`) +**hsynz p1 zstd** run hsync_make with `-p-1 -c-zstd-21-24` +**hsynz p8 zstd** run hsync_make with `-p-8 -c-zstd-21-24` (run `hsync_demo` with `-p-8`) + +**测试结果取平均**: +|程序|包大小|diff内存|速度|patch内存|最大内存|速度| +|:----|----:|----:|----:|----:|----:|----:| +|bzip2-9 |33.67%||22.9MB/s|||66MB/s| +|zlib-9 |36.53%||19.8MB/s|||539MB/s| +|lzma2-9-16m |25.85%||5.3MB/s|||215MB/s| +|zstd-21-24 |27.21%||4.2MB/s|||976MB/s| +|| +|zstd --patch-from|7.96%|2798M|3.3MB/s|629M|2303M|828MB/s| +|xdelta3|13.60%|409M|6.9MB/s|86M|102M|159MB/s| +|xdelta3 +hpatchz -m|13.60%|409M|6.9MB/s|70M|82M|377MB/s| +|xdelta3 -B|9.63%|2282M|10.9MB/s|460M|2070M|267MB/s| +|xdelta3 -B +hpatchz -m|9.63%|2282M|10.9MB/s|315M|1100M|477MB/s| +|bsdiff|8.17%|2773M|2.5MB/s|637M|2312M|167MB/s| +|bsdiff +hpatchz -m|8.17%|2773M|2.5MB/s|321M|1101M|197MB/s| +|hdiffz p1 -BSD|7.72%|1210M|13.4MB/s|14M|14M|172MB/s| +|hdiffz p8 -BSD|7.72%|1191M|31.2MB/s|14M|14M|172MB/s| +|hdiffz p1 zlib|7.79%|1214M|14.4MB/s|4M|4M|564MB/s| +|hdiffz p8 zlib|7.79%|1190M|44.8MB/s|4M|4M|559MB/s| +|hdiffz p1 lzma2|6.44%|1209M|11.4MB/s|16M|20M|431MB/s| +|hdiffz p8 lzma2|6.44%|1191M|33.4MB/s|16M|20M|428MB/s| +|hdiffz p1 zstd|6.74%|1211M|11.5MB/s|16M|21M|592MB/s| +|hdiffz p8 zstd|6.74%|1531M|24.3MB/s|16M|21M|586MB/s| +|hdiffz -s p1 -BSD|11.96%|91M|46.0MB/s|14M|14M|148MB/s| +|hdiffz -s p8 -BSD|11.96%|95M|59.8MB/s|14M|14M|148MB/s| +|hdiffz -s p1 zlib|12.52%|91M|46.4MB/s|3M|4M|611MB/s| +|hdiffz -s p8 zlib|12.53%|95M|178.9MB/s|3M|4M|609MB/s| +|hdiffz -s p1 lzma2|9.11%|170M|18.1MB/s|17M|20M|402MB/s| +|hdiffz -s p8 lzma2|9.13%|370M|50.6MB/s|17M|20M|400MB/s| +|hdiffz -s p1 zstd|9.60%|195M|18.0MB/s|17M|21M|677MB/s| +|hdiffz -s p8 zstd|9.60%|976M|28.5MB/s|17M|21M|678MB/s| +|hsynz p1 zlib|20.05%|6M|17.7MB/s|6M|21M|160MB/s| +|hsynz p8 zlib|20.05%|30M|119.5MB/s|13M|29M|246MB/s| +|hsynz p1 zstd|14.97%|531M|1.9MB/s|24M|35M|173MB/s| +|hsynz p8 zstd|14.96%|3349M|10.2MB/s|24M|35M|278MB/s| + + +## 使用 Apk 文件来测试: +测试用例: +| |app|newFile <-- oldFile|newSize|oldSize| +|----:|:---:|:----|----:|----:| +|1||cn.wps.moffice_eng_13.30.0.apk <-- 13.29.0|95904918|94914262| +|2||com.achievo.vipshop_7.80.2.apk <-- 7.79.9|127395632|120237937| +|3||com.adobe.reader_22.9.0.24118.apk <-- 22.8.1.23587|27351437|27087718| +|4||com.alibaba.android.rimet_6.5.50.apk <-- 6.5.45|195314449|193489159| +|5||com.amazon.mShop.android.shopping_24.18.2.apk <-- 24.18.0|76328858|76287423| +|6||com.baidu.BaiduMap_16.5.0.apk <-- 16.4.5|131382821|132308374| +|7||com.dragon.read_5.5.3.33.apk <-- 5.5.1.32|45112658|43518658| +|8||com.ebay.mobile_6.80.0.1.apk <-- 6.79.0.1|61202587|61123285| +|9||com.eg.android.AlipayGphone_10.3.0.apk <-- 10.2.96|122073135|119046208| +|10||com.google.android.apps.translate_6.46.0.apk <-- 6.45.0|48892967|48843378| +|11||com.google.android.googlequicksearchbox_13.38.11.apk <-- 13.37.10|190539272|189493966| +|12||com.jingdong.app.mall_11.3.2.apk <-- 11.3.0|101098430|100750191| +|13||com.netease.cloudmusic_8.8.45.apk <-- 8.8.40|181914846|181909451| +|14||com.reddit.frontpage_2022.36.0.apk <-- 2022.34.0|50205119|47854461| +|15||com.sankuai.meituan.takeoutnew_7.94.3.apk <-- 7.92.2|74965893|74833926| +|16||com.sankuai.meituan_12.4.207.apk <-- 12.4.205|93613732|93605911| +|17||com.sina.weibo_12.10.0.apk <-- 12.9.5|156881776|156617913| +|18||com.smile.gifmaker_10.8.40.27845.apk <-- 10.8.30.27728|102403847|101520138| +|19||com.ss.android.article.news_9.0.7.apk <-- 9.0.6|54444003|53947221| +|20||com.ss.android.ugc.aweme_22.6.0.apk <-- 22.5.0|171683897|171353597| +|21||com.taobao.taobao_10.18.10.apk <-- 10.17.0|117218670|117111874| +|22||com.tencent.mm_8.0.28.apk <-- 8.0.27|266691829|276603782| +|23||com.tencent.mobileqq_8.9.15.apk <-- 8.9.13|311322716|310529631| +|24||com.tencent.mtt_13.2.0.0103.apk <-- 13.2.0.0045|97342747|97296757| +|25||com.tripadvisor.tripadvisor_49.5.apk <-- 49.3|28744498|28695346| +|26||com.twitter.android_9.61.0.apk <-- 9.58.2|36141840|35575484| +|27||com.ubercab_4.442.10002.apk <-- 4.439.10002|69923232|64284150| +|28||com.ximalaya.ting.android_9.0.66.3.apk <-- 9.0.62.3|115804845|113564876| +|29||com.xunmeng.pinduoduo_6.30.0.apk <-- 6.29.1|30896833|30951567| +|30||com.youdao.dict_9.2.29.apk <-- 9.2.28|110624682|110628778| +|31||org.mozilla.firefox_105.2.0.apk <-- 105.1.0|83078464|83086656| +|32||tv.danmaku.bili_7.1.0.apk <-- 7.0.0|104774723|104727005| + + +**对测试程序的参数进行一些调整**: +**hdiffz ...** `-m-6 -SD` changed to `-m-1 -SD-2m -cache`, `-s-64 -SD` changed to `-s-16 -SD-2m` +**hdiffz ...** lzma2 dict size `16m` changed to `8m`, zstd dict bit `24` changed to `23` +**hsynz ...** make `-s-2k` changed to `-s-1k` +& adding **hsynz p1**, **hsynz p8** make without compressor +**archive-patcher** v1.0, diff with `--generate --old {old} --new {new} --patch {pat}`, + patch with `--apply --old {old} --patch {pat} --new {new}` + 注意: archive-patcher 统计的补丁包大小是经过了 lzma2-9-16m 压缩后的, 而 diff&patch 统计时并不包含压缩和解压缩补丁所需的内存和时间。 +**sfpatcher -1 zstd** v1.1.1 diff with `-o-1 -c-zstd-21-23 -m-1 -step-3m -lp-512k -p-8 -cache -d {old} {new} {pat}` +**sfpatcher -2 lzma2** diff with `-o-2 -c-lzma2-9-4m -m-1 -step-2m -lp-8m -p-8 -cache -d {old} {new} {pat}` + sfpatcher patch with `-lp -p-8 {old} {pat} {new}` +adding test hpatchz&hsynz&sfpatcher on Android, arm CPU 麒麟980(2×A76 2.6G + 2×A76 1.92G + 4×A55 1.8G) +( [archive-patcher]、[sfpatcher] diff&patch 时针对apk文件格式进行了优化 ) + +**测试结果取平均**: +|程序|包大小|diff内存|速度|patch内存|最大内存|速度|arm 麒麟980| +|:----|----:|----:|----:|----:|----:|----:|----:| +|zstd --patch-from|53.18%|2199M|3.6MB/s|209M|596M|609MB/s| +|xdelta3|54.51%|422M|3.8MB/s|98M|99M|170MB/s| +|xdelta3 +hpatchz -m|54.51%|422M|3.8MB/s|70M|81M|438MB/s| +|bsdiff|53.84%|931M|1.2MB/s|218M|605M|54MB/s| +|bsdiff+hpatchz -m|53.84%|931M|1.2MB/s|116M|310M|57MB/s| +|bsdiff+hpatchz -s|53.84%|931M|1.2MB/s|14M|14M|54MB/s| +|hdiffz p1 -BSD|53.69%|509M|6.8MB/s|14M|14M|55MB/s| +|hdiffz p8 -BSD|53.70%|514M|15.3MB/s|14M|14M|55MB/s| +|hdiffz p1|54.40%|509M|8.8MB/s|5M|6M|682MB/s| +|hdiffz p8|54.41%|514M|32.4MB/s|5M|6M|686MB/s|443MB/s| +|hdiffz p1 zlib|53.21%|509M|8.2MB/s|5M|6M|514MB/s| +|hdiffz p8 zlib|53.22%|514M|31.1MB/s|5M|6M|512MB/s|343MB/s| +|hdiffz p1 lzma2|52.93%|525M|4.1MB/s|21M|22M|260MB/s| +|hdiffz p8 lzma2|52.94%|557M|18.9MB/s|21M|22M|261MB/s|131MB/s| +|hdiffz p1 zstd|53.04%|537M|5.4MB/s|21M|22M|598MB/s| +|hdiffz p8 zstd|53.05%|1251M|11.1MB/s|21M|22M|604MB/s|371MB/s| +|hdiffz -s p1 zlib|53.73%|118M|26.8MB/s|4M|6M|513MB/s| +|hdiffz -s p8 zlib|53.73%|122M|97.3MB/s|4M|6M|513MB/s| +|hdiffz -s p1 lzma2|53.30%|197M|6.4MB/s|20M|22M|258MB/s| +|hdiffz -s p8 lzma2|53.30%|309M|32.4MB/s|20M|22M|258MB/s| +|hdiffz -s p1 zstd|53.44%|221M|10.1MB/s|20M|22M|620MB/s| +|hdiffz -s p8 zstd|53.44%|1048M|14.4MB/s|20M|22M|613MB/s| +|hsynz p1|62.43%|4M|1647.6MB/s|4M|9M|152MB/s|55MB/s| +|hsynz p8|62.43%|6M|2563.7MB/s|11M|18M|270MB/s|107MB/s| +|hsynz p1 zlib|58.67%|5M|23.7MB/s|4M|11M|151MB/s|54MB/s| +|hsynz p8 zlib|58.67%|29M|141.8MB/s|12M|19M|265MB/s|96MB/s| +|hsynz p1 zstd|57.74%|534M|2.7MB/s|24M|28M|151MB/s|52MB/s| +|hsynz p8 zstd|57.74%|3434M|13.2MB/s|24M|28M|265MB/s|95MB/s| +|archive-patcher|31.65%|1448M|0.9MB/s|558M|587M|14MB/s| +|sfpatcher-1 p1 zstd|31.08%|818M|2.3MB/s|15M|19M|201MB/s|92MB/s| +|sfpatcher-1 p8 zstd|31.07%|1025M|4.6MB/s|18M|25M|424MB/s|189MB/s| +|sfpatcher-2 p1 lzma2|24.11%|976M|2.1MB/s|15M|20M|37MB/s|19MB/s| +|sfpatcher-2 p8 lzma2|24.15%|968M|5.0MB/s|20M|26M|108MB/s|45MB/s| + + +--- +## 联系 +housisong@hotmail.com +