Commit Graph
100 Commits
Author SHA1 Message Date
Nick Terrell 53a67ec1a6 [linux-kernel] Fix duplicate symbols when built-in to kernel 2017-05-25 18:34:13 -07:00
Nick Terrell e63fff9b97 [linux-kernel] Fix clang-format edge case with goto labels 2017-05-25 13:56:46 -07:00
Nick Terrell 74b12f4014 [linux-kernel] Fix some up clang-format edge cases 2017-05-24 13:52:36 -07:00
Nick Terrell 55fc1f91fd [zstd] Fix up formatting edge cases for clang-format 2017-05-24 13:50:10 -07:00
Nick Terrell a1280406b0 [libzstd] Allow users to define custom visibility 2017-05-19 18:01:59 -07:00
Nick Terrell ddc68e174b [linux-kernel] Fix a weird clang-format corner case 2017-05-17 15:06:41 -07:00
Nick Terrell a2b21c552f [linux-kernel] Update tests Makefile 2017-05-17 14:56:37 -07:00
Nick Terrell 8d8e65c6c3 [linux-kernel] Update zstd.diff 2017-05-17 14:52:12 -07:00
Nick Terrell 06fa1b0560 [linux-kernel] Move ZSTD_STATIC_ASSERT to zstd_internal.h 2017-05-17 14:51:50 -07:00
Nick Terrell 67101c6c77 [linux-kernel] clang-format lib/zstd/ 2017-05-17 14:40:46 -07:00
Nick Terrell 588579f3a1 [linux-kernel] Rename MEM_* functions to ZSTD_* 2017-05-17 14:39:57 -07:00
Nick Terrell 581e5fbe83 Add clang-format config 2017-05-17 13:49:19 -07:00
Nick Terrell d1a5790f8e [linux-kernel] Dual license with GPLv2 2017-05-17 12:08:15 -07:00
Nick Terrell fb10c91b4f [linux-kernel] Update zstd.diff 2017-05-16 17:21:22 -07:00
Nick Terrell 358280f107 Remove cross-platform macros and dead code 2017-05-16 17:16:00 -07:00
Nick Terrell 8eb7a32527 [linux-kernel] Fix whitespace edge case with script 2017-05-16 16:55:52 -07:00
Nick Terrell 0ce0782c97 [linux-kernel] Update kernelize.sh script for edge cases 2017-05-16 16:55:03 -07:00
Nick Terrell 0d26da2f25 [linux-kernel] Don't undef current (use curr) 2017-05-16 16:48:58 -07:00
Nick Terrell f3c9bd014c [linux-kernel] Remove unused variables in test 2017-05-16 16:13:51 -07:00
Nick Terrell 90a1c94965 [linux-kernel] Update header comments 2017-05-16 16:10:17 -07:00
Nick Terrell 1d42ca8f6d Add zstd.diff 2017-05-16 16:02:05 -07:00
Nick Terrell b3ebe9b77c [linux-kernel] Separate xxhash into its own module 2017-05-16 15:52:35 -07:00
Nick Terrell 374f868354 Update whitespace 2017-05-10 17:48:42 -07:00
Nick Terrell a99ece9e79 Update zstd.1.md to use btultra 2017-05-10 16:51:18 -07:00
Nick Terrell 5f2c7213c7 Merge remote-tracking branch 'upstream/dev' into btopt
* upstream/dev: (305 commits)
  added test for ZSTD_estimateCStreamSize()
  changed variable name, for clarity
  fixed ZSTD_estimateCStreamSize()
  shortened ZSTD_createCStream_Advanced()
  fixed symbols test
  added ZSTD_estimateDStreamSize()
  changed name frameParams into frameHeader
  regroup memory usage function declarations
  separated ZSTD_estimateCStreamSize() from ZSTD_estimateCCtxSize()
  bumped version number
  added ZSTD_estimateCDictSize() and ZSTD_estimateDDictSize()
  Updated ZSTD_freeCCtx()
  updated ZSTD_estimateCCtxSize()
  Updated ZSTD_sizeof_CCtx()
  merged CCtx and CStream as a single same object
  cli : -d and -t do not stop after a failed decompression
  added dev branch CircleCI badge
  added dev branch Appveyor badge
  keep dev branch status only
  creates a binary archive without the `programs` directory
  ...
