Bug 1083584, Support caching patches in funsize (partial update service), r=rstrong DONTBUILD
authorMihai Tabara <tabara.mihai@gmail.com>
Thu, 23 Oct 2014 09:52:25 +1300
changeset 211823 63f4c2e0a51acbf1ec8311da3899c3d62278e3c5
parent 211822 bc5264a31fe1f7cdd9c728f5ecc39121e7cd05a2
child 211824 c3348fa64f8b9798b3ce6e954960de584ffd31e7
push id50811
push usernthomas@mozilla.com
push dateWed, 22 Oct 2014 20:54:46 +0000
treeherdermozilla-inbound@63f4c2e0a51a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1083584
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1083584, Support caching patches in funsize (partial update service), r=rstrong DONTBUILD
tools/update-packaging/make_incremental_update.sh
--- a/tools/update-packaging/make_incremental_update.sh
+++ b/tools/update-packaging/make_incremental_update.sh
@@ -177,18 +177,43 @@ for ((i=0; $i<$num_oldfiles; i=$i+1)); d
     fi
 
     if ! diff "$olddir/$f" "$newdir/$f" > /dev/null; then
       # Compute both the compressed binary diff and the compressed file, and
       # compare the sizes.  Then choose the smaller of the two to package.
       dir=$(dirname "$workdir/$f")
       mkdir -p "$dir"
       notice "diffing \"$f\""
-      $MBSDIFF "$olddir/$f" "$newdir/$f" "$workdir/$f.patch"
-      $BZIP2 -z9 "$workdir/$f.patch"
+      # MBSDIFF_HOOK represents the communication interface with funsize and,
+      # if enabled, caches the intermediate patches for future use and
+      # compute avoidance
+      #
+      # An example of MBSDIFF_HOOK env variable could look like this:
+      # export MBSDIFF_HOOK="myscript.sh -A https://funsize/api -c /home/user"
+      # where myscript.sh has the following usage:
+      # myscript.sh -A SERVER-URL [-c LOCAL-CACHE-DIR-PATH] [-g] [-u] \
+      #   PATH-FROM-URL PATH-TO-URL PATH-PATCH SERVER-URL
+      #
+      # Note: patches are bzipped stashed in funsize to gain more speed
+
+      # if service is not enabled then default to old behavior
+      if [ -z "$MBSDIFF_HOOK" ]; then
+        $MBSDIFF "$olddir/$f" "$newdir/$f" "$workdir/$f.patch"
+        $BZIP2 -z9 "$workdir/$f.patch"
+      else
+        # if service enabled then check patch existence for retrieval
+        if $MBSDIFF_HOOK -g "$olddir/$f" "$newdir/$f" "$workdir/$f.patch.bz2"; then
+          notice "file \"$f\" found in funsize, diffing skipped"
+        else
+          # if not found already - compute it and cache it for future use
+          $MBSDIFF "$olddir/$f" "$newdir/$f" "$workdir/$f.patch"
+          $BZIP2 -z9 "$workdir/$f.patch"
+          $MBSDIFF_HOOK -u "$olddir/$f" "$newdir/$f" "$workdir/$f.patch.bz2"
+        fi
+      fi
       $BZIP2 -cz9 "$newdir/$f" > "$workdir/$f"
       copy_perm "$newdir/$f" "$workdir/$f"
       patchfile="$workdir/$f.patch.bz2"
       patchsize=$(get_file_size "$patchfile")
       fullsize=$(get_file_size "$workdir/$f")
 
       if [ $patchsize -lt $fullsize ]; then
         make_patch_instruction "$f" "$updatemanifestv2" "$updatemanifestv3"