Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clevel argument for Zstd #164

Merged
merged 11 commits into from
May 3, 2022
Merged

Add clevel argument for Zstd #164

merged 11 commits into from
May 3, 2022

Conversation

mkitti
Copy link
Contributor

@mkitti mkitti commented Mar 2, 2022

Fix #163

@t20100
Copy link
Member

t20100 commented Mar 3, 2022

Thanks for the PR!

@mkitti
Copy link
Contributor Author

mkitti commented Mar 3, 2022

tests should be passing now.

@mkitti
Copy link
Contributor Author

mkitti commented Mar 3, 2022

Could someone approve the CI workflow so that it runs in full again?

@vasole
Copy link
Member

vasole commented Mar 3, 2022

done

@mkitti
Copy link
Contributor Author

mkitti commented Mar 3, 2022

Great. Thank you. Looks like all the CI passes now as well.

@mkitti
Copy link
Contributor Author

mkitti commented Mar 3, 2022

One issue I encountered in testing is the inability to access negative levels:
https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L51-L52

The library also offers negative
compression levels, which extend the range of speed vs. ratio preferences.
The lower the level, the faster the speed (at the cost of compression).

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find an issue with the ZSTD HDF5 filter which clips the clevel to [1, 22]:
https://github.com/aparamon/HDF5Plugin-Zstandard/blob/d5afdb5f04116d5c2d1a869dc9c7c0c72832b143/zstd_h5plugin.c#L38-L39

Since negative values are not currently supported, there are a minor updates to do.

src/hdf5plugin/__init__.py Outdated Show resolved Hide resolved
src/hdf5plugin/__init__.py Outdated Show resolved Hide resolved
src/hdf5plugin/__init__.py Outdated Show resolved Hide resolved
src/hdf5plugin/__init__.py Outdated Show resolved Hide resolved
Comment on lines 183 to 185
{'clevel': 0},
{'clevel': -1},
{'clevel': -1000}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still test that 0 and negative values "work"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, an assert on the clevel value would be best.

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done!
To be inline with other filters, it would be good to check the input value is in the accepted range (and remove tests for clevel <= 0).

Comment on lines 183 to 185
{'clevel': 0},
{'clevel': -1},
{'clevel': -1000}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, an assert on the clevel value would be best.

"""
filter_id = ZSTD_ID

def __init__(self, clevel=None):
if clevel is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An assert on clevel would be good: For the other filters we have assert on the input arguments when possible. We do so since error messages from hdf5 can be hard to understand for end-users.
Example for blosc: https://github.com/silx-kit/hdf5plugin/blob/main/src/hdf5plugin/__init__.py#L201

Suggested change
if clevel is not None:
if clevel is not None:
assert 1 <= clevel <= 22

src/hdf5plugin/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR and the updates!

@t20100 t20100 added this to the Next release milestone Mar 4, 2022
@t20100 t20100 merged commit 6aeb14c into silx-kit:main May 3, 2022
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.

Aggression argument for Zstd aggression
3 participants