2017-05-10 16:49:58 -07:00
Nick Terrell cf4f9403fa [kernel] Update README with SquashFS patch
Take patch from PR #682 by @iburinoc and update benchmarks.
2017-05-03 11:07:39 -07:00
Nick Terrell 99972fa9a8 [btrfs] Fix typo in pr_warn() message 2017-05-02 13:57:40 -07:00
Nick Terrell 79a85e1371 [btrfs] Update patch to use ZSTD_init{C,D}Stream() 2017-05-02 13:41:57 -07:00
Nick Terrell f376d47c11 [CLI] Switch dictionary builder on CLI to cover 2017-05-02 11:18:27 -07:00
Nick Terrell 020b960e13 [cover] Make optimization faster 2017-05-02 11:02:48 -07:00
Nick Terrell f2d9ef1dc0 [cover] Optimize case where d <= 8 2017-05-02 11:02:43 -07:00
Nick Terrell 865918dd04 Fix typo in zdict.h 2017-05-02 11:02:37 -07:00
Nick Terrell feba969a69 Fix LZ4_MSG in xzstd 2017-05-02 11:02:16 -07:00
Nick Terrell 0bd5d25d02 [pzstd] Add logging statements to tests 2017-04-27 09:55:19 -07:00
Nick Terrell 5087c1761f Rename ZSTD_create*() to ZSTD_init*() 2017-04-26 13:08:20 -07:00
Nick Terrell b633377d0e Add BtrFS benchmarks 2017-04-11 12:40:53 -07:00
Nick Terrell b4dd3378f1 Add BtrFS patch for 4.10 kernel 2017-04-11 11:50:24 -07:00
Nick Terrell adb1974aec Switch comments to kernel style + limit to 80 cols 2017-04-10 16:52:59 -07:00
Nick Terrell bed6c0a4b0 Remove ZSTDLIB_API from decompress.c 2017-04-10 14:49:34 -07:00
Nick Terrell 9c7371b3ee Improve comments and ordering 2017-04-04 19:02:28 -07:00
Nick Terrell 97693aff98 Add a README 2017-04-04 18:39:22 -07:00
Nick Terrell 7f510a7797 Add Kconfig and Makefile diffs 2017-04-04 18:37:55 -07:00
Nick Terrell 60b34b0d1c fix gitignore 2017-04-04 18:15:21 -07:00
Nick Terrell bb213798d9 Rename zstd_(de)compress.c to (de)compress.c 2017-04-04 18:09:02 -07:00
Nick Terrell 1b3856463e Undef current if defined 2017-04-04 17:21:49 -07:00
Nick Terrell c53bacc881 Fix up some old names 2017-04-04 17:03:48 -07:00
Nick Terrell 2e4dbd2105 Really move the makefile 2017-04-04 17:02:28 -07:00
Nick Terrell 5859101396 Move Makefile to lib/zstd 2017-04-04 17:00:12 -07:00
Nick Terrell d0bbceac40 Add fs/btrfs/zstd.c 2017-04-04 16:56:52 -07:00
Nick Terrell 2eb623a6eb Explicitly convert scratchBuffer to unsigned* 2017-04-04 16:38:13 -07:00
Nick Terrell 405d2a1027 Explicitly convert scratchBuffer to unsigned* 2017-04-04 16:35:31 -07:00
Nick Terrell fd95be0ade Move sources to lib/zstd/ 2017-04-04 16:30:11 -07:00
Nick Terrell 1af700ea43 Remove unused FSE/HUF functions 2017-04-04 16:22:58 -07:00
Nick Terrell 16a739cab0 Switch call of FSE_count() to FSE_count_wksp() 2017-04-04 16:17:21 -07:00
Nick Terrell dd62829ccf Remove more restrict 2017-04-04 15:55:48 -07:00
Nick Terrell 9c257dc268 Fix up xxhash 2017-04-04 15:54:39 -07:00
Nick Terrell 0888251fb1 Switch intptr_t to ptrdiff_t 2017-04-04 15:49:38 -07:00
Nick Terrell 675839254d Move zstd.h to linux/zstd.h 2017-04-04 15:44:27 -07:00
Nick Terrell b06507221e Test module macros 2017-04-04 12:56:44 -07:00
Nick Terrell b1b582b9fa Add module macros 2017-04-04 12:56:35 -07:00
Nick Terrell b5e3e3c9a8 Add zstd kernel module Makefile 2017-04-04 12:10:47 -07:00
Nick Terrell 79298bf187 Add userland test with mock kernel headers 2017-04-04 11:53:22 -07:00
Nick Terrell 33fc0ad56a Fix ZSTD_createCStream_usingCDict() and ZSTD_compress_usingCDict() 2017-04-04 11:52:49 -07:00
Nick Terrell 26b046a7c4 Remove unnecessary dictID store 2017-04-03 21:46:28 -07:00
Nick Terrell 39a6cc5172 Make ZSTD_compress_usingCDict() respect contentSizeFlag 2017-04-03 21:09:55 -07:00
Nick Terrell 62ecad3819 Fix ZSTD_initCStream_usingCDict() to use dictionary 2017-04-03 21:05:59 -07:00
Nick Terrell 87cec8fd56 Fix compilation errors 2017-04-03 16:08:20 -07:00
Nick Terrell 59aadc85dc Preallocate workSpace for cctx and combine create and init for cstream 2017-04-03 15:23:09 -07:00
Nick Terrell 21b6c53b9f Working on API 2017-03-31 18:07:32 -07:00
Nick Terrell eb38617175 Clean up default sparse logic 2017-03-31 15:20:50 -07:00
Nick Terrell 96fe545a18 Turn off sparse mode for OS X by default 2017-03-31 15:16:43 -07:00
Nick Terrell e48b135521 Remove STATIC_LINKING_ONLY defines 2017-03-30 14:54:33 -07:00
Nick Terrell 6ce58897da Use <asm/unaligned.h> for unaligned memory access 2017-03-30 14:53:57 -07:00
Nick Terrell be7da5d98b Change stdlib includes to linux includes 2017-03-30 14:53:52 -07:00
Nick Terrell b3b41d0f6d Remove platform specific macros 2017-03-30 14:53:23 -07:00
Nick Terrell 1075c12078 Convert all spaces to tabs 2017-03-30 14:49:45 -07:00
Nick Terrell 78063ca2bd spaces to tabs 2017-03-30 14:47:42 -07:00
Nick Terrell b1c6bb8702 Copy files into contrib/linux-kernel/ 2017-03-30 14:47:35 -07:00
Nick Terrell 5152fb2cb2 Convert all tabs to spaces 2017-03-29 18:51:58 -07:00
Nick Terrell dfc75f74da Add $(EXT) to binary to fix zlib detection for some MinGW versions 2017-03-22 13:24:52 -07:00
Nick Terrell 741e3e8314 Add $(FLAGS) when testing for zlib/lzma support.
* If zlib/lzma isn't in the usual spot, it won't be used,
  even if `$CFLAGS` and `$LDFLAGS` add the location it is in.
