]> git.ipfire.org Git - thirdparty/zstd.git/log
thirdparty/zstd.git
7 years agomeson: fix build 959/head
Shawn Landden [Wed, 20 Dec 2017 06:00:27 +0000 (22:00 -0800)] 
meson: fix build

used absolute paths which are deprecated in meson, also missing some sources
that got split

also move source files each to their own line so future diffs are clearer.

7 years agoMerge pull request #958 from facebook/continueCCtx
Yann Collet [Tue, 19 Dec 2017 23:12:50 +0000 (00:12 +0100)] 
Merge pull request #958 from facebook/continueCCtx

fix a subtle issue in continue mode

7 years agoZSTD_resetCCtx_internal: fixed order of arguments 958/head
Yann Collet [Tue, 19 Dec 2017 20:49:04 +0000 (21:49 +0100)] 
ZSTD_resetCCtx_internal: fixed order of arguments

params1 was swapped with params2.
This used to be a non-issue when testing for strict equality,
but now that some tests look for "sufficient size" `<=`, order matters.

7 years agochanged variable name for clarity, suggested by @terrelln
Yann Collet [Tue, 19 Dec 2017 20:20:46 +0000 (21:20 +0100)] 
changed variable name for clarity, suggested by @terrelln

7 years agofuzzer: ensure existence of CHECK_Z macro beyond OS-X systems
Yann Collet [Tue, 19 Dec 2017 10:24:14 +0000 (11:24 +0100)] 
fuzzer: ensure existence of CHECK_Z macro beyond OS-X systems

7 years agoadded test case for "wrong blockSize in continue mode"
Yann Collet [Tue, 19 Dec 2017 09:16:09 +0000 (10:16 +0100)] 
added test case for "wrong blockSize in continue mode"

7 years agofix a subtle issue in continue mode
Yann Collet [Tue, 19 Dec 2017 08:43:03 +0000 (09:43 +0100)] 
fix a subtle issue in continue mode

The deep fuzzer tests caught a subtle bug that was probably there for a long time.
The impact of the bug is not a crash, or any other clear error signal,
rather, it reduces performance, by cutting data into smaller blocks.
Eventually, the following test would fail because it produces too many 1-byte blocks,
requiring more space than buffer can provide :
`./zstreamtest_asan --mt -s3514 -t1678312 -i1678314`

The root scenario is as follows :
- Create context, initialize it using explicit parameters or a `cdict` to pin them down, set `pledgedSrcSize=1`
- The compression parameters will not be adapted, but `windowSize` and `blockSize` will be automatically set to `1`.
  `windowSize` and `blockSize` are dynamic values, set within `ZSTD_resetCCtx_internal()`.
  The automatic adaptation makes it possible to generate smaller contexts for smaller input sizes.
- Complete compression
- New compression with same context, using same parameters, but `pledgedSrcSize=ZSTD_CONTENTSIZE_UNKNOWN`
  trigger "continue mode"
- Continue mode doesn't modify blockSize, because it used to depend on `windowLog` only,
  but in fact, it also depends on `pledgedSrcSize`.
- The "old" blocksize (1) is still there,
  next compression will use this value to cut input into blocks,
  resulting in more blocks and worse performance than necessary performance.

Given the scenario, and its possible variants, I'm surprised it did not show up before.
But I suspect it did show up, it's just that it never triggered an error, because "worse performance" is not a trigger.
The above test is a special corner case, where performance is so impacted that it reaches an error case.

The fix works, but I'm not completely pleased.
I think the current code relies too much on implied relations between variables.
This will likely break again in the future when some related part of the code change.
Unfortunately, no time to make larger changes if we want to keep the release target for zstd v1.3.3.
So a longer term fix will have to be considered after the release.

To do : create a reliable test case which triggers this scenario for CI tests.

7 years agoMerge pull request #957 from facebook/nbThreads
Yann Collet [Tue, 19 Dec 2017 00:04:14 +0000 (16:04 -0800)] 
Merge pull request #957 from facebook/nbThreads

zstdmt via compress_generic: reduce opportunity to free/create mtctx

