[contrib] Edit distance match finder #2036
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Turned out to not provide enough utility to make up for the additional CPU usage. Including this in contrib with some light docs in case this becomes interesting again.
The one place where this outperforms zstd-19 for compression ratio consistently is when compressing a small file (<10KB) with a small and similar in content dictionary (a use case which doesn't really exist as far as I can tell). There are very few overlapping matches in those cases so edit distance basically does as good of a job as can be done.
For large files, this is 5-10X slower than zstd-19 and 2-3X worse in terms of compression ratio. I Think most of the loss is in being unable to find overlapping matches.
References:
An O(ND) Difference Algorithm and Its Variations:
http://www.xmailserver.org/diff2.pdf
An Algorithm for Differential File Comparison:
https://www.cs.dartmouth.edu/~doug/diff.pdf
A File Comparison Program:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.189.70&rep=rep1&type=pdf
More information and references on diff algorithms on this page:
https://wiki.c2.com/?DiffAlgorithm