* Update the test code snippets to not trigger any warnings.
2017-03-22 12:33:08 -07:00
Nick Terrell eaf69b07f0 Zero pointers after freeing 2017-03-21 13:20:59 -07:00
Nick Terrell aa8bcf360f Add xz and lzma support.
Finish feature started by @inikep.

* Add xz and lzma compression and decompression support to target `xzstd`.
* Fix bug in gzip decompression that silently accepted truncated files.
* Add gzip frame composition tests.
* Add xz/lzma compatibility tests.
* Add xz/lzma frame composition tests.
2017-03-13 18:45:41 -07:00
Nick Terrell f35ef5c8e9 Whitespace only: tabs to spaces 2017-03-09 12:51:33 -08:00
Nick Terrell eeb31eed39 s/ZSTD_btopt2/ZSTD_btultra/g 2017-03-09 11:44:25 -08:00
Nick Terrell e65aab8e0f Remove 'mem.h' dependency from ZSTD_WINDOWLOG_MAX 2017-03-08 15:40:13 -08:00
Nick Terrell 81512e9ebe Avoid '#define inline /* ... */'
Take definition of `FORCE_INLINE` from `zstd_internal.h`.
2017-03-08 14:00:21 -08:00
Nick Terrell e06c303475 Fix ZSTD_sizeof_CStream() 2017-03-08 13:45:10 -08:00
Nick Terrell 54c4babd8f Always check Huffman tables for ZSTD_lazy+
The compressor always reuses the existing Huffman table if the literals
size is at most 1 KiB. If the compression strategy is `ZSTD_lazy` or
stronger always check to see if reusing the previous table or creating
a new table is better.

