Bug 1437473 Don't cache smaller partials diffs r=mtabara draft
authorSimon Fraser <sfraser@mozilla.com>
Mon, 12 Feb 2018 11:02:17 +0000
changeset 753766 8ea798abe88d3fdea53f6e9aeaa81eb304eb1957
parent 753761 cb9b9f2707a33a1a85d5c2e74e2cd75a8afa337e
push id98673
push usersfraser@mozilla.com
push dateMon, 12 Feb 2018 11:03:49 +0000
reviewersmtabara
bugs1437473
milestone60.0a1
Bug 1437473 Don't cache smaller partials diffs r=mtabara MozReview-Commit-ID: 7pYvEgRD382
taskcluster/docker/funsize-update-generator/scripts/mbsdiff_hook.sh
--- a/taskcluster/docker/funsize-update-generator/scripts/mbsdiff_hook.sh
+++ b/taskcluster/docker/funsize-update-generator/scripts/mbsdiff_hook.sh
@@ -10,16 +10,19 @@
 
 HOOK=
 AWS_BUCKET_NAME=
 LOCAL_CACHE_DIR=
 
 S3_CACHE_HITS=0
 S3_CACHE_MISSES=0
 
+# Don't cache files smaller than this, as it's slower with S3
+# Bug 1437473
+CACHE_THRESHOLD=500000
 
 getsha512(){
     openssl sha512 "${1}" | awk '{print $2}'
 }
 
 print_usage(){
     echo "$(basename "$0") [-S S3-BUCKET-NAME] [-c LOCAL-CACHE-DIR-PATH] [-g] [-u] PATH-FROM-URL PATH-TO-URL PATH-PATCH"
     echo "Script that saves/retrieves from cache presumptive patches as args"
@@ -30,16 +33,20 @@ print_usage(){
     echo "-u post hook - upload patch to cache for future use"
     echo ""
     echo "PATH-FROM-URL     : path on disk for source file"
     echo "PATH-TO-URL       : path on disk for destination file"
     echo "PATH-PATCH        : path on disk for patch between source and destination"
 }
 
 upload_patch(){
+    if [ "$(stat -f "%z" "$2")" -lt ${CACHE_THRESHOLD} ]
+    then
+      return 0
+    fi
     sha_from=$(getsha512 "$1")
     sha_to=$(getsha512 "$2")
     patch_path="$3"
     patch_filename="$(basename "$3")"
 
     # save to local cache first
     if [ -n "$LOCAL_CACHE_DIR" ]; then
         local_cmd="mkdir -p "$LOCAL_CACHE_DIR/$sha_from""
@@ -58,16 +65,20 @@ upload_patch(){
         echo "${patch_path} failed to be uploaded to s3://${AWS_BUCKET_NAME}"
         return 1
     fi
     return 0
 }
 
 get_patch(){
     # $1 and $2 are the /path/to/filename
+    if [ "$(stat -f "%z" "$2")" -lt ${CACHE_THRESHOLD} ]
+    then
+      return 1
+    fi
     sha_from=$(getsha512 "$1")
     sha_to=$(getsha512 "$2")
     destination_file="$3"
     s3_filename="$(basename "$3")"
 
     # Try to retrieve from local cache first.
     if [ -n "$LOCAL_CACHE_DIR" ]; then
         if [ -r "$LOCAL_CACHE_DIR/$sha_from/$sha_to" ]; then