summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2022-08-22 09:17:21 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2022-08-23 16:23:39 +0200
commit5c6c4b68e569037d4548ee1f2eae39033cd5f9ca (patch)
treea8dd56dff00a1deb56029ca528f18f1262a9a408
parent459dcf165dedc708571aa764e112c193f135ced1 (diff)
downloadlibtota-5c6c4b68e569037d4548ee1f2eae39033cd5f9ca.tar.gz
libtota-5c6c4b68e569037d4548ee1f2eae39033cd5f9ca.tar.bz2
libtota-5c6c4b68e569037d4548ee1f2eae39033cd5f9ca.zip
ss_bsdiff: Change the logic of timing out when creating deltas.
Patch is created with score = 8. If the action does not finish within 4 hours, the creation is aborted and started with score = 4 without timeout. Change-Id: I83f1d2cc356b419f81717d2983444d22e97d7b85
-rwxr-xr-xbsdiff/ss_bsdiff.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/bsdiff/ss_bsdiff.c b/bsdiff/ss_bsdiff.c
index a01aa89..b153a73 100755
--- a/bsdiff/ss_bsdiff.c
+++ b/bsdiff/ss_bsdiff.c
@@ -57,7 +57,7 @@
#define CONST_MEMORY_USAGE 16384 // patch in m+O(1); m=size of new file; use only const memory for old file at patch side;
#define PATCH_FILE_FORMAT_MOD // no accumulation of diff and extra in db and eb; immediate write; also write all 3 parts of control stmt at same time
#define MULTI_THREADING 1 // only with #define CONST_MEMORY_USAGE or #define MAX_MATCH_SIZE
-#define TIME_LIMIT_CHECK 300 // After TIME_LIMIT_CHECK seconds, new diff will be created with smaller score argument
+#define TIME_LIMIT_CHECK 4*60*60 // After TIME_LIMIT_CHECK seconds, new diff will be created with smaller score argument
#define TEMP_PATCH_NAME "temp_patch"
#define BROTLI_COMPRESSION_QUALITY 9
#define ITERATIONS_COMPLETED 10 // After ITERATIONS_COMPLETED iterations elapsed time will be checked. Increasing it can cause the program to run longer than expected
@@ -371,7 +371,7 @@ int Function(int offset_oldscore)
(data.old[scsc + lastoffset] == data.new[thread_num][scsc]))
oldscore++;
#ifdef TIME_LIMIT_CHECK
- if (offset_oldscore != 0) // when offset_oldscore is 0 we have to make sure diff is created no mater what, so we can't timeout
+ if (offset_oldscore > 4) // when offset_oldscore is 4 and less we have to make sure diff is created no mater what, so we can't timeout
outer_count++;
if (outer_count > ITERATIONS_COMPLETED) {
outer_count = 0;
@@ -744,14 +744,13 @@ int MY_CDECL main(int argc, char *argv[])
int ret = create_patch(info.old_file, info.new_file, TEMP_PATCH_NAME, 8);
#ifdef TIME_LIMIT_CHECK
- /*
- * Creating a patch with an offset score equal to 8 may take too long. On
- * the other hand for a value of 2 the resulting patch will consist of
- * multiple blocks, which can significantly increase the application time.
- * Therefore this commit adds two intermediate steps as a compromise
- * solution.
- */
- for (int score = 6; score >= 0 && ret != 0; score-=2) {
+ if (ret != 0) {
+ /*
+ * Creating a patch with an offset score equal to 8 may take too long
+ * Therefore after a certain amount of time, patch creation is aborted
+ * and we run again with the score equal to 4.
+ */
+ int score = 4;
printf("Trying with offset score %d\n", score);
ret = create_patch(info.old_file, info.new_file, TEMP_PATCH_NAME, score);
}