This doesn't yet weigh in decompression speed. I don't want to add any
heuristics there until I have real data to work with to ensure that the
heuristic works for at least one use case, preferably more.
2017-03-03 16:49:38 -08:00
Nick Terrell d051cd5b43 Use workspace for count and CTable 2017-03-02 16:38:07 -08:00
Nick Terrell 976e325b2e Fix COVER_optimizeTrainFromBuffer() resource leaks
Thanks to @nemequ for reporting the resource leaks.
2017-03-02 15:54:39 -08:00
Nick Terrell a419777eb1 Allow compressor to repeat Huffman tables
* Compressor saves most recently used Huffman table and reuses it
  if it produces better results.
* I attempted to preserve CPU usage profile.
  I intentionally left all of the existing heuristics in place.
  There is only a speed difference on the second block and later.
  When compressing large enough blocks (say >= 4 KiB) there is
  no significant difference in compression speed.
  Dictionary compression of one block is the same speed for blocks
  with literals <= 1 KiB, and after that the difference is not
  very significant.
* In the synthetic data, with blocks 10 KB or smaller, most blocks
  can't use repeated tables because the previous block did not
  contain a symbol that the current block contains.
  Once blocks are about 12 KB or more, most previous blocks have
  valid Huffman tables for the current block, and the compression
  ratio and decompression speed jumped.
* In silesia blocks as small as 4KB can frequently reuse the
  previous Huffman table (85%), but it isn't as profitable, and
  the previous Huffman table only gets used about 3% of the time.
* Microbenchmarks show that `HUF_validateCTable()` takes ~55 ns
  and `HUF_estimateCompressedSize()` takes ~35 ns.
  They are decently well optimized, the first versions took 90 ns
  and 120 ns respectively. `HUF_validateCTable()` could be twice as
  fast, if we cast the `HUF_CElt*` to a `U32*` and compare to 0.
  However, `U32` has an alignment of 4 instead of 2, so I think that
  might be undefined behavior.
* I've ran `zstreamtest` compiled normally, with UASAN and with MSAN
  for 4 hours each.

The worst case for the speed difference is a bunch of small blocks
in the same frame. I modified `bench.c` to compress the input in a
single frame but with blocks of the given block size, set by `-B`.
Benchmarks on level 1:

