1
0
mirror of https://github.com/lz4/lz4.git synced 2026-10-24 01:48:57 +03:00

18 Commits

Author SHA1 Message Date
Yann Collet
88ed0b630e api: LZ4F_getMaxNbWorkers() reports multi-threading support ; CLI thread cap follows liblz4, lz4 -V reports multithreading (checkpoint)
LZ4F_getMaxNbWorkers() (static linking only, experimental like nbWorkers) :
0 when liblz4 is built without LZ4F_MULTITHREAD, otherwise the cap of nbWorkers,
now 1024 on 64-bit systems and 128 on 32-bit ones (was 200).
lz4 : build macro LZ4_NBWORKERS_MAX removed ; worker threads of frame and legacy
formats are capped by LZ4F_getMaxNbWorkers(), 1 without liblz4 multi-threading
(restores a cap for the legacy format on POSIX). lz4 -V reports "multithread"
only when both lz4 and liblz4 support it ; -T# warning and -v note accordingly.
VS2022 _test.bat checks the version line, catching a CLI built without LZ4F_MULTITHREAD
(same output, so no other observable difference).
frameMT : validateMaxNbWorkers ; test builds use LZ4F_NBWORKERS_MAX=128.
2026-10-22 12:58:19 -07:00
Yann Collet
bfd8019c02 memory: CLI memory budget (--memory, LZ4_MEMORY), no fixed nb of workers, single-threaded path without threads, no tmpBuff for MT frames, uncompressed segments as single-threaded (checkpoint)
Prototype, not intended for a PR as is.

- lz4 CLI : the automatic nb of workers (no -T, or -T0) is limited by a memory budget
  (4 GB, 1 GB on 32-bit systems), estimated from liblz4's job slots, input buffers and
  LZ4 states, plus the CLI's buffers (within ~5% of actual allocations when all are used).
  It's also limited to the nb of jobs of each file, when its size is known
  (ex: 3 threads for a 10 MB file, instead of 145 on a 166-core machine).
  -9 on 844 MB, 166 cores : unchanged auto (145 workers, ~3 GB budget estimate).
- --memory=# (suffixes K, M, G) and environment variable LZ4_MEMORY set the budget ;
  an explicitly set budget also limits an explicit -T#, as does the default one on 32-bit
  systems. A budget too small for 1 worker triggers a warning.
- lz4 CLI : no more fixed maximum nb of workers for frames (LZ4_NBWORKERS_MAX now only
  bounds the legacy format's thread pool) ; liblz4 keeps a sanity limit, raised to 1024
  (200 on 32-bit systems, where it keeps LZ4F_compressBound() within address space),
  overridable at compile time (tests : 200, keeping the capped test case affordable).
- liblz4 without LZ4F_MULTITHREAD (ex: default static library) : independent blocks take
  the single-threaded path (same output, no job buffers, no extra copies) ; linked blocks
  keep jobs processed serially (same output as multi-threaded, ~3% slower at level 1).
- liblz4 : frames cut into jobs no longer allocate tmpBuff (-4.1 MB, LZ4F_cctx_size()).
- liblz4 : LZ4F_uncompressedUpdate() with workers now cuts blocks as single-threaded mode :
  an incomplete last block waits for next uncompressed input (it was written immediately,
  producing different blocks for consecutive uncompressed invocations). With independent
  blocks, output is now identical to nbWorkers == 0 in all cases, and doesn't depend on
  multi-threading support. tests/frameMT.c compares uncompressed segments with
  single-threaded mode too. Full digest reference : 899dd7e3d21cad9a.
- Documented in man (-T#, --memory, LZ4_MEMORY, LZ4_NBWORKERS), programs/README.md, lz4frame.h.

Validated : full tests MT / no-MT (same digest), ASAN+UBSAN, TSAN, make test, wine,
CLI == dev CLI, lz4-nomt == lz4, memory budget scenarios, modification scenarios,
build policies, ~88k libFuzzer executions.
2026-10-22 04:26:50 -07:00
Yann Collet
2719f42eb5 removed year from header (#1605)
as it's a burden to maintain, and wasn't consistently updated.

Now rely on git dating.
2025-04-27 10:55:25 -08:00
Yann Collet
c78899a3a2 add support for environment variable LZ4_CLEVEL 2024-07-08 18:48:11 +02:00
Yann Collet
b7b0ee0a54 Add MT control via Environment variable LZ4_NBWORKERS 2024-07-06 23:04:43 +02:00
Yann Collet
8dd837fd44 document LZ4_NBWORKERS_MAX 2024-07-06 05:11:38 -07:00
Yann Collet
04341f1974 changed Makefile variable HAVE_THREAD -> HAVE_MULTITHREAD
and updated documentation `programs/README.md`
2024-07-06 01:55:50 -07:00
Yann Collet
604122c848 Makefile build automatically detect multithreading for Windows 2024-07-05 18:11:37 -07:00
Yann Collet
7a1b70502a fix variable LZ4IO_MULTITHREAD 2024-03-10 17:57:26 -07:00
Yann Collet
1230f1ca61 regrouped all compile-time variables into programs/lz4conf.h
also:
updated naming scheme for better consistency
2024-01-01 09:49:22 -08:00
Yann Collet
d61b4f1fe2 LZ4IO_MULTITHREADING can be forcefully disabled at compile time 2023-12-31 15:55:53 -08:00
Yann Collet
0d57b8262e Build variable LZ4_NBTHREADS_DEFAULT
can provide a different default nb of threads at compile time.
2023-12-31 00:18:07 -08:00
Yann Collet
21ff1a839a updated doc to underline difference between block and frame
as this is a very frequent source of confusion for new users.
2019-04-12 11:27:44 -07:00
Yann Collet
bcb26565a7 improved documentation for LZ4 dictionary compression 2019-04-11 15:20:46 -07:00
Przemyslaw Skibinski
632ab3b8d4 updated programs\README.md 2016-11-16 10:53:06 +01:00
Yann Collet
8195ba8f7b Updated man page 2016-11-04 18:29:07 -07:00
Przemyslaw Skibinski
8847faffbf updated programs/README.md 2016-11-03 16:17:38 +01:00
Yann Collet
67500142c1 Clarified license (#115, #244) 2016-11-01 19:14:04 -07:00