]> git.ipfire.org Git - thirdparty/zstd.git/log
thirdparty/zstd.git
7 years agoMerge branch 'dev' into dubtlazy 970/head
Yann Collet [Thu, 11 Jan 2018 21:25:08 +0000 (13:25 -0800)] 
Merge branch 'dev' into dubtlazy

and fixed conflicts

7 years agoMerge pull request #982 from facebook/fix304
Yann Collet [Thu, 11 Jan 2018 21:20:59 +0000 (13:20 -0800)] 
Merge pull request #982 from facebook/fix304

Fix for #304 and #977 : error during dictionary creation

7 years agochanged function name to ZSTD_DUBT_findBestMatch()
Yann Collet [Thu, 11 Jan 2018 20:38:31 +0000 (12:38 -0800)] 
changed function name to ZSTD_DUBT_findBestMatch()

7 years agoMerge pull request #981 from facebook/fix976
Yann Collet [Thu, 11 Jan 2018 19:40:07 +0000 (11:40 -0800)] 
Merge pull request #981 from facebook/fix976

fixed bug #976, reported by @indygreg

7 years agoadded warning message 982/head
Yann Collet [Thu, 11 Jan 2018 19:29:28 +0000 (11:29 -0800)] 
added warning message

when pathological dataset is detected
(note : cover_optimize needs -v to display the warning)

7 years agofixed #304
Yann Collet [Thu, 11 Jan 2018 19:16:32 +0000 (11:16 -0800)] 
fixed #304

Pathological samples may result in literal section being incompressible.
This case is now detected,
and literal distribution is replaced by one that can be written into the dictionary.

7 years agoadded a test case for dictBuilder failure
Yann Collet [Thu, 11 Jan 2018 17:42:38 +0000 (09:42 -0800)] 
added a test case for dictBuilder failure

cyclic data set makes the entropy stage fails
now, onto a fix for #304 ...

7 years agoMerge pull request #980 from conor42/dev
Yann Collet [Thu, 11 Jan 2018 16:33:35 +0000 (08:33 -0800)] 
Merge pull request #980 from conor42/dev

Fix break condition in decompression noise test

7 years agofixed minor warning on prototype definition 981/head
Yann Collet [Thu, 11 Jan 2018 12:49:19 +0000 (04:49 -0800)] 
fixed minor warning on prototype definition

7 years agofixed bug #976, reported by @indygreg
Yann Collet [Thu, 11 Jan 2018 04:33:45 +0000 (20:33 -0800)] 
fixed bug #976, reported by @indygreg

constants in zstd.h should not depend on MIN() macro which existence is not guaranteed.

Added a test to check the specific constants.
The test is a bit too specific.
But I have found no way to control a more generic "are all macro already defined" condition,
especially as this is a valid construction (the missing macro might be defined later, intentionnally).

7 years agoFix break condition in decompression noise test 980/head
conor42 [Thu, 11 Jan 2018 01:42:58 +0000 (11:42 +1000)] 
Fix break condition in decompression noise test

The bug prevents noise being added

7 years agoMerge pull request #979 from facebook/memdoc
Yann Collet [Thu, 11 Jan 2018 01:39:37 +0000 (17:39 -0800)] 
Merge pull request #979 from facebook/memdoc

Update API documentation related to memory management capabilities

7 years agoMerge pull request #974 from terrelln/dstfile
Yann Collet [Wed, 10 Jan 2018 18:02:48 +0000 (19:02 +0100)] 
Merge pull request #974 from terrelln/dstfile

[fileio] Improve safety of output file modifications

7 years agoapi doc : grouped all ZSTD_create*_advanced() functions together 979/head
Yann Collet [Wed, 10 Jan 2018 17:07:47 +0000 (09:07 -0800)] 
api doc : grouped all ZSTD_create*_advanced() functions together

in a new "custom memory allocator" paragraph
which is itself part of "memory management" category.

This makes it simpler to see the relation between the type and its usages.

7 years agoAPI doc : grouped ZSTD_initStatic*() together
Yann Collet [Wed, 10 Jan 2018 16:47:19 +0000 (08:47 -0800)] 
API doc : grouped ZSTD_initStatic*() together

within "memory management" category.

7 years agofixed msan test
Yann Collet [Sat, 6 Jan 2018 19:50:36 +0000 (20:50 +0100)] 
fixed msan test

a pointer calculation was wrong in a corner case

7 years agoMerge pull request #965 from facebook/tests_obj
Yann Collet [Sat, 6 Jan 2018 12:15:53 +0000 (13:15 +0100)] 
Merge pull request #965 from facebook/tests_obj