|  Program  | Block size |   Corpus  | Ratio | Compression MB/s | Decompression MB/s |
|-----------|------------|-----------|-------|------------------|--------------------|
| zstd.base |        256 | synthetic | 2.364 |            110.0 |              297.0 |
|      zstd |        256 | synthetic | 2.367 |            108.9 |              297.0 |
| zstd.base |        256 | silesia   | 2.204 |             93.8 |              415.7 |
|      zstd |        256 | silesia   | 2.204 |             93.4 |              415.7 |
| zstd.base |        512 | synthetic | 2.594 |            144.2 |              420.0 |
|      zstd |        512 | synthetic | 2.599 |            141.5 |              425.7 |
| zstd.base |        512 | silesia   | 2.358 |            118.4 |              432.6 |
|      zstd |        512 | silesia   | 2.358 |            119.8 |              432.6 |
| zstd.base |       1024 | synthetic | 2.790 |            192.3 |              594.1 |
|      zstd |       1024 | synthetic | 2.794 |            192.3 |              600.0 |
| zstd.base |       1024 | silesia   | 2.524 |            148.2 |              464.2 |
|      zstd |       1024 | silesia   | 2.525 |            148.2 |              467.6 |
| zstd.base |       4096 | synthetic | 3.023 |            300.0 |             1000.0 |
|      zstd |       4096 | synthetic | 3.024 |            300.0 |             1010.1 |
| zstd.base |       4096 | silesia   | 2.779 |            223.1 |              623.5 |
|      zstd |       4096 | silesia   | 2.779 |            223.1 |              636.0 |
| zstd.base |      16384 | synthetic | 3.131 |            350.0 |             1150.1 |
|      zstd |      16384 | synthetic | 3.152 |            350.0 |             1630.3 |
| zstd.base |      16384 | silesia   | 2.871 |            296.5 |              883.3 |
|      zstd |      16384 | silesia   | 2.872 |            294.4 |              898.3 |
2017-03-02 13:27:52 -08:00
Nick Terrell 3475b9b431 Set dictID to 0 for content only dictionaries 2017-03-02 12:33:02 -08:00
Nick Terrell 74b81ada25 Don't run test-pool with QEMU
> make test -n
    ...
    ./pool
    > make test -n QEMU_SYS=valgrind
    ...
    ./legacy
    # ./pool not run
2017-02-14 10:08:18 -08:00
Nick Terrell ecf90ca24b [zstdmt] Fix MSAN failure with ZSTD_p_forceWindow
Reproduction steps:

```
make zstreamtest CC=clang CFLAGS="-O3 -g -fsanitize=memory -fsanitize-memory-track-origins"
./zstreamtest -vv -t4178 -i4178 -s4531
```

How to get to the error in gdb (may be a more efficient way):

* 2 breaks at zstd_compress.c:2418  -- in ZSTD_compressContinue_internal()
* 2 breaks at zstd_compress.c:2276  -- in ZSTD_compressBlock_internal()
* 1 break at zstd_compress.c:1547

Why the error occurred:

When `zc->forceWindow == 1`, after calling `ZSTD_loadDictionaryContent()` we
have `zc->loadedDictEnd == zc->nextToUpdate == 0`. But, we've really loaded up
to `iend` into the dictionary. Then in `ZSTD_compressBlock_internal()` we see
that `current > zc->nextToUpdate + 384`, so we load the last 192 bytes a second
time. In this case the bytes we are loading are a block of all 0s, starting in
the previous block. So when we are loading the last 192 bytes, we find a `match`
in the future, 183 bytes beyond `ip`. Since the block is all 0s, the match
extends to the end of the block. But in `ZSTD_count()` we only check that
`pIn < pInLoopLimit`, but since `pMatch > pIn`, `pMatch` eventually points past
the end of the buffer, causing the MSAN failure.

The fix:

The line changed sets sets `zc->nextToUpdate` to the end of the dictionary.
This is the behavior that existed before `ZSTD_p_forceWindow` was introduced.
This fixes the exposing test case. Since the code doesn't fail without
`zc->forceWindow`, it makes sense that this works. I've run the command
`./zstreamtest -T2mn` 64 times without failures. CI should also verify nothing
obvious broke.
2017-02-13 19:11:22 -08:00
Nick Terrell d08019813b Improvement from @inikep 2017-02-09 14:20:52 -08:00
Nick Terrell 545987996a Fix deprecation warnings for clang with C++14 2017-02-08 17:38:17 -08:00
Nick Terrell a0f9006e5a #undef _POSIX_C_SOURCE if already defined 2017-02-08 17:25:01 -08:00
Nick Terrell b5e46b1255 Remove test-longmatch from test target and only run it once 2017-02-08 12:00:21 -08:00
Nick Terrell 71c5263c00 Attribute cover dictionary code 2017-02-07 11:35:07 -08:00