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

Include only built-in compression algorithms as enum variants #2121

Merged
merged 2 commits into from
Jul 14, 2023

Conversation

adamreichold
Copy link
Collaborator

This enables compile-time errors when a compression algorithm is requested which is not actually enabled for the current Cargo project. The cost is that indexes using other compression algorithms cannot even be loaded (even though they are not fully accessible in any case).

As a drive-by, this also fixes --no-default-features on cfg(unix).

Closes #2119

@adamreichold
Copy link
Collaborator Author

Just an idea I would to propose for discussion: I think having one really fast compression algorithm (LZ4) and one really flexible one (Zstd) might actually be enough and neither Brotli nor Snappy add anything substantially different.

@adamreichold adamreichold force-pushed the compression-feature-gate branch 2 times, most recently from 21c7194 to 8b8449d Compare July 12, 2023 17:47
@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2023

Codecov Report

Merging #2121 (72d37fd) into main (ad76e32) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main    #2121      +/-   ##
==========================================
+ Coverage   94.38%   94.39%   +0.01%     
==========================================
  Files         321      321              
  Lines       60809    60821      +12     
==========================================
+ Hits        57393    57413      +20     
+ Misses       3416     3408       -8     
Impacted Files Coverage Δ
src/core/index_meta.rs 96.14% <ø> (ø)
src/lib.rs 99.05% <ø> (ø)
src/store/compressors.rs 97.27% <100.00%> (+5.08%) ⬆️
src/store/decompressors.rs 98.21% <100.00%> (ø)

... and 6 files with indirect coverage changes

],
));
}
return Err(serde::de::Error::unknown_variant(
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's misleading though.

If the store is compressed with zstd but we don't have the feature flag, we will get an error message saying something like:

It is "zstd" but we expected something in "none", "lz4", "zstd"... etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will just adjust the deserialization error message to mention only those which were built-in and also point to those which could be enabled via additional feature flags.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will just adjust the deserialization error message to mention only those which were built-in and also point to those which could be enabled via additional feature flags.

Ah, the error message itself is generated by Serde. I did update the list of expected variants to match what is built-in though.

Should we keep it that way, or should I switch to custom error message to include reference to those which could be enable but are currently not?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest using a serde custom error, to tell that the compression format xxx is not available and suggestion that tantivy is maybe missing a compilation flag.

Rationale:
The unknown_variant seem appropriate here, but we really want a correct error message surfaced to the user.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@fulmicoton
Copy link
Collaborator

I am ok with hiding the enums. Can we however have an explicit error message about what feature is missing when opening an index with a compression format not compiled in the binary?

@fulmicoton
Copy link
Collaborator

might actually be enough and neither Brotli nor Snappy add anything substantially different.

I agree.
+1 for ditching Brotli and Snappy.

@adamreichold adamreichold force-pushed the compression-feature-gate branch from 8b8449d to 72d37fd Compare July 13, 2023 06:35
This enables compile-time errors when a compression algorithm is requested which
is not actually enabled for the current Cargo project. The cost is that indexes
using other compression algorithms cannot even be loaded (even though they
are not fully accessible in any case).

As a drive-by, this also fixes `--no-default-features` on `cfg(unix)`.
@adamreichold adamreichold force-pushed the compression-feature-gate branch from 72d37fd to f7288b0 Compare July 13, 2023 08:31
@adamreichold
Copy link
Collaborator Author

might actually be enough and neither Brotli nor Snappy add anything substantially different.

I agree. +1 for ditching Brotli and Snappy.

I will propose this as a separate PR then so please see the PR title and can comment further on this.

@fulmicoton fulmicoton merged commit 7e6c4a1 into main Jul 14, 2023
@fulmicoton fulmicoton deleted the compression-feature-gate branch July 14, 2023 02:02
@fulmicoton
Copy link
Collaborator

@adamreichold thank you!

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.

Compression structs etc should be behind a feature gate
3 participants