Bug 1437473 Don't cache smaller partials diffs r=mtabara
MozReview-Commit-ID: 7pYvEgRD382
--- 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