Commit Graph

1245 Commits

Author SHA1 Message Date
Nick Terrell
19ca3fbc03 [zstdcli] Respect --[no-]compress-literals in benchmark mode 2019-02-15 16:27:39 -08:00
Nick Terrell
0c53c5ad4a [zstdcli] Add a flag to control literals compression 2019-02-15 15:00:45 -08:00
Nick Terrell
5261a288d1 Fix a bug in the compress cctx method 2019-02-15 14:58:19 -08:00
Nick Terrell
3d7377b874 [libzstd] Handle uncompressed literals 2019-02-15 14:58:11 -08:00
Nick Terrell
a96e67af6c [regression] Test level 19 with uncompressed literals 2019-02-15 10:52:46 -08:00
Nick Terrell
dbaa7042d9 [regression] Test ZSTD_c_literalCompressionMode
Test a positive compression level with uncompressed literals,
and a negative compression level with compressed literals.

I double checked the `results.csv` and made sure that the compressed
sizes make sense.
2019-02-13 15:00:32 -08:00
Björn Ketelaars
77d9109c27 Add test
While here enable symlink test for OpenBSD.
2019-02-12 01:56:05 +01:00
Björn Ketelaars
b26c53b0d0 'head -c BYTES' is non-portable.
Pull request #1499 added a new test, which uses 'head -c'. The '-c'
option is non-portable (not in POSIX). Instead use 'dd'. Similar issue
has been resolved in the past (#1321).
2019-02-11 12:00:26 +01:00
Peter (Stig) Edwards
cdb3e7af2f
-Wformat-security not needed with -Wformat=2 2019-02-01 09:38:49 +00:00
Peter (Stig) Edwards
723418f8d8
-Wformat-security not needed with -Wformat=2 2019-02-01 09:29:40 +00:00
W. Felix Handte
03e040a966 Replace Uses of CHECK_E with RETURN_ERROR_IF(*_isError(... 2019-01-28 17:33:01 -05:00
Yann Collet
cee31bbd25 updated fullbench and paramgrill
to use new benchfn
returning a double.
2019-01-25 15:38:08 -08:00
Karl Ostmo
4fa585aee3 fix --list on truncated files
fseek() doesn't indicate when it moves past the end of a file.
Consequently, if a file is truncated within its last block, the error would't be detected.

This PR adds a test scenario that induces this situation using a small compressed file of only one block in size.
This test is added to tests/playTests.sh

Check is implemented by ensuring that the filehandle position is equal to the filesize upon exit.
2019-01-15 19:03:29 -08:00
Yann Collet
c5be47c8c1
Merge pull request #1494 from lzutao/fix-leak
Fix potential leak of 'outBuff' (reported by scan-build)
2019-01-06 17:17:02 -08:00
Lzu Tao
260ff2f6b7 tests/legagy.c: More fixes 2019-01-06 23:42:24 +07:00
Lzu Tao
de7e3be7fa Fix potential leak of 'outBuff' (reported by scan-build) 2019-01-06 23:28:38 +07:00
Lzu Tao
7b6a8840c5 Fix #1428 - zstdgrep returned 1 on match and unmatch
- Use ZCAT for testing zstdgrep in case of non-install yet
- tests: Add file test for zstdgrep
2019-01-06 23:22:55 +07:00
Yann Collet
ae1d6bd48e fixed playTests.sh for minGW
On Windows, the equivalent of `/dev/null` is `NUL`.
When tests are run under msys2/minGW,
the environment identifies itself as Windows,
hence the script uses `NUL` instead of `/dev/null`
but the environment will consider `NUL` to be a regular file name.
Consequently, `NUL` will be overwritten during tests,
triggering an error.

This patch uses flag `-f` to force such overwrite
passing the test.
2018-12-26 15:19:09 -08:00
Yann Collet
ededcfca57 fix confusion between unsigned <-> U32
as suggested in #1441.

generally U32 and unsigned are the same thing,
except when they are not ...

case : 32-bit compilation for MIPS (uint32_t == unsigned long)

A vast majority of transformation consists in transforming U32 into unsigned.
In rare cases, it's the other way around (typically for internal code, such as seeds).

Among a few issues this patches solves :
- some parameters were declared with type `unsigned` in *.h,
  but with type `U32` in their implementation *.c .
- some parameters have type unsigned*,
  but the caller user a pointer to U32 instead.

These fixes are useful.

However, the bulk of changes is about %u formating,
which requires unsigned type,
but generally receives U32 values instead,
often just for brevity (U32 is shorter than unsigned).
These changes are generally minor, or even annoying.

As a consequence, the amount of code changed is larger than I would expect for such a patch.

Testing is also a pain :
it requires manually modifying `mem.h`,
in order to lie about `U32`
and force it to be an `unsigned long` typically.
On a 64-bit system, this will break the equivalence unsigned == U32.
Unfortunately, it will also break a few static_assert(), controlling structure sizes.
So it also requires modifying `debug.h` to make `static_assert()` a noop.
And then reverting these changes.

So it's inconvenient, and as a consequence,
this property is currently not checked during CI tests.
Therefore, these problems can emerge again in the future.

I wonder if it is worth ensuring proper distinction of U32 != unsigned in CI tests.
It's another restriction for coding, adding more frustration during merge tests,
since most platforms don't need this distinction (hence contributor will not see it),
and while this can matter in theory, the number of platforms impacted seems minimal.

Thoughts ?
2018-12-21 18:09:41 -08:00
Nick Terrell
a24f73bece [regression] Update results.csv 2018-12-20 17:40:48 -08:00
Yann Collet
41b45b84a1
Merge pull request #1465 from facebook/noFilePresent
fixed : detection of non-existing file
2018-12-20 17:21:04 -08:00
Yann Collet
6e9512a70c
Merge pull request #1463 from yijinfb/getenv
Add support for environment variable ZSTD_CLEVEL in CLI
2018-12-20 15:17:00 -08:00
Yann Collet
e129174d1d fixed shadowing of variable time
some standard lib do define `time` as a global variable
shadowing local declarations ...
2018-12-20 14:54:05 -08:00
Yann Collet
72dbf1bcd0 removed strncpy() from util.c
as Visual surprisingly complains about their usage.
Replaced by memcpy()
2018-12-20 12:27:12 -08:00
Yann Collet
105fa953cb use strerror() to generate error message
as suggested by @terrelln .

also:
- hopefully fixed Windows version
- changed the test, so that it passes on non-english OS stdlib errors.
2018-12-20 09:16:40 -08:00
Yann Collet
173ef9dea2 fixed : detection of non-existing file
better error message
with test
2018-12-19 18:30:57 -08:00
Yann Collet
a835e9cb81
Merge pull request #1461 from terrelln/regression
[regression] Add more configs
2018-12-19 17:53:15 -08:00
Yann Collet
bb7e6018af
Merge pull request #1462 from facebook/btultra2.3
fixed ossfuzz 11849
2018-12-19 17:48:11 -08:00
Yann Collet
2898afab52 fixed OSSfuzz 11849
The problem was already masked,
due to no longer accepting tiny blocks for statistics.

But in case it could still happen with not-so-tiny blocks,
there is a stricter control which ensures that
nothing was already loaded prior to statistics collection.
2018-12-19 16:54:15 -08:00
Yi Jin
26a9ae3f5f refactor readU32FromChar(...), improve init_cLevel(...), and add env var ZSTD_CLEVEL tests 2018-12-19 16:45:42 -08:00
Nick Terrell
6e6315ae46 [regression] Add more configs
* Add configs that test multithreading, LDM, and setting explicit
  parameters.
* Update the `compress cctx` method to accept `ZSTD_parameters`.
* Compile against the multithreaded `libzstd.a`.
* Update `results.csv` for the new configs.

Unless you think there are more configs/methods I should test, I think
we have a fairly wide set of configs/methods, so I'll pause adding
more for now.
2018-12-19 16:36:26 -08:00
Yann Collet
2f67ac3dce
Merge pull request #1460 from facebook/btultra2.2
fixed: compression ratio discrepancy
2018-12-19 15:00:15 -08:00
Yann Collet
78c4ea4930 added tests case 2018-12-19 14:10:27 -08:00
Nick Terrell
3a4634f2af
Merge pull request #1459 from terrelln/destroy
[zstdcli] Refuse to overwrite input file
2018-12-18 17:03:54 -08:00
Nick Terrell
cd2c8defad [zstdcli] Refuse to overwrite input file
Compare the input and output files by their inode number and
refuse to open the output file if the input file is the same.

This doesn't work when (de)compressing multiple files to a single
file, but that is a very uncommon use case, mostly used for
benchmarking by me.

Fixes #1422.
2018-12-18 15:29:54 -08:00
Nick Terrell
d7def456d8 [libzstd] Fix estimate with negative levels
* Fix `ZSTD_estimateCCtxSize()` with negative levels.
* Fix `ZSTD_estimateCStreamSize()` with negative levels.
* Add a unit test to test for this error.
2018-12-18 14:24:49 -08:00
Yann Collet
517d8c984c
Merge pull request #1449 from facebook/ovlog_def
overlapLog default values
2018-12-18 09:45:53 -08:00
Nick Terrell
bdfcaecc0a [zstdcli] Add --no-progress flag
The `--no-progress` flag disables zstd's progress bars, but leaves
the summary.

I've added simple tests to `playTests.sh` to make sure the parsing
works.
2018-12-14 11:50:25 -08:00
Yann Collet
96adc846c5 fixed tests
with correct pointer type
2018-12-13 16:50:19 -08:00
Nick Terrell
75fa3f2eb7
Merge pull request #1446 from terrelln/overflow
[libzstd] Fix infinite loop in decompression
2018-12-13 16:21:15 -08:00
Nick Terrell
aaea4ef924 [libzstd] Fix infinite loop in decompression
When we switched `ZSTD_SKIPPABLEHEADERSIZE` to a macro, the places where we do:

    MEM_readLE32(ptr) + ZSTD_SKIPPABLEHEADERSIZE

can now overflow `(unsigned)-8` to `0` and we infinite loop. We now check
the frame size and reject sizes that overflow a U32.

Note that this bug never made it into a release, and was only in the dev branch
for a few days.

Credit to OSS-Fuzz
2018-12-13 15:13:19 -08:00
Yann Collet
1993f5d412 fixed ovlog tests
and updated man page
2018-12-12 21:09:14 -08:00
Yann Collet
f2f86d369b Merge branch 'btultra2' into ovlog_def 2018-12-12 20:58:14 -08:00
Yann Collet
9a92ed401d updated compression results.csv
and fixed nit
2018-12-12 20:30:09 -08:00
Yann Collet
9792acda3b Merge branch 'dev' into btultra2 2018-12-12 20:18:27 -08:00
Yann Collet
eee789b7ea continued: changed to overlapLog
in deeper code layer.
for consistency.
2018-12-11 17:41:42 -08:00
Yann Collet
9b784dec7f changed parameter name to ZSTD_c_overlapLog
from overlapSizeLog.

Reasoning :
`overlapLog` is already used everwhere, in the code, command line and documentation.
`ZSTD_c_overlapSizeLog` feels unnecessarily different.
2018-12-11 16:55:33 -08:00
Nick Terrell
8c99e311cf Reset the cctx for documentation/safety 2018-12-11 15:57:56 -08:00
Nick Terrell
fcfea057a1 [regression] add more methods 2018-12-11 13:10:22 -08:00
Yann Collet
9c3265a53f
Merge pull request #1417 from facebook/advancedAPI
Advanced API
2018-12-10 18:48:15 -08:00
Yann Collet
5e6aaa3abb fixed btultra2 usage with prefix
notably while using multi-threading
2018-12-10 18:45:03 -08:00
Yann Collet
b71bfb6cf2 paramgrill: add status line
get information on which config is currently tested
so that console get animated during long tests.
2018-12-07 16:02:24 -08:00
Yann Collet
27b253fadc added tests for strategy=9 (btultra2) 2018-12-07 14:20:54 -08:00
Yann Collet
e68c2d86e7 refactor paramgrill for clarity
restored ability to copy/paste the resulting compression level table into zstd_compress.c .
2018-12-07 14:07:54 -08:00
Yann Collet
39e28982cf introduced constants ZSTD_STRATEGY_MIN and ZSTD_STRATEGY_MAX 2018-12-06 16:16:16 -08:00
Yann Collet
be9e561da4 changed ZSTD_c_compressionStrategy into ZSTD_c_strategy
also : fixed paramgrill, and limit conditions
2018-12-06 15:00:52 -08:00
Yann Collet
3583d19c4e changed parameter names from ZSTD_p_* to ZSTD_c_*
for naming consistency
2018-12-05 17:26:02 -08:00
Yann Collet
3e042d5cc0 ZSTD_decompressDCtx() is compatible with sticky parameters 2018-12-04 17:30:58 -08:00
Yann Collet
d7da3fc90a merge dedicated dParam setters 2018-12-04 17:06:48 -08:00
Yann Collet
2fb8d1a392 fixed declaration-after-statement warnings 2018-12-04 15:54:01 -08:00
Yann Collet
aec945f0dc implemented ZSTD_dParam_getBounds()
and ZSTD_DCtx_setParameter()
2018-12-04 15:35:37 -08:00
Yann Collet
34e146f548 advanced decompression function replaces by normal streaming one
advanced parameters compatible with ZSTD_decompressStream().
2018-12-04 10:28:36 -08:00
Yann Collet
6ced8f7c7c joined normal streaming API with advanced one 2018-12-03 14:22:38 -08:00
Nick Terrell
e859862341 [regression] Add dictionary support
Dictionaries are prebuilt and saved as part of the data object.
The config decides whether or not to use the dictionary if it is
available. Configs that require dictionaries are only run with
data that have dictionaries. The method will skip configs that are
irrelevant, so for example ZSTD_compress() will skip configs with
dictionaries.

I've also trimmed the silesia source to 1MB per file (12 MB total),
and added 500 samples from the github data set with a dictionary.

I've intentionally added an extra line to the `results.csv` to make
the nightly build fail, so that we can see how CircleCI reports it.

Full list of changes:

* Add pre-built dictionaries to the data.
* Add `use_dictionary` and `no_pledged_src_size` flags to the config.
* Add a config using a dictionary for every level.
* Add a config that specifies no pledged source size.
* Support dictionaries and streaming in the `zstdcli` method.
* Add a context-reuse method using `ZSTD_compressCCtx()`.
* Clean up the formatting of the `results.csv` file to align columns.
* Add `--data`, `--config`, and `--method` flags to constrain each
  to a particular value. This is useful for debugging a failure
  or debugging a particular config/method/data.
2018-11-30 18:23:01 -08:00
Yann Collet
d8e215cbee created ZSTD_compress2() and ZSTD_compressStream2()
ZSTD_compress_generic() is renamed ZSTD_compressStream2().

Note that, for the time being,
the "stable" API and advanced one use different parameter planes :
setting parameters using the advanced API does not influence ZSTD_compressStream()
and using ZSTD_initCStream() does not influence parameters for ZSTD_compressStream2().
2018-11-30 11:25:56 -08:00
Yann Collet
090bc808a8
Merge pull request #1432 from terrelln/regression
[regression] Add initial regression test framework
2018-11-29 16:06:40 -08:00
Nick Terrell
4aaa36f74b [regression] Add initial regression test framework
The regression tests run nightly or on the `regression`
branch for convenience. The results get uploaded as the
artifacts of the job. If they change, check the diff
printed in the job. If all is well, download the new
results and commit them to the repo.

This code will only run on a UNIX like platform. It
could be made to run on Windows, but I don't think that
it is necessary. It also uses C99.

* data: This module defines the data to run tests on.
  It downloads data from a URL into a cache directory,
  checks it against a checksum, and unpacks it. It also
  provides helpers for accessing the data.
* config: This module defines the configs to run tests
  with. A config is a set of API parameters and a set of
  CLI flags.
* result: This module is a helper for method that defines
  the result type.
* method: This module defines the compression methods
  to test. It is what runs the regression test using the
  data and the config. It reports the total compressed
  size, or an error/skip.
* test: This is the test binary that runs the tests for
  every (data, config, method) tuple, and prints the
  results to the output file and stderr.
* results.csv: The results that the current commit is
  expected to produce.
2018-11-29 14:33:04 -08:00
Lzu Tao
d095adf9fb Add simple test for zstdgrep 2018-11-29 03:39:47 +07:00
Yann Collet
d4d4e109e9 getParameter fills an int*
rather than an unsigned*
for consistency
since type of setParameter() changed to int.
2018-11-21 15:37:26 -08:00
Yann Collet
41c7d0b1e1 changed hashEveryLog into hashRateLog 2018-11-21 14:36:57 -08:00
Yann Collet
2e7fd6a2cb fixed remaining searchLength invocations 2018-11-20 15:13:27 -08:00
Yann Collet
e874dacc08 changed searchLength into minMatch
refactored all relevant API and calls
for consistency.
2018-11-20 14:56:07 -08:00
Yann Collet
3b838abf97 ZSTD_CCtx_setParameter : value argument is now int
for compatibility with compression level
2018-11-20 11:53:01 -08:00
Yann Collet
f07e13b729 fixed fuzz src 2018-11-15 16:53:45 -08:00
Yann Collet
5c68639186 updated ZSTD_DCtx_reset()
signature and behavior is now the same as ZSTD_CCtx_reset()
2018-11-15 16:12:39 -08:00
Yann Collet
06c8d5a4f4 Merge branch 'dev' into advancedAPI
fixed rsyncable
2018-11-15 10:51:24 -08:00
Nick Terrell
71fe78cbf9 [tests] Add rsyncable tests 2018-11-14 17:00:29 -08:00
Yann Collet
cf9f4b63b8 fixed fuzz test src code 2018-11-14 14:46:49 -08:00
Yann Collet
7b0391e37e finalized retrofit of ZSTD_CCtx_reset()
updated all depending sources
2018-11-14 13:05:35 -08:00
Yann Collet
5adbad4059 Merge branch 'dev' into advancedAPI 2018-11-14 13:00:37 -08:00
Yann Collet
c584e84e68
Merge pull request #1415 from facebook/benchfn
Separating benchfn and benchzstd
2018-11-14 13:00:08 -08:00
Yann Collet
d7e10a774a added constant ZSTD_WINDOWLOG_LIMIT_DEFAULT
answering #1407.

Also : removed obsolete function ZSTD_setDStreamParameter()
which could only be used with one parameter (DStream_p_maxWindowSize).
Now replaced by ZSTD_DCtx_setWindowSize() (which exists since a few revisions)
2018-11-13 18:12:34 -08:00
Yann Collet
b83d1e7714 removed some static const variables
and replaced by traditional macro constants.

Unfortunately, C doesn't consider `static const` to mean "constant"
2018-11-13 16:56:32 -08:00
Yann Collet
975abf8f5d circumvent gcc-8 strict aliasing warning
because gcc considers that
`void* const *`  and `void**` are 2 different types ...
2018-11-13 16:04:35 -08:00
Yann Collet
b830ccca5c changed benchfn api
to use structure for function parameters
as it expresses much clearer than a long list of parameters,
since each parameter can now be named.
2018-11-13 13:12:50 -08:00
Yann Collet
d38063f8ae separated bench module into benchfn and benchzstd
it shall be possible to use benchfn
without any dependency on zstd.
2018-11-13 11:01:59 -08:00
W. Felix Handte
2242330b26 Fix Fuzz Range 2018-11-12 13:01:14 -08:00
Yann Collet
1b4a9c518b
Merge pull request #1410 from facebook/prefetch_dec
improve long-range decoder speed
2018-11-08 18:41:58 -08:00
Yann Collet
f40c6b4395 added a simple test case for decode-only benchmark mode
as it was broken and no one noticed
2018-11-08 12:51:42 -08:00
Nick Terrell
103d1ee7a4 Add multithreaded dictbuilder tests to fuzzer.c 2018-11-08 10:58:51 -08:00
Yann Collet
3e5cdf1b6a fixed T36302429 2018-11-05 17:50:30 -08:00
Yann Collet
3a90229616
Merge pull request #1395 from facebook/decompressblock
created zstd_decompress_block module
2018-10-29 16:28:09 -07:00
Yann Collet
1866bd374a Merge branch 'dev' into huf_Refactor 2018-10-26 15:25:01 -07:00
Yann Collet
450356b5af Merge branch 'dev' into decompressblock 2018-10-26 15:03:43 -07:00
Yann Collet
7b74405150 refactor HUF_compress_internal for clarity
changed workspace parameter convention
to always provide workspaceSize,
so that size can be explicitly checked.

Also, use more enum to make the meaning of some parameters more explicit.
2018-10-26 13:21:37 -07:00
Yann Collet
b832498aee fixed : extraneous function prototype in fullbench.c
now provided through zstd_internal.h
2018-10-26 10:39:49 -07:00
Yann Collet
806a5c84e4 support decompressing an empty frame into NULL
fix #1385
decompressing into NULL was an automatic error.
It is now allowed, as long as the content of the frame is empty.

Seems to simplify things for `arrow`.
Maybe some other projects rely on this behavior ?
2018-10-24 16:34:35 -07:00
Yann Collet
b7421f8e69 fix and refactored libzstd_partial_build.sh
make the test intention clearer
(easier to maintain)

also resist the existence of zstd_ddict.o within libzstd.a
2018-10-24 11:32:09 -07:00
Yann Collet
debff3929b fixed warnings in testpools 2018-10-24 10:36:06 -07:00
Yann Collet
c81236620f
Merge pull request #1380 from facebook/decodecorpus
fix decodecorpus incorrect frame generation
2018-10-22 11:57:12 -07:00
Ethan Jones
953c7b9463 Fix libFuzzer location in makefile.
libFuzzer was moved into compiler-rt, update the repo location
accordingly.
2018-10-22 11:19:13 -05:00
Yann Collet
f181799082 fix decodecorpus incorrect frame generation
fix #1379
decodecorpus was generating one extraneous byte when `nbSeq==0`.
This is disallowed by the specification.

The reference decoder was just skipping the extraneous byte.
It is now stricter, and flag such situation as an error.
2018-10-20 18:56:21 -07:00
Yann Collet
f2cff22804
Merge pull request #1368 from rkjain89/test-branch
Moving Code To util.c
2018-10-19 16:31:10 -07:00
Rohit Jain
5dc9443053 Changing tests/fuzz/Makefile to move util.o to FUZZ_SRC instead 2018-10-12 19:06:58 -07:00
Rohit Jain
535226cadb Fixing poolTests, I will understand about cmake and VStudio and push them in a later commit 2018-10-12 11:36:02 -07:00
Rohit Jain
23e727e3a2 Fixing regressiontest makefile 2018-10-11 17:08:42 -07:00
Rohit Jain
b19140bc13 Fixed makefile and removed multiple definitions from util.h (UTIL_getTime) 2018-10-11 15:17:40 -07:00
Yann Collet
1e6208e75e bumped version number to v1.3.7
updated documentation
2018-10-11 14:40:12 -07:00
Rohit Jain
f881ee8c48 Moving code to util.c 2018-10-11 14:38:41 -07:00
Yann Collet
33d643124d fixed fullbench-lib target 2018-10-04 18:12:36 -07:00
Yann Collet
efbc3e823d fixed paramgrill wrong assert() conditions
and slightly refactored affected function.

Honestly, the formula calculating variance should get a second reviewing round,
it's not clear if it's correct.
2018-10-04 14:27:13 -07:00
Yann Collet
c9843ec232
Merge pull request #1348 from facebook/donotdelete
Fix #1082
2018-10-02 16:37:58 -07:00
Yann Collet
9012b6cba0 ./zstd -f do no longer overwrite destination file
if source file does not exist (#1082)
2018-10-01 17:16:34 -07:00
Yann Collet
c7bd6a41ab zstd -d -f do no longer erase destination file
when source file does not exist (#1082)
2018-10-01 14:04:00 -07:00
Nick Terrell
eb4423e7ed Fix another warning 2018-09-28 14:24:38 -07:00
Nick Terrell
0e7a7f1def Fix warnings 2018-09-28 12:14:24 -07:00
Nick Terrell
146049a1ea [zstreamtest] Add failing test case 2018-09-28 12:09:14 -07:00
Nick Terrell
e06f91a169
Merge pull request #1343 from terrelln/faster-ci
[zstreamtest] Reduce memory of newapi tests
2018-09-27 19:29:02 -07:00
Yann Collet
913a0365b6 Merge branch 'dev' into donotdelete 2018-09-27 19:23:55 -07:00
Yann Collet
ff36513556 fixed longmatch test too 2018-09-27 18:24:41 -07:00
Yann Collet
73773c6b6a fixed legacy compilation tests
for some reason, these tests started failing recently on CircleCI
2018-09-27 18:15:14 -07:00
Yann Collet
9b45db7fa6 minor refactoring of --list
trying to reduce recurrent patterns.
2018-09-27 16:49:08 -07:00
Nick Terrell
d8c73cd607 Reset number of threads less often 2018-09-27 15:49:31 -07:00
Nick Terrell
f2d6db45cd [zstd] Add -Wmissing-prototypes 2018-09-27 15:24:48 -07:00
Nick Terrell
7ee910e86b More aggressive limitations 2018-09-27 13:55:24 -07:00
Nick Terrell
ca0cfa3dbd [zstreamtest] Reduce memory of newapi tests
We could allocate up to 2^28 bytes of memory when using 2 threads with
window log = 24. Now, we limit it to 2^26 bytes of memory when not running
big tests.

I chose max window log = 22 since that is the maximum source size when
big tests are disabled. Hopefully this will be enough to reduce or
eliminate the test failures.
2018-09-27 12:48:29 -07:00
Yann Collet
2a5cd8535a
Merge pull request #1342 from facebook/fixcatyd
fix : huge (>4GB) chain of blocks
2018-09-27 10:20:14 -07:00
Yann Collet
9bce916732
Merge pull request #1340 from terrelln/generate-artifacts
Publish artifacts with CircleCI
2018-09-26 15:52:23 -07:00
Yann Collet
8883af6a1e
Merge pull request #1327 from facebook/adapt
Adaptive compression
2018-09-26 14:39:08 -07:00
Yann Collet
f98c69d77c fix : huge (>4GB) stream of blocks
experimental function ZSTD_compressBlock() is designed for very small data in mind,
for situation where saving the ~12 bytes of frame header can actually make a difference.

Some systems though may have to deal with small and large data entangled.
If it's larger than a block (> 128KB), compressBlock() cannot compress them in one round.

That's why it's possible to compress in multiple rounds.
This is a chain of compressed blocks.

Some users push this capability to the limit, encoding gigantic chain of blocks.
On crossing the 4GB limit, some internal overflow occurs.

This fix moves the overflow correction mechanism higher in the call chain,
so that it's applied also to gigantic chains of blocks.

Added a test case in fuzzer.c, which crashes before the fix, and pass now.
2018-09-26 14:24:28 -07:00
Yann Collet
65ed6eeefb
Merge pull request #1337 from facebook/test_failure
fixed `!` tests
2018-09-26 13:40:20 -07:00
Yann Collet
8ff17a6a09
Merge pull request #1329 from facebook/v04isout
Changed default legacy support to v0.5+
2018-09-26 13:39:05 -07:00
Nick Terrell
3ff6040848 Publish artifacts with CircleCI
* Updates CircleCI to use workflows.
  We can now specify any number of test jobs to run in parallel.
* Switch the image to `buildpack-deps:trusty` which is only 500 MB
  instead of 7 GB, so that saves 7 minutes to download it if it isn't
  already cached on the host.
* Publish the source tarball and sha256sum as artifacts.
* If the `GITHUB_TOKEN` environment variable is set, we will also
  add the tarball + sha256sum to the tagged release, after manual
  approval.
2018-09-26 13:23:28 -07:00
Yann Collet
6c51bf420c bounds for --adapt mode
can supply min and max compression level through advanced command :
--adapt=min=#,max=#
2018-09-25 16:03:28 -07:00
Yann Collet
63abaf2171 fixed ! tests
Sometimes, it's necessary to test that a certain command fail, as expected.
Such failure is actually a success, and must not stop the flow of tests.

Several tests were prefixed with `!` to invert return code.
This does not work : it effectively makes the tests pass no matter what.

Use instead function die(), which is meant to trap successes, and transform them into errors.
2018-09-25 15:57:28 -07:00
Yann Collet
04f47bbdd2 Merge branch 'dev' into adapt 2018-09-24 16:56:45 -07:00
Yann Collet
0e211bdd18 fixed constant comparison on 32-bits systems 2018-09-21 18:23:32 -07:00
Yann Collet
484f40697b fix constant redeclaration in paramgrill 2018-09-21 17:28:37 -07:00
Yann Collet
a54c86cfc6 defined a minimum negative level
which can be probed using new function ZSTD_minCLevel().

Also : redefined ZSTD_TARGETLENGTH_MIN/MAX for consistency

used the opportunity to bump version number to v1.3.6
2018-09-20 16:52:03 -07:00
Yann Collet
db97310ace fixed versions-test to only test v0.5+
since zstd_devel is no longer compatible with v0.4+
2018-09-20 14:59:11 -07:00
Yann Collet
15519479ba fixed minor gcc warning on a unused variable 2018-09-20 13:00:11 -07:00
Yann Collet
45010da074 updated man page
and added `--adapt` test in `playTests.sh`
2018-09-19 17:37:22 -07:00
Yann Collet
2f78228f65 Merge branch 'dev' into adapt 2018-09-19 12:43:42 -07:00
Björn Ketelaars
06fd1e473d 'head -c BYTES' is non-portable.
tests/playTests.sh uses 'head -c' in a couple of tests to truncate the
last byte of a file. The '-c' option is non-portable (not in POSIX).
Instead use a wrapper around dd (truncateLastByte).
2018-09-17 20:39:35 +02:00
Yann Collet
d195eec97e fixed msan error
cold dictionary is detected through a comparison with dictEnd,
which was not initialized at the beginning of first DCtx usage.
2018-09-13 12:29:52 -07:00
Yann Collet
31ebb26945
Merge pull request #1301 from terrelln/lit-size
[zstd] Fix seqStore growth
2018-08-28 17:10:25 -07:00
Nick Terrell
e3b5286197 Fix decodecorpus 2018-08-28 13:56:47 -07:00
Nick Terrell
e984d01912 Small test fixes 2018-08-28 13:42:01 -07:00
Nick Terrell
5a4e6c9f3d [fuzzer] Test growing the seqStore_t 2018-08-28 13:20:37 -07:00
Yann Collet
b37a0a6bde
Merge pull request #1298 from facebook/bench
Refactored bench.c
2018-08-28 12:25:02 -07:00
Yann Collet
55affc09de timedFn : measurement delay is programmable
instead of hard-coded 1 second per measurement
2018-08-28 11:26:27 -07:00
Yann Collet
0ff9b67552 paramgrill: removed useless tests
designed to compensate iter_mode,
but since only time_mode is available now,
all tests are guaranteed to last a minimum amount of time.
2018-08-27 19:07:17 -07:00
Yann Collet
9e26893e07 paramgrill: fixed a bunch of div-by-zero
they were pretty easy to trigger by the way,
just start an extended paramgrill session
to find a compression table based on any sample,
it would necessarily happen at some point.
2018-08-27 18:47:09 -07:00
Yann Collet
0071e8348f restored assert() in paramgrill
assert() in paramgrill are not in the benchmark path.
They should remain active, as they don't impact measurements, and their runtime is insignificant.
2018-08-27 17:52:04 -07:00
Yann Collet
01dcd0fd17 bench: minor api update, for consistency
BMK_benchTimedFn()
BMK_isCompleted_TimedFn() uses TimedFnState
2018-08-26 21:30:18 -07:00
Yann Collet
c3a4baaf6e fixed minor warnings
valgrind: memory leak of a few bytes in fullbench
static analyzer: uninitialized data passed as result
2018-08-24 23:25:35 -07:00
Yann Collet
af23d39eb8
Merge pull request #1297 from felixhandte/check-offset-table
Fix Missing Offset Table Check
2018-08-24 17:36:44 -07:00
Yann Collet
2279f3d127 bench: reduce nb of return type
runOutcome is enough
removed timedFnOutcome
2018-08-24 17:28:38 -07:00
W. Felix Handte
db4c8d05b3 Add Failing Test 2018-08-24 14:30:21 -07:00
Yann Collet
7b23cc4d1e fixed fullbench behavior
now same as v1.3.5
2018-08-24 12:40:10 -07:00
Yann Collet
4da5bdf482 fixed zstd -b speed result
the benchmark was displaying the speed of last run
instead of the best of all previous runs.
2018-08-23 18:13:49 -07:00
Nick Terrell
3b56bb1e4c Fix decodecorpus 2018-08-23 17:48:06 -07:00
Yann Collet
b0e1f3982d fixed paramgrill
to work with new bench.c
2018-08-23 17:21:38 -07:00
Yann Collet
1f9ec13621 introduced MB_UNIT
so that all benchmarking programs use the same speed scale
2018-08-23 16:03:30 -07:00
Yann Collet
d39a25c5ed update fullbench.c to work with new bench.h 2018-08-23 15:00:09 -07:00
Jennifer Liu
9d6ed9def3 Merge fastCover into DictBuilder (#1274)
* Minor fix

* Run non-optimize FASTCOVER 5 times in benchmark

* Merge fastCover into dictBuilder

* Fix mixed declaration issue

* Add fastcover to symbol.c

* Add fastCover.c and cover.h to build

* Change fastCover.c to fastcover.c

* Update benchmark to run FASTCOVER in dictBuilder

* Undo spliting fastcover_param into cover_param and f

* Remove convert param functions

* Assign f to parameter

* Add zdict.h to Makefile in lib

* Add cover.h to BUCK

* Cast 1 to U64 before shifting

* Remove trimming of zero freq head and tail in selectSegment and rebenchmark

* Remove f as a separate parameter of tryParam

* Read 8 bytes when d is 6

* Add trimming off zero frequency head and tail

* Use best functions from COVER and remove trimming part(which leads to worse compression ratio after previous bugs were fixed)

* Add finalize= argument to FASTCOVER to specify percentage of training samples passed to ZDICT_finalizeDictionary

* Change nbDmer to always read 8 bytes even when d=6

* Add skip=# argument to allow skipping dmers in computeFrequency in FASTCOVER

* Update comments and benchmarking result

* Change default method of ZDICT_trainFromBuffer to ZDICT_optimizeTrainFromBuffer_fastCover

* Add dictType enum and fix bug about passing zParam when converting to coverParam

* Combine finalize and skip into a single parameter

* Update acceleration parameters and benchmark on 3 sample sets

* Change default splitPoint of FASTCOVER to 0.75 and benchmark first 3 sample sets

* Initialize variables outside of for loop in benchmark.c

* Update benchmark result for hg-manifest

* Remove cover.h from install-includes

* Add explanation of f

* Set default compression level for trainFromBuffer to 3

* Add assertion of fastCoverParams in DiB_trainFromFiles

* Add checkTotalCompressedSize function + some minor fixes

* Add test for multithreading fastCovr

* Initialize segmentFreqs in every FASTCOVER_selectSegment and move mutex_unnlock to end of COVER_best_finish

* Free segmentFreqs

* Initialize segmentFreqs before calling FASTCOVER_buildDictionary instead of in FASTCOVER_selectSegment

* Add FASTCOVER_MEMMULT

* Minor fix

* Update benchmarking result
2018-08-23 12:06:20 -07:00
Yann Collet
77e805e3db bench: changed creation/reset function to timedFnState
for consistency
2018-08-21 18:19:27 -07:00
Yann Collet
801e3bcd97
Merge pull request #1290 from edenzik/ezik/1119-safe-strcpy-in-fileio
Fixed unsafe string copy and concat in `fileio.c`.
2018-08-21 13:18:44 -07:00
Eden Zik
78af534f82 Fixed unsafe string copy and concat in fileio.c.
Per warnings from flawfinder: "Does not check for buffer overflows when
copying to destination [MS-banned] (CWE-120). Consider using snprintf,
strcpy_s, or strlcpy (warning: strncpy easily misused).".

Replaced called to strcpy and strcat in `fileio.c` to calls with a
specified size (`strncpy` and `strncat`).

Tested the changes on OSX, Linux, Windows.
On OSX + Linux, changes were tested with ASAN. The following flags were
used: 'check_initialization_order=1:strict_init_order=1:detect_odr_violation=1:detect_stack_use_after_return=1'

To reproduce warning:
./flawfinder.py ./programs/fileio.c
2018-08-20 22:15:24 -04:00
Yann Collet
ea0b5fc193
Merge pull request #1285 from facebook/scanbuild
static analyzer tests
2018-08-17 16:38:41 -07:00
Yann Collet
b4e7f71055 Merge branch 'dev' into adapt 2018-08-17 15:54:13 -07:00
George Lu
3959ba15e6 Clarify README 2018-08-16 17:22:29 -07:00
George Lu
8175b28f03 Fix negative lvl display value
Also fix synthetic benchmark parameter setting
2018-08-16 16:46:37 -07:00
George Lu
239e114d62 prune comments 2018-08-15 16:04:34 -07:00
George Lu
8a296d3e1f Move Stuff around
Group similar functions together, remove outdated comments
2018-08-15 16:04:34 -07:00
George Lu
3f8b10baa1 consts 2018-08-15 16:04:34 -07:00
George Lu
46be2ef5d8 Remove unused stuff 2018-08-15 16:04:34 -07:00
George Lu
b234870c33 clarify display README 2018-08-15 14:29:49 -07:00
George Lu
ee77ddc28d Fix wraparound 2018-08-15 14:01:32 -07:00
George Lu
1e8d352930 silencing params 2018-08-15 14:01:32 -07:00
George Lu
2c5fdae0ae Clean up repetitive display
Add documentation
2018-08-15 14:01:32 -07:00
George Lu
4d9c6f51b8 -q -v options 2018-08-15 14:01:32 -07:00
George Lu
3dcfe5cc2c begin display changes 2018-08-15 14:01:32 -07:00
Yann Collet
3692c31598 Merge branch 'dev' into scanbuild 2018-08-15 13:50:49 -07:00
George Lu
b1d9ca737a Add memoTable options
-hashing memotable
-no memotable
2018-08-15 10:19:38 -07:00
George Lu
8c918edd3a MAke it easier to add params
Make memoTable size limited
2018-08-14 16:15:46 -07:00
George Lu
96725989ef Temp fix perf regression 2018-08-14 16:14:37 -07:00
George Lu
3f2d024dca forceAttachDict 2018-08-14 14:24:41 -07:00
George Lu
e3c679484a Add Time Checks
Fix double -> U64 display
2018-08-14 14:24:41 -07:00
George Lu
88dda92285 Reduce Duplication
Change Defaults
Asserts actually disabled in paramgrill + fullbench
2018-08-14 14:24:41 -07:00
George Lu
f581ccd267 Doc Updates
Add option to pass in existing parameters in use
2018-08-14 14:24:41 -07:00
George Lu
76acba025d scan-build 2018-08-14 12:13:05 -07:00
George Lu
614aaa3ae1 rebase clevel 2018-08-14 10:53:04 -07:00
George Lu
3b36fe5c68 strategy switching 2018-08-13 16:36:14 -07:00
George Lu
d4730a4f66 Update fulltable to use same interface
Add seperateFiles flag
2018-08-13 16:15:52 -07:00
George Lu
43b4971ca8 Renames, Documentation Updates 2018-08-13 16:15:52 -07:00
George Lu
a884b76bc2 Style Changes
Add single run dictionaries
Change MB to be consistent 1 << 20 rather than 1,000,000
2018-08-13 16:15:52 -07:00
George Lu
b3544217b7 Cleanup 2018-08-13 16:15:52 -07:00
George Lu
8ff0de15e4 Generalize, macro magic numbers 2018-08-13 16:15:52 -07:00
George Lu
3a2e95eba4 Perf improvements
try decay
strategy selection skipping
2018-08-13 16:15:52 -07:00
George Lu
2bdfe6ca71 Better Display 2018-08-13 16:15:52 -07:00
George Lu
f67d040c39 Bugfixes, style changes
Complete euclidean distance climb
2018-08-13 16:15:52 -07:00
George Lu
5f4502fc07 New climb
feas part 2 uses euclidean metric
2018-08-13 16:15:52 -07:00
George Lu
13611249a5 Table
Compiling
+Euclidean Metric
2018-08-13 16:15:52 -07:00
George Lu
0cea754024 Revert "Reorder declaration"
This reverts commit 3ac2c22485.
2018-08-13 16:15:34 -07:00
George Lu
486e586eed Revert "Default lvl 1"
This reverts commit 0cc75d6ee0.
2018-08-13 16:13:46 -07:00
George Lu
0cc75d6ee0 Default lvl 1
MB to 2^20
2018-08-13 14:55:56 -07:00
Yann Collet
09c9cf3f51 simplified rateLimiter
resists better to changing in/out conditions
limits risks of "catching up"
2018-08-13 12:13:47 -07:00
Yann Collet
e11f91b039 remove error message for Ctrl+C 2018-08-13 11:48:25 -07:00
Yann Collet
f3aa510738 rateLimiter does not "catch up" when input speed is slow 2018-08-13 11:38:55 -07:00
Yann Collet
a996b1fd2d fixed rate limited for high speed 2018-08-10 17:39:00 -07:00
Yann Collet
681a382eea added rateLimiter.py, by @felixhandte
this rate limiter avoid the problem of `pv`
which "catch up" after a blocked period
instead of preserving a constant speed cap.
2018-08-10 12:25:52 -07:00
George Lu
3ac2c22485 Reorder declaration 2018-08-09 16:38:32 -07:00
George Lu
bfe8392e23 Remove ctx from benchMem 2018-08-09 12:07:57 -07:00
George Lu
0ece2e5cdc Add consts
+ fix gcc-8 warnings
2018-08-09 11:38:09 -07:00
George Lu
6f480927af argument parsing cleanup
+ clarifying comment
2018-08-09 10:42:58 -07:00
George Lu
ad16a69408 Readability improvements, renaming 2018-08-09 10:42:58 -07:00
George Lu
8278a49cb6 const srcPtrs 2018-08-09 10:42:58 -07:00
George Lu
3d230db853 Change speed representation from floating point to integral 2018-08-09 10:42:58 -07:00
George Lu
8faeb41679 Update Documentation
Change comment // to  /* */
Add more description of what functions do
Remove outdated comments
2018-08-09 10:42:58 -07:00
George Lu
dd270b2f75 Renaming / Style fixes 2018-08-09 10:42:58 -07:00
George Lu
e148db366e Separate capacity vs size
Also:
Make suggested fixes
-varInds_t
-reorder some arguments
-remove code duplication
-update README / -h
-Fix memory leaks
2018-08-09 10:42:58 -07:00
George Lu
df026e159f Fix windows implicit casting bugs 2018-08-09 10:42:58 -07:00
George Lu
0f91b039ff Add Levels 2018-08-09 10:42:58 -07:00
George Lu
7b5b3d7ae3 BenchMem with block compressed sizes passed back up 2018-08-09 10:42:58 -07:00
George Lu
3adc217ea4 Total Changes:
Add different constraint types (decompression speed, compression memory, parameter constraints)
Separate search space by strategy + strategy selection
Memoize results
Real random restarts
Support multiple files
Support Dictionary inputs
Debug Macro for extra printing
2018-08-09 10:42:58 -07:00
George Lu
fab4438801 Dictionary + Multiple file Loading 2018-08-09 10:42:58 -07:00
George Lu
eb21b7f482 Not crashing 2018-08-09 10:42:58 -07:00
George Lu
5f49034520 Working V1 2018-08-09 10:42:58 -07:00
George Lu
cffb6da339 Parses additional parameters
Additional constraint checking

Minor fixes

more param parsing

Add Memory

Change paramVariation

work on feasibility

reformat bench

Changed Paramgrill to use bench.c benchmarking

customlevel macro

Printing Flag

Minor changes

Explicit casting

Makefile fix

casting, type fix

Printing Flag

Minor Changes

comments, helper fn's
2018-08-09 10:42:58 -07:00
Yann Collet
5808027abf Merge branch 'dev' into fix1241 2018-08-03 16:08:33 -07:00
Nick Terrell
b9faaa1dc3 [FSE] Add division by zero test 2018-07-30 13:24:09 -07:00
cyan4973
3f535007e4 fix %zu support under minGW
and relevant test on Appveyor
2018-07-30 16:56:18 +02:00
cyan4973
aade1e5904 Merge branch 'dev' into fix1241 2018-07-30 16:30:35 +02:00
cyan4973
3d4b09a5aa support %zu under mingw 2018-07-30 16:29:20 +02:00
Yann Collet
effa84c8d1
Merge pull request #1230 from terrelln/train-out
zstdcli: Allow -o before --train
2018-07-18 16:34:10 +02:00
Yann Collet
6e490a2f09
Merge pull request #1237 from terrelln/init-cstream-adv
Set requestedParams in ZSTD_initCStream*()
2018-07-18 16:33:30 +02:00
cyan4973
7d1bc9cc8c fix minor conversion warning 2018-07-18 16:10:23 +02:00
cyan4973
9597b438e9 fix #1241
Ensure that first input position is valid for a match
even during first usage of context
by starting reference at 1
(avoiding the problematic 0).
2018-07-17 18:52:57 +02:00
Nick Terrell
58b8219475 zstdcli: Allow -o before --train
Only set the default value if `outFileName` is unset.

Fixes #1227.
2018-07-16 12:45:34 -07:00
Nick Terrell
45821fac0c
Merge pull request #1225 from jennifermliu/dev
Split samples when building dictionary for COVER
2018-07-13 13:26:15 -07:00
Nick Terrell
6d222c437c Set requestedParams in ZSTD_initCStream*()
The correct parameters are used once, but once `ZSTD_resetCStream()` is
called the default parameters (level 3) are used. Fix this by setting
`requestedParams` in the `ZSTD_initCStream*()` functions.

The added tests both fail before this patch and pass after.
2018-07-12 18:35:55 -07:00
Dmitry V. Levin
7ca12a1455 tests: use /dev/zero instead of /dev/random on all systems except GNU/Hurd
https://github.com/facebook/zstd/pull/1124 broke the test suite
on Linux.  Looks like GNU/Hurd is the only operating system where
/dev/random is available for writing by unprivileged processes.

https://github.com/facebook/zstd/pull/1222 reverted the change
introduced by https://github.com/facebook/zstd/pull/1124 for OpenBSD
only, other operating systems need that change to be reverted, too.

Fixes: 2dde9d5aba ("Write to /dev/random for test")
Complements: 276988f794 ("OpenBSD is unable to write to /dev/zero")
2018-07-11 12:41:50 +00:00
Jennifer Liu
a085d1aae1 Allow splitPoint==1.0 (using all samples for both training and testing) 2018-07-05 10:38:45 -07:00
Yann Collet
1bf0784975
Merge pull request #1206 from GeorgeLu97/FullBenchParam
Fullbench Param
2018-07-02 13:33:53 -07:00
Yann Collet
689bfecd48
Merge pull request #1188 from GeorgeLu97/BenchModule
Bench module
2018-07-02 13:33:27 -07:00
Jennifer Liu
1a14f8639c Update COVER dictionary builder tests 2018-07-02 11:37:04 -07:00
Björn Ketelaars
527dbf89ec xz/lzma warning causes test to fail
OpenBSD's port building infrastructure is able to build in a privilege
separated mode. It uses a privilege drop model. Regression tests fail in
this mode as xz/lzma is unable to set file group and errors out with:

xz: tmp.xz: Cannot set the file group: Operation not permitted
gmake[1]: *** [Makefile:307: zstd-playTests] Error 2

Actually it is not a xz/lzma error but a warning causing zstd's
regression test to fail. Proposed fix is to have xz/lzma not set the
exit status to 2 even if a condition worth a warning was detected (-Q
flag).
2018-06-30 13:54:34 +02:00
Björn Ketelaars
276988f794 OpenBSD is unable to write to /dev/zero
https://github.com/facebook/zstd/pull/1124 fixes an issue with GNU/Hurd
being unable to write to /dev/zero. Implemented fix is writing to
/dev/random instead.

On OpenBSD a regular user is unable to write to /dev/random because of
permissions set on this device. Result is failing a regression test.

Proposed solution should work for all platforms.
2018-06-30 13:54:34 +02:00
Yann Collet
328ec7e34c fix test-zstd can be run with parallel compilation
fix #1221
2018-06-29 16:52:21 -07:00