7 years agozstdmt via compress_generic: reduce opportunity to free/create mtctx 957/head
Yann Collet [Sat, 16 Dec 2017 20:48:13 +0000 (12:48 -0800)] 
zstdmt via compress_generic: reduce opportunity to free/create mtctx

`zstreamtest --newapi` (and `--opaqueapi`) create and destroy way too many threads
resulting in failure of tsan tests,
and potentially connected to the qemu flaky tests.

This is because, at each test, the nb of threads can be changed (random).

The `--no-big-tests` directive reduce this choice to 1/2 threads,
in order to limit memory usage, especially for qemu and 32-bits builds.
Unfortunately, swapping between 1 and 2 threads is enough to constantly create/destroy new mtctx.

This patch takes advantage of the following property :
via compress_generic, no internal mtctx is needed for nbThreads < 2.
As a consequence, when nbThreads == 2, the currently active mtctx is necessarily good.

This dramatically reduces the nb of thread creations when invoking `zstreamtest --newapi --no-big-tests`
(only when parent cctx itself is created, which is randomized to 1/256 tests).

Expected outcome :
- at a minimum : tsan tests shall now work continuously without exploding the thread counter
- at best : flaky qemu tests on `zstreamtest --newapi --no-big-tests` may stop being flaky, due to less stress from constant thread creation/destruction

Real world impact :
minimal, I don't expect users to constantly change `nbThreads` between each invocation.
If `nbThreads` remains stable, existing implementation re-uses existing mtctx.

