Skip to content

Instantly share code, notes, and snippets.

@evandandrea
Last active September 22, 2017 14:26
Show Gist options
  • Save evandandrea/a10e06d0cc0a5311f0560804e8fa83eb to your computer and use it in GitHub Desktop.
Save evandandrea/a10e06d0cc0a5311f0560804e8fa83eb to your computer and use it in GitHub Desktop.
# Repack our xz squashfses using lz4
$ unsquashfs ubuntu-core_109.snap
$ sudo mksquashfs squashfs-root ubuntu-core_109_lz4.snap -noappend -comp lz4 -no-xattrs
$ unsquashfs ubuntu-core_122.snap
$ sudo mksquashfs squashfs-root ubuntu-core_122_lz4.snap -noappend -comp lz4 -no-xattrs
# Create the delta
$ cd squashdelta
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time ./squashdelta ../ubuntu-core_109_lz4.snap ../ubuntu-core_122_lz4.snap ../ubuntu-core_lz4_109-122.squashdelta
...
./squashdelta ../ubuntu-core_109_lz4.snap ../ubuntu-core_122_lz4.snap 7.56s user 2.02s system 99% cpu 9.649 total
# Apply the delta
$ cd ../squashmerge
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time ./squashmerge ../ubuntu-core_109_lz4.snap ../ubuntu-core_lz4_109-122.squashdelta ../ubuntu-core_122_squashdelta-reconstructed.snap
./squashmerge ../ubuntu-core_109_lz4.snap 0.45s user 0.52s system 82% cpu 1.172 total
# Verify
$ cd ..
$ diff ubuntu-core_122_lz4.snap ubuntu-core_122_squashdelta-reconstructed.snap; echo $?
0
# For comparison
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time xdelta3 -v -9 -S djw -s ubuntu-core_109_lz4.snap ubuntu-core_122_lz4.snap ubuntu-core_lz4_109-122.xdelta
...
xdelta3 -v -9 -S djw -s ubuntu-core_109_lz4.snap ubuntu-core_122_lz4.snap 5.08s user 0.10s system 97% cpu 5.304 total
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time xdelta3 -d -s ubuntu-core_109_lz4.snap ubuntu-core_lz4_109-122.xdelta ubuntu-core_122_xdelta-reconstructed.snap
xdelta3 -d -s ubuntu-core_109_lz4.snap ubuntu-core_lz4_109-122.xdelta 0.19s user 0.21s system 84% cpu 0.476 total
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time bsdiff ubuntu-core_109_lz4.snap ubuntu-core_122_lz4.snap ubuntu-core_lz4_109-122.bsdiff
bsdiff ubuntu-core_109_lz4.snap ubuntu-core_122_lz4.snap 152.60s user 1.96s system 91% cpu 2:48.21 total
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time bspatch ubuntu-core_109_lz4.snap ubuntu-core_122_bspatch-reconstructed.snap ubuntu-core_lz4_109-122.bsdiff
bspatch ubuntu-core_109_lz4.snap ubuntu-core_122_bspatch-reconstructed.snap 1.46s user 0.66s system 78% cpu 2.708 total
# xz
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time xdelta3 -v -9 -S djw -s ubuntu-core_109.snap ubuntu-core_122.snap ubuntu-core_xz_109-122.xdelta
...
xdelta3 -v -9 -S djw -s ubuntu-core_109.snap ubuntu-core_122.snap 3.70s user 3.54s system 69% cpu 10.381 total
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time xdelta3 -d -s ubuntu-core_109.snap ubuntu-core_xz_109-122.xdelta ubuntu-core_122_xz_xdelta-reconstructed.snap
xdelta3 -d -s ubuntu-core_109.snap ubuntu-core_xz_109-122.xdelta 0.04s user 1.00s system 90% cpu 1.148 total
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time bsdiff ubuntu-core_109.snap ubuntu-core_122.snap ubuntu-core_xz_109-122.bsdiff
bsdiff ubuntu-core_109.snap ubuntu-core_122.snap ubuntu-core_xz_109-122.bsdif 103.02s user 8.38s system 91% cpu 2:02.21 total
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
$ time bspatch ubuntu-core_109.snap ubuntu-core_122_xz_bspatch-reconstructed.snap ubuntu-core_xz_109-122.bsdiff
bspatch ubuntu-core_109.snap ubuntu-core_122_xz_bspatch-reconstructed.snap 1.72s user 0.13s system 95% cpu 1.936 total
# Stats
$ ls -lah
-rw-r--r-- 1 ev ev 112M Jul 9 21:39 ubuntu-core_109_lz4.snap
-rw------- 1 ev ev 65M Jul 9 21:36 ubuntu-core_109.snap
-rw-r--r-- 1 ev ev 112M Jul 9 21:40 ubuntu-core_122_lz4.snap
-rw-rw-r-- 1 ev ev 112M Jul 10 00:10 ubuntu-core_122_bspatch-reconstructed.snap
-rw-rw-r-- 1 ev ev 112M Jul 9 22:16 ubuntu-core_122_squashdelta-reconstructed.snap
-rw-rw-r-- 1 ev ev 112M Jul 9 22:07 ubuntu-core_122_xdelta-reconstructed.snap
-rw-rw-r-- 1 ev ev 65M Jul 10 10:16 ubuntu-core_122_xz_bspatch-reconstructed.snap
-rw-rw-r-- 1 ev ev 65M Jul 10 10:03 ubuntu-core_122_xz_xdelta-reconstructed.snap
-rw------- 1 ev ev 65M Jul 9 21:36 ubuntu-core_122.snap
-rw-rw-r-- 1 ev ev 8.2M Jul 10 00:13 ubuntu-core_lz4_109-122.bsdiff
-rw-rw-r-- 1 ev ev 7.2M Jul 9 21:44 ubuntu-core_lz4_109-122.squashdelta
-rw-rw-r-- 1 ev ev 9.4M Jul 9 21:47 ubuntu-core_lz4_109-122.xdelta
-rw-rw-r-- 1 ev ev 18M Jul 10 10:14 ubuntu-core_xz_109-122.bsdiff
-rw-rw-r-- 1 ev ev 18M Jul 10 10:02 ubuntu-core_xz_109-122.xdelta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment