diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2007-02-11 02:16:27 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2007-02-11 02:16:27 +0000 |
commit | a5f03073f9a5ce6f25255566803f9ad9fcf1c469 (patch) | |
tree | 5d4447b2d0b7995cdfebc7a005c17e52f7fab0f8 | |
parent | e6a4d603ed05dd9d7e04311ef351700b60852dae (diff) |
Fixes bugs in XDELTA environment variable.
Removes stream.srcwin_size variable, uses stream.src->blksize instead, to address performance regression from xdelta1. Changes the order of checksum computation to be like xdelta1, insert checksums in reverse to give preference to earlier matches.
Removes svn:executable from files.
-rw-r--r--[-rwxr-xr-x] | xdelta3/COPYING | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/Makefile | 17 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/README | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/badcopy.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/draft-korn-vcdiff.txt | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/linkxd3lib.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/rcs_junk.cc | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/releases/xdelta30h.ppc-osx.bin | bin | 147404 -> 147404 bytes | |||
-rw-r--r--[-rwxr-xr-x] | xdelta3/releases/xdelta30n.tar.gz | bin | 158197 -> 158197 bytes | |||
-rw-r--r--[-rwxr-xr-x] | xdelta3/releases/xdelta30n.x86-32.exe | bin | 102400 -> 102400 bytes | |||
-rw-r--r--[-rwxr-xr-x] | xdelta3/releases/xdelta30o.tar.gz | bin | 177573 -> 177573 bytes | |||
-rw-r--r--[-rwxr-xr-x] | xdelta3/setup.py | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-cfgs.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-decode.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-djw.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-fgk.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-list.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-main.h | 52 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-python.h | 0 | ||||
-rwxr-xr-x | xdelta3/xdelta3-regtest.py | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-second.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3-test.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3.c | 82 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3.h | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3.prj | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3.swig | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | xdelta3/xdelta3.vcproj | 0 |
27 files changed, 104 insertions, 58 deletions
diff --git a/xdelta3/COPYING b/xdelta3/COPYING index 5b6e7c6..5b6e7c6 100755..100644 --- a/xdelta3/COPYING +++ b/xdelta3/COPYING | |||
diff --git a/xdelta3/Makefile b/xdelta3/Makefile index ea48055..cb79e64 100755..100644 --- a/xdelta3/Makefile +++ b/xdelta3/Makefile | |||
@@ -30,22 +30,22 @@ TARGETS = xdelta3-debug \ | |||
30 | xdelta3-nosec.o xdelta3-all.o xdelta3-fgk.o \ | 30 | xdelta3-nosec.o xdelta3-all.o xdelta3-fgk.o \ |
31 | xdelta3-noext xdelta3-tools xdelta3-tune \ | 31 | xdelta3-noext xdelta3-tools xdelta3-tune \ |
32 | xdelta3-notools \ | 32 | xdelta3-notools \ |
33 | $(PYTGT) \ | 33 | xdelta3_wrap.c xdelta3.py \ |
34 | $(PYTGT) $(SWIGTGT) | ||
34 | 35 | ||
35 | PYTHON = python | 36 | PYTHON = python |
36 | 37 | ||
37 | PYTGT = build/lib.linux-i686-2.4/xdelta3.so | 38 | SWIGTGT = xdelta3module.so |
38 | #PYTGT = build/lib.cygwin-1.5.24-i686-2.4/xdelta3main.dll | 39 | SWIGTGT = xdelta3module.dll |
39 | 40 | ||
40 | PYFILES = xdelta3-regtest.py setup.py | 41 | PYTGT = build/lib.linux-i686-2.4/xdelta3.so |
42 | PYTGT = build/lib.cygwin-1.5.24-i686-2.4/xdelta3main.dll | ||
41 | 43 | ||
42 | EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \ | 44 | EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \ |
43 | draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \ | 45 | draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \ |
46 | xdelta3-regtest.py xdelta3-test.py setup.py \ | ||
44 | xdelta3.py xdelta3_wrap.c | 47 | xdelta3.py xdelta3_wrap.c |
45 | 48 | ||
46 | SWIGTGT = xdelta3module.so | ||
47 | #SWIGTGT = xdelta3module.dll | ||
48 | |||
49 | SWIG_FLAGS = -DXD3_DEBUG=0 \ | 49 | SWIG_FLAGS = -DXD3_DEBUG=0 \ |
50 | -DXD3_USE_LARGEFILE64=1 \ | 50 | -DXD3_USE_LARGEFILE64=1 \ |
51 | -DSECONDARY_DJW=1 \ | 51 | -DSECONDARY_DJW=1 \ |
@@ -80,7 +80,8 @@ tar: | |||
80 | 80 | ||
81 | clean: | 81 | clean: |
82 | rm -f $(TARGETS) | 82 | rm -f $(TARGETS) |
83 | rm -rf build Debug Release | 83 | rm -rf build Debug Release core *.stackdump *.exe \ |
84 | xdelta3.ncb xdelta3.suo xdelta3.sln | ||
84 | 85 | ||
85 | xdelta3: $(SOURCES) | 86 | xdelta3: $(SOURCES) |
86 | $(CC) -O3 -Wall -Wshadow xdelta3.c -lm -o xdelta3 \ | 87 | $(CC) -O3 -Wall -Wshadow xdelta3.c -lm -o xdelta3 \ |
diff --git a/xdelta3/README b/xdelta3/README index b139f7e..b139f7e 100755..100644 --- a/xdelta3/README +++ b/xdelta3/README | |||
diff --git a/xdelta3/badcopy.c b/xdelta3/badcopy.c index 03abc63..03abc63 100755..100644 --- a/xdelta3/badcopy.c +++ b/xdelta3/badcopy.c | |||
diff --git a/xdelta3/draft-korn-vcdiff.txt b/xdelta3/draft-korn-vcdiff.txt index 1487deb..1487deb 100755..100644 --- a/xdelta3/draft-korn-vcdiff.txt +++ b/xdelta3/draft-korn-vcdiff.txt | |||
diff --git a/xdelta3/linkxd3lib.c b/xdelta3/linkxd3lib.c index 6064467..6064467 100755..100644 --- a/xdelta3/linkxd3lib.c +++ b/xdelta3/linkxd3lib.c | |||
diff --git a/xdelta3/rcs_junk.cc b/xdelta3/rcs_junk.cc index ac49644..ac49644 100755..100644 --- a/xdelta3/rcs_junk.cc +++ b/xdelta3/rcs_junk.cc | |||
diff --git a/xdelta3/releases/xdelta30h.ppc-osx.bin b/xdelta3/releases/xdelta30h.ppc-osx.bin index 7ce8f0d..7ce8f0d 100755..100644 --- a/xdelta3/releases/xdelta30h.ppc-osx.bin +++ b/xdelta3/releases/xdelta30h.ppc-osx.bin | |||
Binary files differ | |||
diff --git a/xdelta3/releases/xdelta30n.tar.gz b/xdelta3/releases/xdelta30n.tar.gz index 66fadb4..66fadb4 100755..100644 --- a/xdelta3/releases/xdelta30n.tar.gz +++ b/xdelta3/releases/xdelta30n.tar.gz | |||
Binary files differ | |||
diff --git a/xdelta3/releases/xdelta30n.x86-32.exe b/xdelta3/releases/xdelta30n.x86-32.exe index cd96077..cd96077 100755..100644 --- a/xdelta3/releases/xdelta30n.x86-32.exe +++ b/xdelta3/releases/xdelta30n.x86-32.exe | |||
Binary files differ | |||
diff --git a/xdelta3/releases/xdelta30o.tar.gz b/xdelta3/releases/xdelta30o.tar.gz index b2de57b..b2de57b 100755..100644 --- a/xdelta3/releases/xdelta30o.tar.gz +++ b/xdelta3/releases/xdelta30o.tar.gz | |||
Binary files differ | |||
diff --git a/xdelta3/setup.py b/xdelta3/setup.py index d7f11c4..d7f11c4 100755..100644 --- a/xdelta3/setup.py +++ b/xdelta3/setup.py | |||
diff --git a/xdelta3/xdelta3-cfgs.h b/xdelta3/xdelta3-cfgs.h index c48df9f..c48df9f 100755..100644 --- a/xdelta3/xdelta3-cfgs.h +++ b/xdelta3/xdelta3-cfgs.h | |||
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h index b1b5b88..b1b5b88 100755..100644 --- a/xdelta3/xdelta3-decode.h +++ b/xdelta3/xdelta3-decode.h | |||
diff --git a/xdelta3/xdelta3-djw.h b/xdelta3/xdelta3-djw.h index deff7cb..deff7cb 100755..100644 --- a/xdelta3/xdelta3-djw.h +++ b/xdelta3/xdelta3-djw.h | |||
diff --git a/xdelta3/xdelta3-fgk.h b/xdelta3/xdelta3-fgk.h index 34ee3ca..34ee3ca 100755..100644 --- a/xdelta3/xdelta3-fgk.h +++ b/xdelta3/xdelta3-fgk.h | |||
diff --git a/xdelta3/xdelta3-list.h b/xdelta3/xdelta3-list.h index 8d49e45..8d49e45 100755..100644 --- a/xdelta3/xdelta3-list.h +++ b/xdelta3/xdelta3-list.h | |||
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 1552809..7ccd63b 100755..100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -346,7 +346,6 @@ main_config (void) | |||
346 | P(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE); | 346 | P(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE); |
347 | P(RINT "XD3_DEBUG=%d\n", XD3_DEBUG); | 347 | P(RINT "XD3_DEBUG=%d\n", XD3_DEBUG); |
348 | P(RINT "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL); | 348 | P(RINT "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL); |
349 | P(RINT "XD3_DEFAULT_CKSUM_SIZE=%d\n", XD3_DEFAULT_CKSUM_ADVANCE); | ||
350 | P(RINT "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE); | 349 | P(RINT "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE); |
351 | P(RINT "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ); | 350 | P(RINT "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ); |
352 | P(RINT "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ); | 351 | P(RINT "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ); |
@@ -742,7 +741,13 @@ main_file_open (main_file *xfile, const char* name, int mode) | |||
742 | 741 | ||
743 | xfile->mode = mode; | 742 | xfile->mode = mode; |
744 | 743 | ||
744 | XD3_ASSERT (name != NULL); | ||
745 | XD3_ASSERT (! main_file_isopen (xfile)); | 745 | XD3_ASSERT (! main_file_isopen (xfile)); |
746 | if (name[0] == 0) | ||
747 | { | ||
748 | XPR(NT "invalid file name: empty string\n"); | ||
749 | return XD3_INVALID; | ||
750 | } | ||
746 | 751 | ||
747 | #if XD3_STDIO | 752 | #if XD3_STDIO |
748 | xfile->file = fopen (name, XOPEN_STDIO); | 753 | xfile->file = fopen (name, XOPEN_STDIO); |
@@ -1840,6 +1845,12 @@ main_get_appheader_params (main_file *file, char **parsed, int output, const cha | |||
1840 | 1845 | ||
1841 | if (other->filename != NULL) { | 1846 | if (other->filename != NULL) { |
1842 | /* Take directory from the other file, if it has one. */ | 1847 | /* Take directory from the other file, if it has one. */ |
1848 | /* TODO: This results in nonsense names like /dev/foo.tar.gz | ||
1849 | * and probably the filename-default logic interferes with | ||
1850 | * multi-file operation and the standard file extension? | ||
1851 | * Possibly the name header is bad, should be off by default. | ||
1852 | * Possibly we just want to remember external/compression | ||
1853 | * settings. */ | ||
1843 | char *last_slash = strrchr(other->filename, '/'); | 1854 | char *last_slash = strrchr(other->filename, '/'); |
1844 | 1855 | ||
1845 | if (last_slash != NULL) { | 1856 | if (last_slash != NULL) { |
@@ -2029,17 +2040,25 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour | |||
2029 | sfile->nread = 0; | 2040 | sfile->nread = 0; |
2030 | source->size = UINT64_MAX; | 2041 | source->size = UINT64_MAX; |
2031 | } | 2042 | } |
2032 | else if ((ret = main_file_open (sfile, sfile->filename, XO_READ)) || | 2043 | else |
2033 | (ret = main_file_stat (sfile, & source->size, 1))) | ||
2034 | { | 2044 | { |
2035 | goto error; | 2045 | if (option_verbose) |
2046 | { | ||
2047 | XPR(NT "source file: %s\n", sfile->filename); | ||
2048 | } | ||
2049 | |||
2050 | if ((ret = main_file_open (sfile, sfile->filename, XO_READ)) || | ||
2051 | (ret = main_file_stat (sfile, & source->size, 1))) | ||
2052 | { | ||
2053 | goto error; | ||
2054 | } | ||
2036 | } | 2055 | } |
2037 | 2056 | ||
2038 | source->name = sfile->filename; | 2057 | source->name = sfile->filename; |
2039 | source->ioh = sfile; | 2058 | source->ioh = sfile; |
2040 | source->curblkno = (xoff_t) -1; | 2059 | source->curblkno = (xoff_t) -1; |
2041 | source->curblk = NULL; | 2060 | source->curblk = NULL; |
2042 | 2061 | ||
2043 | #if EXTERNAL_COMPRESSION | 2062 | #if EXTERNAL_COMPRESSION |
2044 | if (option_decompress_inputs) | 2063 | if (option_decompress_inputs) |
2045 | { | 2064 | { |
@@ -2650,7 +2669,7 @@ main_input (xd3_cmd cmd, | |||
2650 | } | 2669 | } |
2651 | 2670 | ||
2652 | /* Limited instruction buffer size affects source copies */ | 2671 | /* Limited instruction buffer size affects source copies */ |
2653 | if (stream.i_slots_used > stream.iopt_size) | 2672 | if (option_verbose > 1 && stream.i_slots_used > stream.iopt_size) |
2654 | { | 2673 | { |
2655 | XPR(NT "warning: input position %"Q"u overflowed instruction buffer, " | 2674 | XPR(NT "warning: input position %"Q"u overflowed instruction buffer, " |
2656 | "needed %u (vs. %u)\n", | 2675 | "needed %u (vs. %u)\n", |
@@ -2831,7 +2850,7 @@ setup_environment (int argc, | |||
2831 | (*env_free) = main_malloc(strlen(v) + 1); | 2850 | (*env_free) = main_malloc(strlen(v) + 1); |
2832 | strcpy(*env_free, v); | 2851 | strcpy(*env_free, v); |
2833 | 2852 | ||
2834 | /* Space needed for new argv: count spaces */ | 2853 | /* Space needed for extra args, at least # of spaces */ |
2835 | n = argc + 1; | 2854 | n = argc + 1; |
2836 | for (p = *env_free; *p != 0; ) { | 2855 | for (p = *env_free; *p != 0; ) { |
2837 | if (*p++ == ' ') { | 2856 | if (*p++ == ' ') { |
@@ -2839,7 +2858,6 @@ setup_environment (int argc, | |||
2839 | } | 2858 | } |
2840 | } | 2859 | } |
2841 | 2860 | ||
2842 | (*argc_out) = n; | ||
2843 | (*argv_free) = main_malloc(sizeof(char*) * (n + 1)); | 2861 | (*argv_free) = main_malloc(sizeof(char*) * (n + 1)); |
2844 | (*argv_out) = (*argv_free); | 2862 | (*argv_out) = (*argv_free); |
2845 | (*argv_out)[0] = argv[0]; | 2863 | (*argv_out)[0] = argv[0]; |
@@ -2851,7 +2869,7 @@ setup_environment (int argc, | |||
2851 | while (*p != ' ' && *p != 0) { | 2869 | while (*p != ' ' && *p != 0) { |
2852 | p++; | 2870 | p++; |
2853 | } | 2871 | } |
2854 | if (*p == ' ') { | 2872 | while (*p == ' ') { |
2855 | *p++ = 0; | 2873 | *p++ = 0; |
2856 | } | 2874 | } |
2857 | } | 2875 | } |
@@ -2860,7 +2878,11 @@ setup_environment (int argc, | |||
2860 | (*argv_out)[i++] = argv[i0]; | 2878 | (*argv_out)[i++] = argv[i0]; |
2861 | } | 2879 | } |
2862 | 2880 | ||
2863 | XD3_ASSERT (i == n); | 2881 | /* Counting spaces is an upper bound, argv stays NULL terminated. */ |
2882 | (*argc_out) = i; | ||
2883 | while (i <= n) { | ||
2884 | (*argv_out)[i++] = NULL; | ||
2885 | } | ||
2864 | } | 2886 | } |
2865 | 2887 | ||
2866 | int | 2888 | int |
@@ -2881,8 +2903,8 @@ main (int argc, char **argv) | |||
2881 | char *sfilename; | 2903 | char *sfilename; |
2882 | int env_argc; | 2904 | int env_argc; |
2883 | char **env_argv; | 2905 | char **env_argv; |
2884 | char **free_argv; /* malloced */ | 2906 | char **free_argv; /* malloc() in setup_environment() */ |
2885 | char *free_value; /* malloced */ | 2907 | char *free_value; /* malloc() in setup_environment() */ |
2886 | int ret; | 2908 | int ret; |
2887 | 2909 | ||
2888 | #ifdef _WIN32 | 2910 | #ifdef _WIN32 |
@@ -3248,7 +3270,7 @@ main (int argc, char **argv) | |||
3248 | static int | 3270 | static int |
3249 | main_help (void) | 3271 | main_help (void) |
3250 | { | 3272 | { |
3251 | /* TODO: update www/xdelta3-cmdline.html */ | 3273 | /* Note: update wiki when command-line features change */ |
3252 | main_version (); | 3274 | main_version (); |
3253 | P(RINT "usage: xdelta3 [command/options] [input [output]]\n"); | 3275 | P(RINT "usage: xdelta3 [command/options] [input [output]]\n"); |
3254 | P(RINT "special command names:\n"); | 3276 | P(RINT "special command names:\n"); |
@@ -3296,5 +3318,9 @@ main_help (void) | |||
3296 | P(RINT " -P repeat count (for profiling)\n"); | 3318 | P(RINT " -P repeat count (for profiling)\n"); |
3297 | P(RINT " -T use alternate code table\n"); | 3319 | P(RINT " -T use alternate code table\n"); |
3298 | #endif | 3320 | #endif |
3321 | P(RINT "the XDELTA environment variable may contain extra args:\n"); | ||
3322 | P(RINT " XDELTA=\"-s source-x.y.tar.gz\" \\\n"); | ||
3323 | P(RINT " tar --use-compress-program=xdelta3 \\\n"); | ||
3324 | P(RINT " -cf target-x.z.tar.gz.vcdiff target-x.y/\n"); | ||
3299 | return EXIT_FAILURE; | 3325 | return EXIT_FAILURE; |
3300 | } | 3326 | } |
diff --git a/xdelta3/xdelta3-python.h b/xdelta3/xdelta3-python.h index a91b7f2..a91b7f2 100755..100644 --- a/xdelta3/xdelta3-python.h +++ b/xdelta3/xdelta3-python.h | |||
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py index db6f06f..928a5f0 100755 --- a/xdelta3/xdelta3-regtest.py +++ b/xdelta3/xdelta3-regtest.py | |||
@@ -85,6 +85,8 @@ def INPUT_SPEC(rand): | |||
85 | RCSDIR = '/tmp/PRCS_read_copy' | 85 | RCSDIR = '/tmp/PRCS_read_copy' |
86 | #RCSDIR = 'G:/jmacd/PRCS' | 86 | #RCSDIR = 'G:/jmacd/PRCS' |
87 | 87 | ||
88 | SAMPLEDIR = "C:/sample_data/WESNOTH_tmp/tar' | ||
89 | |||
88 | TMPDIR = '/tmp/xd3regtest.%d' % os.getpid() | 90 | TMPDIR = '/tmp/xd3regtest.%d' % os.getpid() |
89 | 91 | ||
90 | RUNFILE = os.path.join(TMPDIR, 'run') | 92 | RUNFILE = os.path.join(TMPDIR, 'run') |
diff --git a/xdelta3/xdelta3-second.h b/xdelta3/xdelta3-second.h index c64ffe0..c64ffe0 100755..100644 --- a/xdelta3/xdelta3-second.h +++ b/xdelta3/xdelta3-second.h | |||
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h index f4d5972..f4d5972 100755..100644 --- a/xdelta3/xdelta3-test.h +++ b/xdelta3/xdelta3-test.h | |||
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 4e40ba4..cc11f5b 100755..100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -1197,7 +1197,6 @@ int xd3_compute_code_table_encoding (xd3_stream *in_stream, const xd3_dinst *cod | |||
1197 | 1197 | ||
1198 | /* Be exhaustive. */ | 1198 | /* Be exhaustive. */ |
1199 | config.sprevsz = 1<<11; | 1199 | config.sprevsz = 1<<11; |
1200 | config.srcwin_size = CODE_TABLE_STRING_SIZE; | ||
1201 | config.srcwin_maxsz = CODE_TABLE_STRING_SIZE; | 1200 | config.srcwin_maxsz = CODE_TABLE_STRING_SIZE; |
1202 | 1201 | ||
1203 | config.smatch_cfg = XD3_SMATCH_SOFT; | 1202 | config.smatch_cfg = XD3_SMATCH_SOFT; |
@@ -2416,15 +2415,17 @@ xd3_config_stream(xd3_stream *stream, | |||
2416 | 2415 | ||
2417 | stream->winsize = config->winsize ? config->winsize : XD3_DEFAULT_WINSIZE; | 2416 | stream->winsize = config->winsize ? config->winsize : XD3_DEFAULT_WINSIZE; |
2418 | stream->sprevsz = config->sprevsz ? config->sprevsz : XD3_DEFAULT_SPREVSZ; | 2417 | stream->sprevsz = config->sprevsz ? config->sprevsz : XD3_DEFAULT_SPREVSZ; |
2419 | stream->iopt_size = config->iopt_size ? config->iopt_size : XD3_DEFAULT_IOPT_SIZE; | ||
2420 | stream->srcwin_size = config->srcwin_size ? config->srcwin_size : XD3_DEFAULT_CKSUM_ADVANCE; | ||
2421 | stream->srcwin_maxsz = config->srcwin_maxsz ? config->srcwin_maxsz : XD3_DEFAULT_SRCWINSZ; | 2418 | stream->srcwin_maxsz = config->srcwin_maxsz ? config->srcwin_maxsz : XD3_DEFAULT_SRCWINSZ; |
2422 | 2419 | ||
2423 | if (stream->iopt_size == 0) | 2420 | if (config->iopt_size == 0) |
2424 | { | 2421 | { |
2425 | stream->iopt_size = XD3_ALLOCSIZE / sizeof(xd3_rinst); | 2422 | stream->iopt_size = XD3_ALLOCSIZE / sizeof(xd3_rinst); |
2426 | stream->iopt_unlimited = 1; | 2423 | stream->iopt_unlimited = 1; |
2427 | } | 2424 | } |
2425 | else | ||
2426 | { | ||
2427 | stream->iopt_size = XD3_DEFAULT_IOPT_SIZE; | ||
2428 | } | ||
2428 | 2429 | ||
2429 | stream->getblk = config->getblk; | 2430 | stream->getblk = config->getblk; |
2430 | stream->alloc = config->alloc ? config->alloc : __xd3_alloc_func; | 2431 | stream->alloc = config->alloc ? config->alloc : __xd3_alloc_func; |
@@ -4210,7 +4211,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
4210 | { | 4211 | { |
4211 | *next_move_point = stream->input_position + | 4212 | *next_move_point = stream->input_position + |
4212 | (usize_t)(stream->srcwin_cksum_pos - logical_input_cksum_pos); | 4213 | (usize_t)(stream->srcwin_cksum_pos - logical_input_cksum_pos); |
4213 | return 0; | 4214 | goto finished; |
4214 | } | 4215 | } |
4215 | 4216 | ||
4216 | /* If the stream has matched beyond the srcwin_cksum_pos (good), we shouldn't | 4217 | /* If the stream has matched beyond the srcwin_cksum_pos (good), we shouldn't |
@@ -4225,8 +4226,21 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
4225 | logical_input_cksum_pos = stream->srcwin_cksum_pos; | 4226 | logical_input_cksum_pos = stream->srcwin_cksum_pos; |
4226 | } | 4227 | } |
4227 | 4228 | ||
4228 | /* Advance an extra srcwin_size bytes */ | 4229 | /* Advance at least one source block. For the command-line, this |
4229 | logical_input_cksum_pos += stream->srcwin_size; | 4230 | * means we read to EOF for files smaller than the source window. |
4231 | * Note that this term (stream->src->blksize) is used again below. | ||
4232 | * | ||
4233 | * TODO: This is possibly a post-3.0o performance regression. I | ||
4234 | * have examples of files that perform better w/ xdelta1. Note that | ||
4235 | * xdelta1 fills its cksum table in reverse so that earlier matches | ||
4236 | * are preferred. Note that xdelta3 is designed to avoid | ||
4237 | * unnecessary computation, which this might be if we have long | ||
4238 | * matches ahead. OTOH, sometimes tar scrambles a file such that you | ||
4239 | * copy from the end to the beginning right away, and this logic at | ||
4240 | * least helps those cases. Used to use 16K here, instead of | ||
4241 | * stream->src->blksize. | ||
4242 | */ | ||
4243 | logical_input_cksum_pos += stream->src->blksize; | ||
4230 | 4244 | ||
4231 | IF_DEBUG1 (P(RINT "[srcwin_move_point] T=%"Q"u S=%"Q"u/%"Q"u\n", | 4245 | IF_DEBUG1 (P(RINT "[srcwin_move_point] T=%"Q"u S=%"Q"u/%"Q"u\n", |
4232 | stream->total_in + stream->input_position, | 4246 | stream->total_in + stream->input_position, |
@@ -4240,7 +4254,6 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
4240 | usize_t blkoff = stream->srcwin_cksum_pos % stream->src->blksize; | 4254 | usize_t blkoff = stream->srcwin_cksum_pos % stream->src->blksize; |
4241 | usize_t onblk = xd3_bytes_on_srcblk (stream->src, blkno); | 4255 | usize_t onblk = xd3_bytes_on_srcblk (stream->src, blkno); |
4242 | int ret; | 4256 | int ret; |
4243 | int diff; | ||
4244 | 4257 | ||
4245 | if (blkoff + stream->smatcher.large_look > onblk) | 4258 | if (blkoff + stream->smatcher.large_look > onblk) |
4246 | { | 4259 | { |
@@ -4258,34 +4271,44 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
4258 | return ret; | 4271 | return ret; |
4259 | } | 4272 | } |
4260 | 4273 | ||
4261 | onblk -= stream->smatcher.large_look; | 4274 | /* Note: I experimented with rewriting this block to use |
4262 | diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; | 4275 | * LARGE_CKSUM_UPDATE() instead of recalculating the cksum every |
4263 | onblk = min(blkoff + diff, onblk); | 4276 | * N bytes. It seemed to make performance worse (except |
4264 | 4277 | * obviously for step == 1, not worth extra complexity). | |
4265 | /* Note: I experimented with rewriting this block to use LARGE_CKSUM_UPDATE() | 4278 | * |
4266 | * instead of recalculating the cksum every N bytes. It seemed to make performance | 4279 | * Prior to 3.0p, this loop inserted cksums forwards, now it |
4267 | * worse (except obviously for step == 1, not worth extra complexity) */ | 4280 | * goes in reverse like xdelta1. */ |
4268 | while (blkoff <= onblk) | 4281 | while (onblk >= stream->smatcher.large_step && |
4282 | onblk >= stream->smatcher.large_look) | ||
4269 | { | 4283 | { |
4270 | /* It's a big win to have the compiler optimize this loop w/ fi. */ | 4284 | onblk -= stream->smatcher.large_step; |
4271 | uint32_t cksum = xd3_lcksum (stream->src->curblk + blkoff, stream->smatcher.large_look); | ||
4272 | usize_t hval = xd3_checksum_hash (& stream->large_hash, cksum); | ||
4273 | 4285 | ||
4274 | stream->large_table[hval] = stream->srcwin_cksum_pos + HASH_CKOFFSET; | 4286 | uint32_t cksum = xd3_lcksum (stream->src->curblk + onblk, |
4287 | stream->smatcher.large_look); | ||
4288 | usize_t hval = xd3_checksum_hash (& stream->large_hash, cksum); | ||
4275 | 4289 | ||
4276 | blkoff += stream->smatcher.large_step; | 4290 | /* TODO: can you simplify this computation? */ |
4277 | stream->srcwin_cksum_pos += stream->smatcher.large_step; | 4291 | stream->large_table[hval] = (stream->src->blksize * blkno + onblk) + HASH_CKOFFSET; |
4278 | 4292 | ||
4279 | IF_DEBUG (stream->large_ckcnt += 1); | 4293 | IF_DEBUG (stream->large_ckcnt += 1); |
4280 | } | 4294 | } |
4295 | |||
4296 | stream->srcwin_cksum_pos = (blkno + 1) * stream->src->blksize; | ||
4281 | } | 4297 | } |
4282 | 4298 | ||
4283 | if (stream->srcwin_cksum_pos > stream->src->size) { | 4299 | if (stream->srcwin_cksum_pos > stream->src->size) |
4284 | // We do this so the xd3_source_cksum_offset() function, which uses the high/low | 4300 | { |
4285 | // 32-bits of srcwin_cksum_pos, is guaranteed never to return a position > src->size | 4301 | /* We do this so the xd3_source_cksum_offset() function, which |
4286 | stream->srcwin_cksum_pos = stream->src->size; | 4302 | * uses the high/low 32-bits of srcwin_cksum_pos, is guaranteed |
4287 | } | 4303 | * never to return a position > src->size */ |
4288 | *next_move_point = stream->input_position + stream->srcwin_size; | 4304 | stream->srcwin_cksum_pos = stream->src->size; |
4305 | } | ||
4306 | |||
4307 | finished: | ||
4308 | /* How long until this function should be called again. */ | ||
4309 | /* TODO: Ack, this logic is underflowing the usize_t */ | ||
4310 | *next_move_point = stream->input_position + | ||
4311 | (usize_t)(stream->srcwin_cksum_pos - logical_input_cksum_pos); | ||
4289 | return 0; | 4312 | return 0; |
4290 | } | 4313 | } |
4291 | 4314 | ||
@@ -4895,7 +4918,8 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream) | |||
4895 | usize_t next_move_point; | 4918 | usize_t next_move_point; |
4896 | 4919 | ||
4897 | /* If there will be no compression due to settings or short input, skip it entirely. */ | 4920 | /* If there will be no compression due to settings or short input, skip it entirely. */ |
4898 | if (! (DO_SMALL || DO_LARGE || DO_RUN) || stream->input_position + SLOOK > stream->avail_in) { goto loopnomore; } | 4921 | if (! (DO_SMALL || DO_LARGE || DO_RUN) || |
4922 | stream->input_position + SLOOK > stream->avail_in) { goto loopnomore; } | ||
4899 | 4923 | ||
4900 | if ((ret = xd3_string_match_init (stream))) { return ret; } | 4924 | if ((ret = xd3_string_match_init (stream))) { return ret; } |
4901 | 4925 | ||
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index e6c9e20..8c11000 100755..100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -38,11 +38,6 @@ | |||
38 | #define XD3_DEFAULT_WINSIZE (1U << 18) | 38 | #define XD3_DEFAULT_WINSIZE (1U << 18) |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | /* This is a unit of how far to advance the checksum position in one go. */ | ||
42 | #ifndef XD3_DEFAULT_CKSUM_ADVANCE | ||
43 | #define XD3_DEFAULT_CKSUM_ADVANCE (1U << 14) | ||
44 | #endif | ||
45 | |||
46 | /* Default total size of the source window used in xdelta3-main.h */ | 41 | /* Default total size of the source window used in xdelta3-main.h */ |
47 | #ifndef XD3_DEFAULT_SRCWINSZ | 42 | #ifndef XD3_DEFAULT_SRCWINSZ |
48 | #define XD3_DEFAULT_SRCWINSZ (1U << 26) | 43 | #define XD3_DEFAULT_SRCWINSZ (1U << 26) |
@@ -583,7 +578,6 @@ struct _xd3_config | |||
583 | usize_t winsize; /* The encoder window size. */ | 578 | usize_t winsize; /* The encoder window size. */ |
584 | usize_t sprevsz; /* How far back small string matching goes */ | 579 | usize_t sprevsz; /* How far back small string matching goes */ |
585 | usize_t iopt_size; /* entries in the instruction-optimizing buffer */ | 580 | usize_t iopt_size; /* entries in the instruction-optimizing buffer */ |
586 | usize_t srcwin_size; /* Initial size of the source-window lookahead */ | ||
587 | usize_t srcwin_maxsz; /* srcwin_size grows by a factor of 2 when no matches are found */ | 581 | usize_t srcwin_maxsz; /* srcwin_size grows by a factor of 2 when no matches are found */ |
588 | 582 | ||
589 | xd3_getblk_func *getblk; /* The three callbacks. */ | 583 | xd3_getblk_func *getblk; /* The three callbacks. */ |
@@ -657,7 +651,6 @@ struct _xd3_stream | |||
657 | usize_t sprevmask; /* small string, previous window size mask */ | 651 | usize_t sprevmask; /* small string, previous window size mask */ |
658 | uint iopt_size; | 652 | uint iopt_size; |
659 | uint iopt_unlimited; | 653 | uint iopt_unlimited; |
660 | uint srcwin_size; | ||
661 | uint srcwin_maxsz; | 654 | uint srcwin_maxsz; |
662 | 655 | ||
663 | /* general configuration */ | 656 | /* general configuration */ |
@@ -693,7 +686,7 @@ struct _xd3_stream | |||
693 | * match in the buffer. */ | 686 | * match in the buffer. */ |
694 | 687 | ||
695 | // SRCWIN | 688 | // SRCWIN |
696 | // these variables plus srcwin_size, srcwin_maxsz above (set by config) | 689 | // these variables plus srcwin_maxsz above (set by config) |
697 | int srcwin_decided; /* boolean: true if the srclen,srcbase have been decided. */ | 690 | int srcwin_decided; /* boolean: true if the srclen,srcbase have been decided. */ |
698 | xoff_t srcwin_cksum_pos; /* Source checksum position */ | 691 | xoff_t srcwin_cksum_pos; /* Source checksum position */ |
699 | 692 | ||
diff --git a/xdelta3/xdelta3.prj b/xdelta3/xdelta3.prj index 52ad972..52ad972 100755..100644 --- a/xdelta3/xdelta3.prj +++ b/xdelta3/xdelta3.prj | |||
diff --git a/xdelta3/xdelta3.swig b/xdelta3/xdelta3.swig index 696974f..696974f 100755..100644 --- a/xdelta3/xdelta3.swig +++ b/xdelta3/xdelta3.swig | |||
diff --git a/xdelta3/xdelta3.vcproj b/xdelta3/xdelta3.vcproj index e1c3625..e1c3625 100755..100644 --- a/xdelta3/xdelta3.vcproj +++ b/xdelta3/xdelta3.vcproj | |||