Skip to content

[core] Use the lz4 tool compression levels for LZ4 - #23748

Open
fwyzard wants to merge 1 commit into
root-project:masterfrom
fwyzard:lz4-compression-levels
Open

fwyzard wants to merge 1 commit into
root-project:masterfrom
fwyzard:lz4-compression-levels

Conversation

@fwyzard

@fwyzard fwyzard commented Oct 17, 2026

Copy link
Copy Markdown

This Pull request:

Changes or fixes:

Make the LZ4 compression levels follow those of the lz4 command line tool:

  • level 1: fast compressor, unchanged;
  • level 2: the "medium" compressor added in LZ4 1.10.0; with older LZ4 versions it stays on the fast compressor, as the lz4 tool does; use LZ4_versionNumber() to check the LZ4 version at runtime;
  • level 3: HC level 3;
  • levels 4-9: unchanged.

The on-disk format is unchanged, so files written with levels 2 and 3 remain readable by older ROOT versions. Users who explicitly write with LZ4 level 2 or 3 will get smaller files and slower compression.

Compressed size (in MiB and as a fraction of the input) and compression speed with R__zipMultipleAlgorithm, on a sample of 10 CMS proton-proton raw data events (13.53 MiB, compressed as a single buffer):

level before after, LZ4 1.10.0 after, LZ4 1.9.2
1 11.68 MiB (86.3%), 1339 MiB/s unchanged unchanged
2 11.68 MiB (86.3%), 1347 MiB/s 11.31 MiB (83.6%), 264 MiB/s unchanged
3 11.68 MiB (86.3%), 1343 MiB/s 11.07 MiB (81.8%), 77 MiB/s 11.07 MiB (81.8%), 76 MiB/s
4 11.03 MiB (81.5%), 72 MiB/s unchanged unchanged
... ... unchanged unchanged
9 11.00 MiB (81.3%), 52 MiB/s unchanged unchanged
image

Without this PR the levels 2 and 3 are identical to level 1.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Use the same compression levels as the lz4 command line tool: level 1 is
the fast compressor, level 2 is the medium compressor added in LZ4 1.10.0
(or the fast compressor with older versions), and higher levels use the
high-compression (HC) compressor with the given level.

With older LZ4 versions level 2 keeps using the fast compressor, as the
lz4 tool does. The on-disk format does not change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant