391 Commits

Author SHA1 Message Date
Eric Biggers
be5aefe42f deflate_compress: rename CACHE_LENGTH to MATCH_CACHE_LENGTH 2021-12-31 17:00:05 -06:00
Eric Biggers
1f45d0b36a deflate_constants: define constant for window order 2021-12-31 17:00:05 -06:00
Eric Biggers
dd42d1a001 deflate_constants: define constant for first len sym 2021-12-31 17:00:05 -06:00
Eric Biggers
0b6127da2d deflate_constants: remove unused constants 2021-12-31 17:00:05 -06:00
Eric Biggers
e5132579a4 deflate_compress: replace COST_SHIFT with BIT_COST
This is a bit easier to understand, and the compiler will optimize the
mulitplications to shifts anyway.
2021-12-31 17:00:05 -06:00
Eric Biggers
f7d3a70d4c deflate_compress: use lazy2 compressor for levels 8-9
Instead of switching directly from the lazy compressor at level 7 to the
near-optimal compressor at level 8, use the lazy2 compressor at levels
8-9 and don't switch to near-optimal until level 10.

This avoids poor compression ratio and bad performance (both
significantly worse than level 7, and significantly worse than zlib) at
levels 8-9 on data where the near-optimal compressor doesn't do well
until the parameters are cranked up.

On data where the near-optimal compressor *does* do well, this change
worsens the compression ratio of levels 8-9, but also speeds them up a
lot, thus positioning them similarly vs. zlib as the lower levels (i.e.
much faster and slightly stronger, rather than slightly faster and much
stronger).  The difference between levels 9 and 10 is increased, but
that's perhaps the least bad place to have a discontinuity.

Resolves https://github.com/ebiggers/libdeflate/issues/85
2021-12-31 17:00:05 -06:00
Eric Biggers
1b3eaf2f13 deflate_compress: introduce the lazy2 compressor
Add deflate_compress_lazy2(), which is a slightly stronger variant of
deflate_compress_lazy().  It looks ahead 2 positions instead of 1.
2021-12-31 17:00:05 -06:00
Eric Biggers
f699b697d6 deflate_compress: tweak level 4 parameters
Use a lower max_search_depth but a higher nice_match_length.  This seems
to turn out a bit better, on average.  This is consistent with what the
other compression levels do; level 4 was the only one that had
nice_match_length <= max_search_depth.
2021-12-31 17:00:05 -06:00
Eric Biggers
057cb92782 deflate_compress: slightly decrease max_search_depth for levels 5-6
The new match scoring method in the lazy compressor has improved the
compression ratio slightly.  Therefore, for levels 5-6 decrease
max_search_depth slightly to get a bit more performance.
2021-12-31 17:00:05 -06:00
Eric Biggers
193dedc73f deflate_compress: improve match scoring in lazy compressor
In the lazy compressor, it's usually worthwhile to (quickly) consider
the match offset too, not just the match length.
2021-12-31 17:00:05 -06:00
Eric Biggers
4b7e9029d1 deflate_compress: don't use far len 3 matches in lazy compressor
It's usually not worth using length 3 matches with a large offset.
2021-12-31 17:00:05 -06:00
Eric Biggers
7e0242d04f deflate_compress: don't use far len 3 matches in greedy compressor
It's usually not worth using length 3 matches with a large offset.
2021-12-31 17:00:05 -06:00
Eric Biggers
4f7fb20776 deflate_compress: skip unneeded work in do_end_block_check()
Summing ->new_observations[] is unnecessary, since
->num_new_observations already contains the sum.
2021-12-31 17:00:05 -06:00
Eric Biggers
dd5b9693cb deflate_compress: clean up deflate_compress_{greedy,lazy,near_optimal}()
Various minor cleanups, such as adjusting the coding style and
refactoring some logic into a helper function.  No "real" changes.
2021-12-31 17:00:05 -06:00
Eric Biggers
12e72cf936 deflate_compress: use DEFLATE_END_OF_BLOCK constant 2021-12-31 17:00:05 -06:00
Eric Biggers
804c6c74f6 scripts: improve afl-fuzz support
Add a proper script which builds the fuzzed programs and runs the
fuzzer.  Also make all compression levels get fuzzed.
2021-12-31 12:19:10 -06:00
Eric Biggers
eafe829b4d Remove "originally public domain" comments
These comments are unnecessary, and they might cause confusion since
they could be misunderstood as being part of the license.
2021-12-31 12:19:10 -06:00
Eric Biggers
a62d3610f0 Makefile: add missing chmod 2021-11-24 19:41:30 -08:00
Eric Biggers
2d2bc2cc8a Makefile: fix up coding style 2021-11-24 19:41:30 -08:00
nick black
0a2b40203d Generate a pkg-config support file #140
We pull the version out of libdeflate.h into the
Makefile, and then sed a few macros out of the new
file libdeflate.pc.in. Set the necessary Cflags
and Libs (CFLAGS and LFLAGS) based off compile-time
definitions. Depend on the Makefile to pick up
version changes. Update uninstall target.