%.o objects files in /tests

7 years agoMerge branch 'dev' into dubtlazy
Yann Collet [Sat, 6 Jan 2018 11:40:58 +0000 (12:40 +0100)] 
Merge branch 'dev' into dubtlazy

7 years agofixed ZSTD_reduceIndex()
Yann Collet [Sat, 6 Jan 2018 11:31:26 +0000 (12:31 +0100)] 
fixed ZSTD_reduceIndex()

following suggestions from @terrelln.
Also added some comments to present logic behind ZSTD_preserveUnsortedMark().

7 years agominor tests/Makefile change, as suggested by @terrelln 965/head
Yann Collet [Sat, 6 Jan 2018 06:13:09 +0000 (07:13 +0100)] 
minor tests/Makefile change, as suggested by @terrelln

https://github.com/facebook/zstd/pull/965#discussion_r160008006

7 years agoMerge pull request #963 from facebook/benchfix
Yann Collet [Sat, 6 Jan 2018 05:57:02 +0000 (06:57 +0100)] 
Merge pull request #963 from facebook/benchfix

fix: bench can accept hlog custom parameter

7 years ago[fileio] Don't call FIO_remove() on stdout or /dev/null 974/head
Nick Terrell [Fri, 5 Jan 2018 19:49:55 +0000 (11:49 -0800)] 
[fileio] Don't call FIO_remove() on stdout or /dev/null

7 years ago[fileio] Use FIO_remove() everywhere for safety
Nick Terrell [Fri, 5 Jan 2018 19:44:45 +0000 (11:44 -0800)] 
[fileio] Use FIO_remove() everywhere for safety

7 years ago[util] Refuse to set file stat on non-regular file
Nick Terrell [Fri, 5 Jan 2018 19:44:25 +0000 (11:44 -0800)] 
[util] Refuse to set file stat on non-regular file

7 years agoMerge pull request #972 from pixelb/bz1530049
Yann Collet [Thu, 4 Jan 2018 11:14:50 +0000 (12:14 +0100)] 
Merge pull request #972 from pixelb/bz1530049

zstd: fix crash when not overwriting existing files

7 years agoMerge pull request #973 from terrelln/test-case
Yann Collet [Thu, 4 Jan 2018 11:14:36 +0000 (12:14 +0100)] 
Merge pull request #973 from terrelln/test-case

Add test case for PR #972

7 years agoAdd test case for PR #972 973/head
Nick Terrell [Wed, 3 Jan 2018 22:02:44 +0000 (14:02 -0800)] 
Add test case for PR #972

7 years agozstd: fix crash when not overwriting existing files 972/head
Pádraig Brady [Tue, 2 Jan 2018 15:17:32 +0000 (15:17 +0000)] 
zstd: fix crash when not overwriting existing files

This fixes the following crash:
  $ touch exists
  $ programs/zstd -r examples/ -o exists
  zstd: exists already exists; not overwritten
  Segmentation fault (core dumped)

* programs/fileio.c (FIO_compressMultipleFilenames):
Handle the case where we're not overwriting the destination.

Reported at https://bugzilla.redhat.com/1530049

7 years agoupdated /lib documentation
Yann Collet [Sun, 31 Dec 2017 14:50:00 +0000 (15:50 +0100)] 
updated /lib documentation

7 years agoMerge pull request #968 from shawnl/dev
Yann Collet [Sat, 30 Dec 2017 15:16:37 +0000 (16:16 +0100)] 
Merge pull request #968 from shawnl/dev

meson: get soversion right

7 years agofixed minor argument property for Visual
Yann Collet [Sat, 30 Dec 2017 14:42:28 +0000 (15:42 +0100)] 
fixed minor argument property for Visual

7 years agoMerge branch 'dubtlazy' of github.com:facebook/zstd into dubtlazy
Yann Collet [Sat, 30 Dec 2017 14:21:18 +0000 (15:21 +0100)] 
Merge branch 'dubtlazy' of github.com:facebook/zstd into dubtlazy

7 years agoimproved btlazy2 : list of unsorted candidates can reach extDict
Yann Collet [Sat, 30 Dec 2017 14:12:59 +0000 (15:12 +0100)] 
improved btlazy2 : list of unsorted candidates can reach extDict

It used to stop on reaching extDict, for simplification.
As a consequence, there was a small loss of performance each time the round buffer would restart from beginning.
It's not a large difference though, just several hundreds of bytes on silesia.
This patch fixes it.