Also : `zstreamtest --newapi` but without `--no-big-tests` doesn't benefit as much,
since this test can select a random `nbThreads` value between 1 and 4.
The current patch only reduces opportunity to free/create mtctx (for example : 2->1->2 doesn't need a new mtctx)
but doesn't completely eliminate it, since `nbThreads` can still change between 2/3/4.
A more complete solution could be to only use 2 out of 4 allocated threads, thus keeping the pool at a constant size.
This would require a larger change to `POOL_*` api though.

7 years agoMerge pull request #955 from facebook/readme
Yann Collet [Fri, 15 Dec 2017 21:53:37 +0000 (13:53 -0800)] 
Merge pull request #955 from facebook/readme

Readme

7 years agoremove last paragraph 955/head
Yann Collet [Fri, 15 Dec 2017 21:28:34 +0000 (13:28 -0800)] 
remove last paragraph

7 years agominor readme formatting update
Yann Collet [Fri, 15 Dec 2017 21:26:39 +0000 (13:26 -0800)] 
minor readme formatting update

7 years agoMerge pull request #953 from facebook/clevels
Yann Collet [Fri, 15 Dec 2017 19:11:50 +0000 (11:11 -0800)] 
Merge pull request #953 from facebook/clevels

update levels 15-20

7 years agoMerge pull request #952 from terrelln/merge-end
Yann Collet [Fri, 15 Dec 2017 18:27:53 +0000 (10:27 -0800)] 
Merge pull request #952 from terrelln/merge-end

[fileio] Merge end loop for small optimization

7 years agoupdated levels 15-20 953/head
Yann Collet [Fri, 15 Dec 2017 07:29:00 +0000 (23:29 -0800)] 
updated levels 15-20

taking advantage of `btopt` improved speed to tune parameters.
Levels 16-19 are stronger than previous release, making the graph more favorable.

In theory, I should also update small-size tables,
but I got lazy on that one ...

7 years agoversion bump to v1.3.3
Yann Collet [Fri, 15 Dec 2017 00:11:20 +0000 (16:11 -0800)] 
version bump to v1.3.3

7 years ago[fileio] Merge end loop for small optimization 952/head
Nick Terrell [Thu, 14 Dec 2017 21:00:20 +0000 (13:00 -0800)] 
[fileio] Merge end loop for small optimization

7 years agoMerge pull request #951 from facebook/lastBlock
Yann Collet [Thu, 14 Dec 2017 23:39:50 +0000 (15:39 -0800)] 
Merge pull request #951 from facebook/lastBlock

saves 3-bytes on small input with streaming API

7 years agoMerge pull request #950 from facebook/srcSizeAdaptation
Yann Collet [Thu, 14 Dec 2017 22:48:31 +0000 (14:48 -0800)] 
Merge pull request #950 from facebook/srcSizeAdaptation

fix adaptation on srcSize

7 years agoadded test on small file 951/head
Yann Collet [Thu, 14 Dec 2017 21:32:24 +0000 (13:32 -0800)] 
added test on small file

on top of test on small stream

7 years agosaves 3-bytes on small input with streaming API
Yann Collet [Thu, 14 Dec 2017 19:47:02 +0000 (11:47 -0800)] 
saves 3-bytes on small input with streaming API

zstd streaming API was adding a null-block at end of frame for small input.

Reason is : on small input, a single block is enough.
ZSTD_CStream would size its input buffer to expect a single block of this size,
automatically triggering a flush on reaching this size.

Unfortunately, that last byte was generally received before the "end" directive (at least in `fileio`).
The later "end" directive would force the creation of a 3-bytes last block to indicate end of frame.

The solution is to not flush automatically, which is btw the expected behavior.
It happens in this case because blocksize is defined with exactly the same size as input.
Just adding one-byte is enough to stop triggering the automatic flush.

I initially looked at another solution, solving the problem directly in the compression context.
But it felt awkward.
Now, the underlying compression API `ZSTD_compressContinue()` would take the decision the close a frame
on reaching its expected end (`pledgedSrcSize`).
This feels awkward, a responsability over-reach, beyond the definition of this API.
ZSTD_compressContinue() is clearly documented as a guaranteed flush,
with ZSTD_compressEnd() generating a guaranteed end.

I faced similar issue when trying to port a similar mechanism at the higher streaming layer.
Having ZSTD_CStream end a frame automatically on reaching `pledgedSrcSize` can surprise the caller,
since it did not explicitly requested an end of frame.
The only sensible action remaining after that is to end the frame with no additional input.
This adds additional logic in the ZSTD_CStream state to check this condition.
Plus some potential confusion on the meaning of ZSTD_endStream() with no additional input (ending confirmation ? new 0-size frame ?)

In the end, just enlarging input buffer by 1 byte feels the least intrusive change.
It's also a contract remaining inside the streaming layer, so the logic is contained in this part of the code.

The patch also introduces a new test checking that size of small frame is as expected, without additional 3-bytes null block.

7 years agoMerge pull request #946 from terrelln/r-o
Yann Collet [Thu, 14 Dec 2017 18:02:05 +0000 (10:02 -0800)] 
Merge pull request #946 from terrelln/r-o

Allow -o with multiple files

7 years agoMerge pull request #947 from facebook/fix944
Yann Collet [Thu, 14 Dec 2017 18:01:52 +0000 (10:01 -0800)] 
Merge pull request #947 from facebook/fix944

Fix #944

7 years agofixed minor declaration-after-statement warning 950/head
Yann Collet [Thu, 14 Dec 2017 02:50:05 +0000 (18:50 -0800)] 
fixed minor declaration-after-statement warning

7 years agofixes adaptation on srcSize
Yann Collet [Thu, 14 Dec 2017 01:45:26 +0000 (17:45 -0800)] 
fixes adaptation on srcSize

This patch restores capability for each file to receive adapted compression parameters depending on its size.

The bug breaking this feature was relatively silly :
setting a parameter with a value "0" is supposed to be a no-op.
Unfortunately, it would pin down compression parameters as if they were manually set,
preventing later automatic adaptation.

Unfortunately, I'm currently short of a test case that could check this situation and trigger an error.
Compression parameters selection between tableID 0,1,2,3 is largely internal,
leaving no trace to outside world, not even in frame header.

7 years agoAllow -o with multiple files 946/head
Nick Terrell [Wed, 13 Dec 2017 02:32:50 +0000 (18:32 -0800)] 
Allow -o with multiple files

7 years agoMerge pull request #949 from terrelln/rrm
Yann Collet [Thu, 14 Dec 2017 01:36:39 +0000 (17:36 -0800)] 
Merge pull request #949 from terrelln/rrm

[fileio] Refuse to remove non-regular file

7 years agozstreamtest : added missing CHECK_Z() 947/head
Yann Collet [Wed, 13 Dec 2017 23:35:49 +0000 (15:35 -0800)] 
zstreamtest : added missing CHECK_Z()

7 years agoMerge pull request #945 from terrelln/dev
Nick Terrell [Wed, 13 Dec 2017 22:24:21 +0000 (14:24 -0800)] 
Merge pull request #945 from terrelln/dev

Fix cdict compressor repcodes

7 years ago[fileio] Refuse to remove non-regular file 949/head
Nick Terrell [Wed, 13 Dec 2017 20:04:46 +0000 (12:04 -0800)] 
[fileio] Refuse to remove non-regular file

7 years agoMerge pull request #948 from terrelln/mb
Yann Collet [Wed, 13 Dec 2017 20:17:05 +0000 (12:17 -0800)] 
Merge pull request #948 from terrelln/mb

[fileio] Fix window size MB calculation

7 years agoImproved tests
Yann Collet [Wed, 13 Dec 2017 19:48:30 +0000 (11:48 -0800)] 
Improved tests

- building cli from /tests preserves potential flags in MOREFLAGS (such as asan/usan)
- MT dictionary tests check for MT capability (MT is not enabled by default for zstd32)

7 years agoFix cdict compressor repcodes 945/head
Nick Terrell [Wed, 13 Dec 2017 01:37:06 +0000 (17:37 -0800)] 
Fix cdict compressor repcodes

7 years agoMerge branch 'dev' into fix944
Yann Collet [Wed, 13 Dec 2017 19:20:09 +0000 (11:20 -0800)] 
Merge branch 'dev' into fix944

7 years ago[fileio] Fix window size MB calculation 948/head
Nick Terrell [Wed, 13 Dec 2017 18:55:24 +0000 (10:55 -0800)] 
[fileio] Fix window size MB calculation

Test command:
```
head -c 10000 /dev/zero | ./zstd -c --zstd=wlog=12 | ./zstd -M2048 -t
```

7 years agofuzzer tests : added -v command
Yann Collet [Wed, 13 Dec 2017 18:08:52 +0000 (10:08 -0800)] 
fuzzer tests : added -v command

so that unit tests get listed in CI console
and we can see which one failed.

7 years agoadded cli test veryfying bug #944
Yann Collet [Wed, 13 Dec 2017 03:47:38 +0000 (19:47 -0800)] 
added cli test veryfying bug #944

this test fails on v1.3.2

7 years agozstd binary, when compiled from /tests, enables debug mode
Yann Collet [Wed, 13 Dec 2017 02:20:04 +0000 (18:20 -0800)] 
zstd binary, when compiled from /tests, enables debug mode

adds ZSTD_DEBUG=1 and -g

7 years agofix #944 : ZSTDMT with large files and dictionary now works correctly
Yann Collet [Wed, 13 Dec 2017 00:20:51 +0000 (16:20 -0800)] 
fix #944 : ZSTDMT with large files and dictionary now works correctly

windowLog is now enforced from provided compression parameters,
instead of being copied blindly from `cdict`
where it could be smaller.

also :
- fix a minor bug in zstreamtest --mt : advanced parameters must be set before init
- changed advanced parameter name to ZSTDMT_jobSize

7 years agore-added test case
Yann Collet [Tue, 12 Dec 2017 22:01:54 +0000 (14:01 -0800)] 
re-added test case

messing with revert ... :(

7 years agoRevert "Created a test case which reliably reproduces bug #944"
Yann Collet [Tue, 12 Dec 2017 20:51:49 +0000 (12:51 -0800)] 
Revert "Created a test case which reliably reproduces bug #944"

This reverts commit 5098d1fbe2a0b3d0ddb66c0880e3004feac65f3e.

7 years agoCreated a test case which reliably reproduces bug #944
Yann Collet [Tue, 12 Dec 2017 20:48:31 +0000 (12:48 -0800)] 
Created a test case which reliably reproduces bug #944

in zstreamtest.

7 years agoMerge pull request #943 from facebook/fix942
Yann Collet [Fri, 8 Dec 2017 18:53:08 +0000 (13:53 -0500)] 
Merge pull request #943 from facebook/fix942

Fix #942

7 years agocomment clarification 943/head
Yann Collet [Fri, 8 Dec 2017 17:16:49 +0000 (12:16 -0500)] 
comment clarification

7 years agoZSTD_initCStream_srcSize() considers "0" to mean "unknown"
Yann Collet [Thu, 7 Dec 2017 22:13:10 +0000 (17:13 -0500)] 
ZSTD_initCStream_srcSize() considers "0" to mean "unknown"

to not break existing programs relying on this behavior.
Might be changed to mean "empty" in the future.

7 years agozstreamtest : add test which detects when ZSTD_initCStream() inflate data
Yann Collet [Thu, 7 Dec 2017 08:06:01 +0000 (03:06 -0500)] 
zstreamtest : add test which detects when ZSTD_initCStream() inflate data

as in #942, when ZSTD_initCStream() believes data is empty, instead of unknown.

7 years agofix #942 : streaming interface does not compress after ZSTD_initCStream()
Yann Collet [Thu, 7 Dec 2017 07:52:50 +0000 (02:52 -0500)] 
fix #942 : streaming interface does not compress after ZSTD_initCStream()

While the final result is still, technically, a frame,
the resulting frame expands initial data instead of compressing it.
This is because the streaming API creates a tiny 1-byte buffer for input,
because it believes input is empty (0-bytes),
because in the past, 0 used to mean "unknown" instead.

This patch fixes the issue.
Todo : add a test which traps the issue.

7 years agoMerge pull request #941 from facebook/registerLess
Yann Collet [Tue, 5 Dec 2017 15:34:03 +0000 (07:34 -0800)] 
Merge pull request #941 from facebook/registerLess

remove `register` keyword

7 years agoMerge pull request #940 from facebook/gettime
Yann Collet [Tue, 5 Dec 2017 02:21:02 +0000 (18:21 -0800)] 
Merge pull request #940 from facebook/gettime

 fix #911 : changed detection macro for `clock_gettime()`

7 years agono longer supported starting C++17 941/head
Yann Collet [Tue, 5 Dec 2017 01:57:42 +0000 (17:57 -0800)] 
no longer supported starting C++17

7 years agoIt's still necessary to check PLATFORM_POSIX_VERSION for clock_gettime() 940/head
Yann Collet [Tue, 5 Dec 2017 00:31:59 +0000 (16:31 -0800)] 
It's still necessary to check PLATFORM_POSIX_VERSION for clock_gettime()

glibc/uclibc is not enough

7 years agoremoved a few redundant #include
Yann Collet [Tue, 5 Dec 2017 00:02:42 +0000 (16:02 -0800)] 
removed a few redundant #include

7 years agofix #911 : changed detection macro for clock_gettime()
Yann Collet [Mon, 4 Dec 2017 23:57:01 +0000 (15:57 -0800)] 
fix #911 : changed detection macro for clock_gettime()

The new macro might be a bit too restrictive.
Systems which do not support new test will simply default to <time.h>'s `clock_t clock()`,
suffering lesser benchmark accuracy.
Should it matter, the detection macro will have to be upgraded.

7 years agoMerge pull request #936 from facebook/qemu32panic
Yann Collet [Mon, 4 Dec 2017 22:16:55 +0000 (14:16 -0800)] 
Merge pull request #936 from facebook/qemu32panic

Reduce memory stress for qemu tests

7 years agofileio: fixed LZ4F invocation from assert() 936/head
Yann Collet [Mon, 4 Dec 2017 19:26:59 +0000 (11:26 -0800)] 
fileio: fixed LZ4F invocation from assert()

7 years agoMerge branch 'dev' into qemu32panic
Yann Collet [Mon, 4 Dec 2017 19:23:21 +0000 (11:23 -0800)] 
Merge branch 'dev' into qemu32panic

7 years agoMerge pull request #939 from facebook/shorterCircleCI
Yann Collet [Mon, 4 Dec 2017 19:22:30 +0000 (11:22 -0800)] 
Merge pull request #939 from facebook/shorterCircleCI

Faster CircleCI tests

7 years agoMerge branch 'dev' into qemu32panic
Yann Collet [Sun, 3 Dec 2017 19:14:36 +0000 (11:14 -0800)] 
Merge branch 'dev' into qemu32panic

7 years agosetParameter : no side-effect on setting a compression parameter
Yann Collet [Sat, 2 Dec 2017 05:17:09 +0000 (21:17 -0800)] 
setParameter : no side-effect on setting a compression parameter

last such side-effect was modifying cctx->loadedDictEnd on setting forceWindow.
It is no a useless operation, so it's removed.
No side-effect left when setting a compression parameter.

7 years agocircleci: removed -m32 tests 939/head
Yann Collet [Sat, 2 Dec 2017 02:34:22 +0000 (18:34 -0800)] 
circleci: removed -m32 tests

installing dependencies costs ~2mn, making it the longest test
(test itself was < 15sec)

7 years agocircleci : balance some tests
Yann Collet [Sat, 2 Dec 2017 02:11:34 +0000 (18:11 -0800)] 
circleci : balance some tests

try to group them by "equivalent" duration
since next job will not start as long as previous one is not completed on both VM

7 years agocircleci : removed cmaketest
Yann Collet [Sat, 2 Dec 2017 01:56:16 +0000 (17:56 -0800)] 
circleci : removed cmaketest

strange error on pthread detection
(seems a bug in cmake detection, since
`make zstd` works perfectly with `-pthread` on same conf)

7 years agozstdcli: fixed minor warning when bench module not enabled
Yann Collet [Sat, 2 Dec 2017 01:42:46 +0000 (17:42 -0800)] 
zstdcli: fixed minor warning when bench module not enabled

one variable defined but not used

7 years agofixed powerpc test
Yann Collet [Sat, 2 Dec 2017 01:35:19 +0000 (17:35 -0800)] 
fixed powerpc test

misspelled CFLAGS

7 years agocircleci: removed gccX/clang tests
Yann Collet [Sat, 2 Dec 2017 01:28:24 +0000 (17:28 -0800)] 
circleci: removed gccX/clang tests

does no longer need to install these large packages

7 years agoadded environment variable through circleci dashboard
Yann Collet [Sat, 2 Dec 2017 01:22:04 +0000 (17:22 -0800)] 
added environment variable through circleci dashboard

check if it works better

7 years agocircleci: removed one test node
Yann Collet [Sat, 2 Dec 2017 01:02:55 +0000 (17:02 -0800)] 
circleci: removed one test node

7 years agoMerge pull request #938 from terrelln/time
Yann Collet [Sat, 2 Dec 2017 00:40:38 +0000 (16:40 -0800)] 
Merge pull request #938 from terrelln/time

 Use util.h for timing

7 years agoMerge pull request #934 from facebook/opt3
Yann Collet [Sat, 2 Dec 2017 00:40:16 +0000 (16:40 -0800)] 
Merge pull request #934 from facebook/opt3

 zstd_opt: changed cost formula

7 years agocircleci: add CFLAGS=-O0 environment variable
Yann Collet [Sat, 2 Dec 2017 00:31:40 +0000 (16:31 -0800)] 
circleci: add CFLAGS=-O0 environment variable

for faster compilation

7 years agocircleci : make libzstd-nomt had its own test
Yann Collet [Sat, 2 Dec 2017 00:27:24 +0000 (16:27 -0800)] 
circleci : make libzstd-nomt had its own test

7 years agoMerge branch 'dev' into qemu32panic
Yann Collet [Fri, 1 Dec 2017 18:51:01 +0000 (10:51 -0800)] 
Merge branch 'dev' into qemu32panic

7 years agoremoved -ftrapv from tests/ debug flags
Yann Collet [Fri, 1 Dec 2017 18:30:53 +0000 (10:30 -0800)] 
removed -ftrapv from tests/ debug flags

-ftrapv is apparently buggy for gcc.
versions >= 5 are supposed to work better,
but even then, some complaints say it's still flaky when optimizations are enabled.
I even saw a post saying it only works if one creates its own signal handler,
which would make this flag no longer transparent.

on clang, it seems to work correctly.
But we would need to add a method to selectively add flags depending on compiler.
That's too much troubles for the intended benefit
(just catch integer overflows, which we can also do using ubsan).

7 years agoCombine definitions of SEC_TO_MICRO 938/head
Nick Terrell [Fri, 1 Dec 2017 03:40:53 +0000 (19:40 -0800)] 
Combine definitions of SEC_TO_MICRO

7 years agoUse util.h for timing
Nick Terrell [Thu, 30 Nov 2017 03:11:12 +0000 (19:11 -0800)] 
Use util.h for timing

7 years agofixed Visual warning on minor interface discrepancy
Yann Collet [Thu, 30 Nov 2017 01:01:14 +0000 (17:01 -0800)] 
fixed Visual warning on minor interface discrepancy

7 years agoremoved long-range-mode tests from `zstreamtest --no-big-tests`
Yann Collet [Thu, 30 Nov 2017 00:42:20 +0000 (16:42 -0800)] 
removed long-range-mode tests from `zstreamtest --no-big-tests`

7 years agosimplified ZSTD_CCtx_setParametersUsingCCtxParams()
Yann Collet [Thu, 30 Nov 2017 00:13:05 +0000 (16:13 -0800)] 
simplified ZSTD_CCtx_setParametersUsingCCtxParams()

Any ZSTD_CCtx_setParameter() shall just write the requested parameter, without further action.
Any action shall be taken at parameter application only (during init).
It makes it possible to just copy CCtxParams from external container to internal state,
and get rid of the more complex code which was trying to compensate for missing actions.

7 years agozstd_opt: added comments, as requested by @terrelln 934/head
Yann Collet [Wed, 29 Nov 2017 23:19:00 +0000 (15:19 -0800)] 
zstd_opt: added comments, as requested by @terrelln

7 years agoremoved one invocation of SET_PRICE() macro
Yann Collet [Wed, 29 Nov 2017 00:08:43 +0000 (16:08 -0800)] 
removed one invocation of SET_PRICE() macro

7 years agoMerge branch 'dev' into opt3
Yann Collet [Tue, 28 Nov 2017 23:03:58 +0000 (15:03 -0800)] 
Merge branch 'dev' into opt3

7 years agoMerge branch 'dev' of github.com:facebook/zstd into dev
Yann Collet [Tue, 28 Nov 2017 23:03:38 +0000 (15:03 -0800)] 
Merge branch 'dev' of github.com:facebook/zstd into dev

7 years agoadd integer overflow trapping to debug builds
Yann Collet [Tue, 28 Nov 2017 23:02:48 +0000 (15:02 -0800)] 
add integer overflow trapping to debug builds

doc: https://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Code-Gen-Options.html

7 years agozstd_opt: changed cost formula
Yann Collet [Tue, 28 Nov 2017 22:07:03 +0000 (14:07 -0800)] 
zstd_opt: changed cost formula

There was a flaw in the formula
which compared literal cost with match cost :
at a given position,
a non-null literal suite is going to be part of next sequence,
while if position ends a previous match, to immediately start another match,
next sequence will have a litlength of zero.
A litlength of zero has a non-null cost.
It follows that literals cost should be compared to match cost + litlength==0.

Not doing so gave a structural advantage to matches, which would be selected more often.
I believe that's what led to the creation of the strange heuristic which added a complex cost to matches.
The heuristic was actually compensating.
It was probably created through multiple trials, settling for best outcome on a given scenario (I suspect silesia.tar).
The problem with this heuristic is that it's hard to understand,
and unfortunately, any future change in the parser would impact the way it should be calculated and its effects.

The "proper" formula makes it possible to remove this heuristic.

Now, the problem is : in a head to head comparison, it's sometimes better, sometimes worse.
Note that all differences are small (< 0.01 ratio).
In general, the newer formula is better for smaller files (for example, calgary.tar and enwik7).
I suspect that's because starting statistics are pretty poor (another area of improvement).
However, for silesia.tar specifically, it's worse at level 22 (while being better at level 17, so even compression level has an impact ...).

It's a pity that zstd -22 gets worse on silesia.tar.
That being said, I like that the new code gets rid of strange variables,
which were introducing complexity for any future evolution (faster variants being in mind).
Therefore, in spite of this detrimental side effect, I tend to be in favor of it.

7 years agoremoved a bunch of code related to cached literal price
Yann Collet [Tue, 28 Nov 2017 20:32:24 +0000 (12:32 -0800)] 
removed a bunch of code related to cached literal price

optState was used both to evaluate price
and to cache cost of previously calculated literals.
This created a strong dependency, forcing parser to request cost in a strict order.
This limitation is forbids future parser with skipping capabilities.

After this patch, caching literals price still exists,
but is now explicit, in a stack structure.

7 years agoseparate rawLiterals, fullLiterals and match costs
Yann Collet [Tue, 28 Nov 2017 20:14:46 +0000 (12:14 -0800)] 
separate rawLiterals, fullLiterals and match costs

removed one SET_PRICE() macro invocation

7 years agoMerge pull request #893 from felixhandte/fix-lz4-compression-bug
Yann Collet [Tue, 28 Nov 2017 19:34:22 +0000 (11:34 -0800)] 
Merge pull request #893 from felixhandte/fix-lz4-compression-bug

Fix LZ4 Compression Bug

7 years agoFix LZ4 Compression Buffer Overflow 893/head
W. Felix Handte [Tue, 17 Oct 2017 05:19:29 +0000 (01:19 -0400)] 
Fix LZ4 Compression Buffer Overflow

Fixes issue where, when `zstd --format=lz4` is fed an input larger than 128KB,
the read overruns the input buffer. This changes Zstd to use LZ4 with chained
64KB blocks. This is technically a breaking change in that some third party
LZ4 implementations may not support linked blocks. However, progress should not
be allowed to be stopped by such petty concerns as backwards compatibility!

7 years agoAdd Test on LZ4 Format Input Buffer Overrun
W. Felix Handte [Tue, 28 Nov 2017 17:06:48 +0000 (12:06 -0500)] 
Add Test on LZ4 Format Input Buffer Overrun

7 years agobtopt: minor refactor : removed one SET_PRICE() macro invocation
Yann Collet [Tue, 28 Nov 2017 01:13:59 +0000 (17:13 -0800)] 
btopt: minor refactor : removed one SET_PRICE() macro invocation

direct assignment makes operation cleaner.
Also allows some (very minor) optimization (non-measurable)

7 years agobtopt: minor speed optimization
Yann Collet [Tue, 28 Nov 2017 01:01:51 +0000 (17:01 -0800)] 
btopt: minor speed optimization

matchPrice is always right at beginning

7 years agoinstall: changed variable MANDIR into MAN1DIR
Yann Collet [Mon, 27 Nov 2017 21:47:35 +0000 (13:47 -0800)] 
install: changed variable MANDIR into MAN1DIR

MANDIR still exists, and is now the parent of MAN1DIR

7 years agozstreamtest : in `-T#s`, s considered a suffix meaning "seconds"
Yann Collet [Mon, 27 Nov 2017 20:15:23 +0000 (12:15 -0800)] 
zstreamtest : in `-T#s`, s considered a suffix meaning "seconds"

avoid unintentionnally triggering `seedset`,
so that seed gets automatically determined when not set.

7 years agoupdated man page
Yann Collet [Sat, 25 Nov 2017 01:20:54 +0000 (17:20 -0800)] 
updated man page

following patch #931 by @scottchiefbaker

7 years agominor update
Yann Collet [Sat, 25 Nov 2017 00:44:28 +0000 (16:44 -0800)] 
minor update

7 years agoMerge pull request #931 from scottchiefbaker/documentation
Yann Collet [Fri, 24 Nov 2017 08:01:34 +0000 (00:01 -0800)] 
Merge pull request #931 from scottchiefbaker/documentation

Include information about the benchmark output/methodology

7 years agoInclude information about the benchmark output/methodology 931/head
Scott Baker [Thu, 23 Nov 2017 04:29:46 +0000 (20:29 -0800)] 
Include information about the benchmark output/methodology

Addresses #930

7 years agoMerge pull request #924 from facebook/opt2
Yann Collet [Wed, 22 Nov 2017 00:34:37 +0000 (16:34 -0800)] 
Merge pull request #924 from facebook/opt2

faster btopt variant

7 years agofixed comment, reported by @gyscos 924/head
Yann Collet [Tue, 21 Nov 2017 18:36:14 +0000 (10:36 -0800)] 
fixed comment, reported by @gyscos

7 years agofixed comment, as suggested by @terrelln
Yann Collet [Tue, 21 Nov 2017 18:26:17 +0000 (10:26 -0800)] 
fixed comment, as suggested by @terrelln