Signed-off-by: nick black <dankamongmen@gmail.com>
2021-11-23 23:28:38 -08:00
Eric Biggers
22c0dd7afd ci.yml: remove ubuntu-16.04
This is no longer supported by GitHub Actions.
2021-11-03 23:07:44 -07:00
Dmitry Bogatov
ee4d18872b Add environment variable to disable building shared library
Environment variable DISABLE_SHARED (following convention of --disable-shared
of ./configure script) disables building of shared library and shared lib
symlink. It makes life of downstream maintainer easier when maintaining package
for environment that supports only static libraries.

See https://github.com/NixOS/nixpkgs/pull/144438
2021-11-03 22:25:22 -07:00
Eric Biggers
047aa84e01 v1.8 v1.8 2021-07-15 09:31:09 -05:00
Eric Biggers
8efdabddae Convert NEWS file to markdown 2021-07-15 09:24:13 -05:00
cielavenir
9b565afd99 Fix ICC compilation
- crc32: On ICC, __v2di is defined in immintrin.h
- adler32.c: __v64qi etc are not available on ICC
2021-05-06 23:10:58 -07:00
tansy
72c81b3332 programs/gzip: add support for the '-t' option (test file integrity)
The '-t' option of GNU gzip allows checking whether a gzip file is valid
without writing the data anywhere.  It's relatively straightforward to
support in libdeflate-gzip too, so add support for it.

Resolves https://github.com/ebiggers/libdeflate/issues/125

[EB - updated commit message]
2021-05-06 22:48:02 -07:00
Eric Biggers
fbada10aa9 prog_util: make it clear that posix_[fm]advise errors are ignored 2021-03-14 21:04:26 -07:00
Eric Biggers
ea2f7569b0 benchmark: clarify what the -g and -z options do
Update https://github.com/ebiggers/libdeflate/issues/120
2021-03-12 00:07:40 -08:00
Eric Biggers
83a1bbf1d3 lib: consistently use include guards
A lot of the internal library headers don't have include guards because
they aren't needed.  It might look like a bug, though, and it doesn't
hurt to add them.  So do this.

Update https://github.com/ebiggers/libdeflate/issues/117
2021-03-12 00:07:30 -08:00
J. Zebedee
4d3c0f00d5 Add C# to bindings list 2021-02-23 22:23:11 -08:00
Ingvar Stepanyan
a07ed5824a Assume fast unaligned access on WebAssembly
I saw this tweet claiming this flag makes libdeflate run 20% faster on
WebAssembly: https://twitter.com/Algunenano/status/1317098341377900550.

Indeed, when tried even in a complex PNG compression benchmark I've
observed 10-15% improvement when this flag is enabled.

Even though WebAssembly might be running on top of a variety of
underlying platforms, the spec requires it to support unaligned access,
and on majority of platforms it will translate to a faster code.