7 years agoupdated compression level table for btlazy2
Yann Collet [Sat, 30 Dec 2017 10:37:18 +0000 (11:37 +0100)] 
updated compression level table for btlazy2

now selected for levels 13, 14 and 15.

Also : dropped the requirement for monotonic memory budget increase of compression levels,,
which was required for ZSTD_estimateCCtxSize()
in order to ensure that a memory budget for level L is large enough for any level <= L.
This condition is now ensured at run time inside ZSTD_estimateCCtxSize().

7 years agoupdated compression level table for btlazy2
Yann Collet [Sat, 30 Dec 2017 10:37:18 +0000 (11:37 +0100)] 
updated compression level table for btlazy2

now selected for levels 13, 14 and 15.

Also : dropped the requirement for monotonic memory budget increase of compression levels,,
which was required for ZSTD_estimateCCtxSize()
in order to ensure that a memory budget for level L is large enough for any level <= L.
This condition is now ensured at run time inside ZSTD_estimateCCtxSize().

7 years agosimplify ZSTD_preserveUnsortedMark() implementation
Yann Collet [Sat, 30 Dec 2017 10:13:52 +0000 (11:13 +0100)] 
simplify ZSTD_preserveUnsortedMark() implementation

since no compiler attempts to auto-vectorize it.

7 years agomeson: allow -Dlegacy_support=true, fix -Dlegacy_support=0 968/head
Shawn Landden [Mon, 25 Dec 2017 00:01:15 +0000 (16:01 -0800)] 
meson: allow -Dlegacy_support=true, fix -Dlegacy_support=0

7 years agoMerge branch 'benchfix' into dubtlazy
Yann Collet [Fri, 29 Dec 2017 18:16:58 +0000 (19:16 +0100)] 
Merge branch 'benchfix' into dubtlazy

7 years agobtlazy2 : optimization for dictionary compression
Yann Collet [Fri, 29 Dec 2017 18:14:18 +0000 (19:14 +0100)] 
btlazy2 : optimization for dictionary compression

we want the dictionary table to be fully sorted,
not just lazily filled.
Dictionary loading is a bit more intensive,
but it saves cpu cycles for match search during compression.

7 years agobtlazy2: fixed interaction between unsortedMark and reduceTable
Yann Collet [Fri, 29 Dec 2017 18:08:51 +0000 (19:08 +0100)] 
btlazy2: fixed interaction between unsortedMark and reduceTable

7 years agoadd test case which reliably produces btlazy2 rescale overflow bug
Yann Collet [Fri, 29 Dec 2017 16:40:36 +0000 (17:40 +0100)] 
add test case which reliably produces btlazy2 rescale overflow bug

The unsorted_mark is handled like any index,
which fails after a rescale.

7 years agofixed bug in dubt
Yann Collet [Fri, 29 Dec 2017 16:04:37 +0000 (17:04 +0100)] 
fixed bug in dubt

the chain of unsorted candidates could grow beyond lowLimit.

7 years agominor speed optimization : index overflow prevention
Yann Collet [Fri, 29 Dec 2017 13:40:33 +0000 (14:40 +0100)] 
minor speed optimization : index overflow prevention

new code supposed to be easier to auto-vectorize

7 years agocomplete ignore list
Yann Collet [Fri, 29 Dec 2017 13:39:49 +0000 (14:39 +0100)] 
complete ignore list

fuzz tests artifacts

7 years agofirst implementation of delayed update for btlazy2
Yann Collet [Thu, 28 Dec 2017 15:58:57 +0000 (16:58 +0100)] 
first implementation of delayed update for btlazy2

This is a pretty nice speed win.

The new strategy consists in stacking new candidates as if it was a hash chain.
Then, only if there is a need to actually consult the chain, they are batch-updated,
before starting the match search itself.
This is supposed to be beneficial when skipping positions,
which happens a lot when using lazy strategy.

The baseline performance for btlazy2 on my laptop is :
15#calgary.tar       :   3265536 ->    955985 (3.416),  7.06 MB/s , 618.0 MB/s
15#enwik7            :  10000000 ->   3067341 (3.260),  4.65 MB/s , 521.2 MB/s
15#silesia.tar       : 211984896 ->  58095131 (3.649),  6.20 MB/s , 682.4 MB/s
(only level 15 remains for btlazy2, as this strategy is squeezed between lazy2 and btopt)