Hence, I think it makes sense to enable this flag by default.
2021-01-19 10:31:25 -08:00
Fabrice Fontaine
e1803dc145 programs/prog_util.h: include sys/types.h
Include sys/types.h to avoid the following build failure on uclibc:

In file included from programs/gzip.c:28:0:
programs/prog_util.h:159:1: error: unknown type name ‘ssize_t’
 ssize_t xread(struct file_stream *strm, void *buf, size_t count);
 ^

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-12-28 10:40:02 -08:00
Eric Biggers
60b6197fa6 ci.yml: run 'apt-get update' prior to 'apt-get install'
This hopefully will prevent the following error:

    E: Failed to fetch http://azure.archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dbg_2.27-3ubuntu1.3_amd64.deb  404  Not Found
    E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
2020-12-25 12:08:45 -08:00
Eric Biggers
4a0bb736c9 lib: make freestanding memset() et al. symbols "weak"
This allows these symbols to be overridden by another definition of
these symbols somewhere else in the binary.

Resolves https://github.com/ebiggers/libdeflate/issues/107
2020-11-23 18:47:15 -08:00
Eric Biggers
e2f9d07050 Remove Travis CI badge
No longer applicable, now that we're using GitHub Actions instead.
2020-11-21 15:31:23 -08:00
Eric Biggers
72e9ef0791 Switch from Travis CI to GitHub Actions 2020-11-21 13:31:29 -08:00
Eric Biggers
e958f1c997 scripts/gzip_tests.sh: eliminate dependency on xxd
Use an equivalent echo command so that the xxd program doesn't have to
be installed.
2020-11-21 13:31:29 -08:00
Eric Biggers
7be9d514f8 scripts/gzip_tests.sh: when root, skip test that requires non-root 2020-11-21 13:31:29 -08:00
Eric Biggers
9f257c0123 scripts/android_tests.sh: add missing executable bit 2020-11-21 13:31:29 -08:00
Eric Biggers
5e57cbd70c scripts/android_tests.sh: clean up all temporary files
bash traps don't stack, so libdeflate_testdata wasn't being deleted.

Also sync the code with run_tests.sh.
2020-11-21 13:31:29 -08:00
Eric Biggers
6c41ede3ac scripts/run_tests.sh: allow skipping more types of tests 2020-11-21 13:31:29 -08:00
Eric Biggers
3e8bdbb401 scripts/run_tests.sh: clean up all temporary files
bash traps don't stack, so libdeflate_testdata wasn't being deleted.
2020-11-21 13:31:29 -08:00
Eric Biggers
8aedcdc12b scripts/run_tests.sh: use llvm-ar for CFI build
This is needed on Ubuntu 20.04, otherwise creating the static library
fails with -flto.
2020-11-21 13:31:29 -08:00
Eric Biggers
448e3f3b04 v1.7 v1.7 2020-11-09 19:29:50 -08:00
4kills
fc1acab71a readme: added table of contents 2020-11-07 10:42:37 -08:00
djytw
bef1e93b70 Makefile.msc: fix clean task 2020-11-07 09:21:16 -08:00
Eric Biggers
f8057e8805 lib/matchfinder: document matchfinder_rebase() preconditions 2020-10-28 19:20:30 -07:00
Eric Biggers
6d66819651 scripts/run_tests.sh: show ldd output if binary isn't dynamically linked 2020-10-28 19:19:48 -07:00
Eric Biggers
952329aeb9 scripts/run_tests.sh: silence some build output 2020-10-26 00:05:30 -07:00
Eric Biggers
ff8634427b lib/matchfinder: simplify init and rebase
Remove the ability of matchfinder_init() and matchfinder_rebase() to
fail due to the matchfinder memory size being misaligned.  Instead,
require that the size always be 128-byte aligned -- which is already the
case.  Also, make the matchfinder memory always be 32-byte aligned --
which doesn't really have any downside.
2020-10-25 22:42:25 -07:00