After this patch, and keeping all parameters identical,
speed is increased by a pretty good margin (+30-50%),
but compression ratio suffers a bit :
15#calgary.tar       :   3265536 ->    958060 (3.408),  9.12 MB/s , 621.1 MB/s
15#enwik7            :  10000000 ->   3078318 (3.249),  6.37 MB/s , 525.1 MB/s
15#silesia.tar       : 211984896 ->  58444111 (3.627),  9.89 MB/s , 680.4 MB/s

That's because I kept `1<<searchLog` as a maximum number of candidates to update.
But for a hash chain, this represents the total number of candidates in the chain,
while for the binary, it represents the maximum depth of searches.
Keep in mind that a lot of candidates won't even be visited in the btree,
since they are filtered out by the binary sort.

As a consequence, in the new implementation,
the effective depth of the binary tree is substantially shorter.

To compensate, it's enough to increase `searchLog` value.
Here is the result after adding just +1 to searchLog (level 15 setting in this patch):
15#calgary.tar       :   3265536 ->    956311 (3.415),  8.32 MB/s , 611.4 MB/s
15#enwik7            :  10000000 ->   3067655 (3.260),  5.43 MB/s , 535.5 MB/s
15#silesia.tar       : 211984896 ->  58113144 (3.648),  8.35 MB/s , 679.3 MB/s

aka, almost the same compression ratio as before,
but with a noticeable speed increase (+20-30%).

This modification makes btlazy2 more competitive.
A new round of paramgrill will be necessary to determine which levels are impacted and could adopt the new strategy.

7 years agowindows ci : removed fullbench-dll from appveyor
Yann Collet [Wed, 27 Dec 2017 18:27:54 +0000 (19:27 +0100)] 
windows ci : removed fullbench-dll from appveyor

the test is broken
previous version was too Windows-specific.
It needs to be either refactored to be cross-platform,
or be removed if it doesn't bring any value
(which is indeed unclear).

7 years ago%.o objects files in /tests
Yann Collet [Wed, 27 Dec 2017 16:49:18 +0000 (17:49 +0100)] 
%.o objects files in /tests

Recipe in /tests rebuild everything from source for each target.
zstd is still a "small" project, so it's not prohibitive,
yet, rebuilding same files over and over represents substantial redundant work.

This patch replaces *.c files from /lib by their corresponding *.o files.
They cannot be compiled and stored directly within /lib,
since /tests triggers additional debug capabilities unwelcome in release binary.
So the resulting *.o are stored directly within /tests.

It turns out, it's difficult to find several target using *exactly* the same rules.
Using only the default rules (debug enabled, multi-threading disabled, no legacy)
a surprisingly small amount of targets share their work.

It's because, in many cases there are additional modifications requested :
some targets are 32-bits, some enable multi-threading, some enable legacy support,
some disable asserts, some want different kind of sanitizer, etc.

I created 2 sets of object files : with and without multithreading.
Several targets share their work, saving compilation time when running `make all`.
Also, obviously, when modifying one source file, only this one needs rebuilding.

For targets requiring some different setting, build from source *.c remain the rule.

The new rules have been tested within `-j` parallel compilation, and work fine with it.

7 years agofix: bench can accept hlog custom parameter 963/head
Yann Collet [Wed, 27 Dec 2017 12:32:05 +0000 (13:32 +0100)] 
fix: bench can accept hlog custom parameter

was ignored during initialization

7 years agoget soversion right
Shawn Landden [Sun, 24 Dec 2017 18:05:43 +0000 (10:05 -0800)] 
get soversion right

7 years agoMerge pull request #961 from shawnl/patch-2
Yann Collet [Fri, 22 Dec 2017 06:09:18 +0000 (07:09 +0100)] 
Merge pull request #961 from shawnl/patch-2

fix unbounded range

7 years agoMerge pull request #960 from shawnl/dev
Yann Collet [Fri, 22 Dec 2017 06:07:52 +0000 (07:07 +0100)] 
Merge pull request #960 from shawnl/dev

meson: support differn't legacy levels.

7 years agofix unbounded range 961/head
Shawn Landden [Fri, 22 Dec 2017 00:15:12 +0000 (16:15 -0800)] 
fix unbounded range

I think you meant 8 MiB or smaller, instead of an unbounded (and illogical) range

7 years agomeson: support differn't legacy levels. 960/head
Shawn Landden [Thu, 21 Dec 2017 23:41:58 +0000 (15:41 -0800)] 
meson: support differn't legacy levels.

Default to v0.4.0+

7 years agoMerge pull request #959 from shawnl/dev 954/head
Yann Collet [Wed, 20 Dec 2017 10:20:07 +0000 (11:20 +0100)] 
Merge pull request #959 from shawnl/dev

meson: fix build

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.