multi_compress 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +116 -0
- data/ext/multi_compress/extconf.rb +171 -0
- data/ext/multi_compress/multi_compress.c +1534 -0
- data/ext/multi_compress/vendor/brotli/c/common/constants.c +15 -0
- data/ext/multi_compress/vendor/brotli/c/common/constants.h +201 -0
- data/ext/multi_compress/vendor/brotli/c/common/context.c +156 -0
- data/ext/multi_compress/vendor/brotli/c/common/context.h +113 -0
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.c +5916 -0
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.h +64 -0
- data/ext/multi_compress/vendor/brotli/c/common/platform.c +23 -0
- data/ext/multi_compress/vendor/brotli/c/common/platform.h +541 -0
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary.c +521 -0
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary_internal.h +75 -0
- data/ext/multi_compress/vendor/brotli/c/common/transform.c +291 -0
- data/ext/multi_compress/vendor/brotli/c/common/transform.h +85 -0
- data/ext/multi_compress/vendor/brotli/c/common/version.h +51 -0
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.c +78 -0
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.h +423 -0
- data/ext/multi_compress/vendor/brotli/c/dec/decode.c +2875 -0
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.c +342 -0
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.h +122 -0
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.h +733 -0
- data/ext/multi_compress/vendor/brotli/c/dec/state.c +183 -0
- data/ext/multi_compress/vendor/brotli/c/dec/state.h +400 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.c +207 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.h +40 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.c +939 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.h +96 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_inc.h +189 -0
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.c +36 -0
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.h +64 -0
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost_inc.h +127 -0
- data/ext/multi_compress/vendor/brotli/c/enc/block_encoder_inc.h +34 -0
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.c +217 -0
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.h +52 -0
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter_inc.h +481 -0
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.c +1336 -0
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.h +89 -0
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.c +57 -0
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.h +49 -0
- data/ext/multi_compress/vendor/brotli/c/enc/cluster_inc.h +325 -0
- data/ext/multi_compress/vendor/brotli/c/enc/command.c +28 -0
- data/ext/multi_compress/vendor/brotli/c/enc/command.h +191 -0
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.c +207 -0
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.h +74 -0
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.c +800 -0
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.h +86 -0
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.c +657 -0
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.h +72 -0
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.c +1848 -0
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.h +25 -0
- data/ext/multi_compress/vendor/brotli/c/enc/encode.c +1996 -0
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.c +640 -0
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.h +157 -0
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.c +504 -0
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.h +123 -0
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode_static.h +542 -0
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.c +105 -0
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.h +67 -0
- data/ext/multi_compress/vendor/brotli/c/enc/find_match_length.h +72 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash.h +728 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_composite_inc.h +140 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +295 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_inc.h +262 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_inc.h +258 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +266 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_rolling_inc.h +212 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +330 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.c +100 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.h +64 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram_inc.h +51 -0
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.c +180 -0
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.h +32 -0
- data/ext/multi_compress/vendor/brotli/c/enc/memory.c +194 -0
- data/ext/multi_compress/vendor/brotli/c/enc/memory.h +131 -0
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.c +677 -0
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.h +106 -0
- data/ext/multi_compress/vendor/brotli/c/enc/metablock_inc.h +185 -0
- data/ext/multi_compress/vendor/brotli/c/enc/params.h +47 -0
- data/ext/multi_compress/vendor/brotli/c/enc/prefix.h +54 -0
- data/ext/multi_compress/vendor/brotli/c/enc/quality.h +202 -0
- data/ext/multi_compress/vendor/brotli/c/enc/ringbuffer.h +168 -0
- data/ext/multi_compress/vendor/brotli/c/enc/state.h +104 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.c +542 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.h +41 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.h +5866 -0
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.c +85 -0
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.h +33 -0
- data/ext/multi_compress/vendor/brotli/c/enc/write_bits.h +88 -0
- data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +409 -0
- data/ext/multi_compress/vendor/brotli/c/include/brotli/encode.h +501 -0
- data/ext/multi_compress/vendor/brotli/c/include/brotli/port.h +305 -0
- data/ext/multi_compress/vendor/brotli/c/include/brotli/shared_dictionary.h +100 -0
- data/ext/multi_compress/vendor/brotli/c/include/brotli/types.h +83 -0
- data/ext/multi_compress/vendor/lz4/lib/LICENSE +24 -0
- data/ext/multi_compress/vendor/lz4/lib/Makefile +244 -0
- data/ext/multi_compress/vendor/lz4/lib/README.md +193 -0
- data/ext/multi_compress/vendor/lz4/lib/dll/example/Makefile +63 -0
- data/ext/multi_compress/vendor/lz4/lib/dll/example/README.md +69 -0
- data/ext/multi_compress/vendor/lz4/lib/dll/example/fullbench-dll.sln +25 -0
- data/ext/multi_compress/vendor/lz4/lib/dll/example/fullbench-dll.vcxproj +182 -0
- data/ext/multi_compress/vendor/lz4/lib/liblz4-dll.rc.in +35 -0
- data/ext/multi_compress/vendor/lz4/lib/liblz4.pc.in +14 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4.c +2829 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4.h +884 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4file.c +341 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4file.h +93 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4frame.c +2136 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4frame.h +751 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4frame_static.h +47 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4hc.c +2192 -0
- data/ext/multi_compress/vendor/lz4/lib/lz4hc.h +414 -0
- data/ext/multi_compress/vendor/lz4/lib/xxhash.c +1030 -0
- data/ext/multi_compress/vendor/lz4/lib/xxhash.h +328 -0
- data/ext/multi_compress/vendor/zstd/lib/BUCK +232 -0
- data/ext/multi_compress/vendor/zstd/lib/Makefile +369 -0
- data/ext/multi_compress/vendor/zstd/lib/README.md +237 -0
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +55 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +200 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +457 -0
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +450 -0
- data/ext/multi_compress/vendor/zstd/lib/common/cpu.h +249 -0
- data/ext/multi_compress/vendor/zstd/lib/common/debug.c +30 -0
- data/ext/multi_compress/vendor/zstd/lib/common/debug.h +116 -0
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +340 -0
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.c +63 -0
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.h +168 -0
- data/ext/multi_compress/vendor/zstd/lib/common/fse.h +640 -0
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +313 -0
- data/ext/multi_compress/vendor/zstd/lib/common/huf.h +286 -0
- data/ext/multi_compress/vendor/zstd/lib/common/mem.h +426 -0
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +371 -0
- data/ext/multi_compress/vendor/zstd/lib/common/pool.h +90 -0
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +158 -0
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +182 -0
- data/ext/multi_compress/vendor/zstd/lib/common/threading.h +150 -0
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.c +18 -0
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.h +7020 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +48 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_deps.h +111 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +392 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_trace.h +163 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/clevels.h +134 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/fse_compress.c +625 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +181 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +75 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +1464 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +7153 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +1534 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.c +235 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.h +39 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +442 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.h +54 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +688 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.h +32 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_cwksp.h +748 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +770 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.h +50 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +968 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.h +38 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +2199 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.h +202 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +730 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +117 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +1576 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.h +80 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +1882 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +113 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +1944 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +595 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +244 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +44 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +2407 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +2215 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.h +73 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +240 -0
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff.h +214 -0
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_common.c +26 -0
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_compress.c +167 -0
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_decompress.c +77 -0
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +1261 -0
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.h +152 -0
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.c +1913 -0
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.h +67 -0
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +766 -0
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +1133 -0
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +48 -0
- data/ext/multi_compress/vendor/zstd/lib/dll/example/README.md +63 -0
- data/ext/multi_compress/vendor/zstd/lib/dll/example/build_package.bat +20 -0
- data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.sln +25 -0
- data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +181 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_legacy.h +452 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +2127 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.h +94 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +3465 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.h +93 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +3105 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.h +93 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +3598 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.h +142 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +4005 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.h +162 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +4106 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.h +172 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +4490 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.h +187 -0
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +237 -0
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +16 -0
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +35 -0
- data/ext/multi_compress/vendor/zstd/lib/zdict.h +474 -0
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +3089 -0
- data/ext/multi_compress/vendor/zstd/lib/zstd_errors.h +114 -0
- data/lib/multi_compress/version.rb +5 -0
- data/lib/multi_compress.rb +329 -0
- metadata +322 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a1afb05d5b335b931383cb6d0cb8102c93609d4e24e8d4a13fb66ab4c8cbd1e9
|
|
4
|
+
data.tar.gz: 945e4407133c1208b86c896be35c5c664568a7f2f8a7b452c13b00caa09700b3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3908089b848102a6cbc4b254fc08612fef8f448f663df8445e988c2ba10dbbb8db6b118c5c00cc9cac663b6e92771138f7f35ebd7c2078bffbf3d55ab4ad492c
|
|
7
|
+
data.tar.gz: 6f8df288d73f7ee0bcd4a6b31bc3ac46a7317b5d917fa0b999fd51baf9c06a8acea25f0f89d76b9e4cd8ae3a6e182fdfafc554585fd09c6dd360e9b76ccc977b
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] — Unreleased
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- One-shot compress/decompress for zstd, lz4, brotli
|
|
7
|
+
- Streaming API: Deflater, Inflater
|
|
8
|
+
- IO wrappers: Writer, Reader with block-style open
|
|
9
|
+
- Dictionary API skeleton (zstd, brotli)
|
|
10
|
+
- Auto-detect algorithm by magic bytes and file extension
|
|
11
|
+
- Named compression levels: :fastest, :default, :best
|
|
12
|
+
- CRC32 / Adler32 utility stubs
|
|
13
|
+
- Algorithm info: `.algorithms`, `.available?`, `.version`
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Roman Haydarov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# MultiCompress 🗜️
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/multi_compress)
|
|
4
|
+
|
|
5
|
+
> **⚠️ PROOF OF CONCEPT** — This is a proof-of-concept implementation. While functional and well-tested, additional features and optimizations are planned before the production-ready release.
|
|
6
|
+
|
|
7
|
+
Modern compression technology: **zstd**, **lz4**, **brotli** — unified compression platform with native C performance.
|
|
8
|
+
|
|
9
|
+
📖 **[Get Started →](GET_STARTED.md)** — Complete technology overview, algorithms, and implementation details
|
|
10
|
+
|
|
11
|
+
## Technology Overview
|
|
12
|
+
|
|
13
|
+
**MultiCompress** is a comprehensive compression system that unites three cutting-edge algorithms in a single platform. Modern algorithms are 3–10x faster than traditional zlib while providing superior compression ratios.
|
|
14
|
+
|
|
15
|
+
| Algorithm | Strength | Best for |
|
|
16
|
+
|-----------|----------|----------|
|
|
17
|
+
| **zstd** | Best speed/ratio balance | Cache, logs, backups |
|
|
18
|
+
| **lz4** | Fastest compress/decompress | IPC, hot cache, real-time |
|
|
19
|
+
| **brotli** | Best ratio for HTTP | Web assets, API responses |
|
|
20
|
+
|
|
21
|
+
## How It Works
|
|
22
|
+
|
|
23
|
+
**MultiCompress** packages modern compression algorithms (zstd, lz4, brotli) with their native C libraries, providing a unified interface. The system includes vendored sources of all compression libraries, eliminating external dependencies.
|
|
24
|
+
|
|
25
|
+
### Key Design Principles
|
|
26
|
+
|
|
27
|
+
- **Zero external dependencies**: All C libraries are vendored and compiled
|
|
28
|
+
- **Unified API**: Same interface for all algorithms — just change the `algo:` parameter
|
|
29
|
+
- **Performance first**: Direct bindings to C libraries, minimal overhead
|
|
30
|
+
- **Memory efficient**: Streaming support for large datasets, proper resource cleanup
|
|
31
|
+
- **Production ready**: Battle-tested error handling, comprehensive test coverage
|
|
32
|
+
|
|
33
|
+
### Algorithm Auto-Detection
|
|
34
|
+
|
|
35
|
+
The system can automatically detect compression algorithms when decompressing data:
|
|
36
|
+
|
|
37
|
+
- **zstd**: Detected by magic bytes `28 B5 2F FD` (little-endian)
|
|
38
|
+
- **lz4**: Detected by internal format header validation (custom format, NOT compatible with lz4 CLI)
|
|
39
|
+
- **brotli**: Requires explicit `algo: :brotli` parameter - no auto-detection
|
|
40
|
+
|
|
41
|
+
**Important**: Auto-detection only works for ZSTD and LZ4. Brotli data must be decompressed with explicit algorithm specification.
|
|
42
|
+
|
|
43
|
+
**Security**: All decompression operations have a built-in 256MB size limit to prevent decompression bomb attacks.
|
|
44
|
+
|
|
45
|
+
## Algorithm Comparison
|
|
46
|
+
|
|
47
|
+
| Algorithm | Speed | Ratio | Best Use Case |
|
|
48
|
+
|-----------|-------|--------|---------------|
|
|
49
|
+
| **lz4** | Fastest | Good | Real-time processing, IPC, hot cache paths |
|
|
50
|
+
| **zstd** | Fast | Excellent | General purpose, logs, backups, web APIs |
|
|
51
|
+
| **brotli** | Slower | Best | Static assets, CDN, long-term storage |
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Benchmark Results
|
|
55
|
+
|
|
56
|
+
Performance comparison against Ruby's built-in zlib compression:
|
|
57
|
+
|
|
58
|
+
### 🗜️ COMPRESSION RATIO (%, lower is better)
|
|
59
|
+
```
|
|
60
|
+
┌─────────────────────────────┬─────────┬─────────┬─────────┬─────────┐
|
|
61
|
+
│ Configuration │ zlib │ lz4 │ zstd │ brotli │
|
|
62
|
+
├─────────────────────────────┼─────────┼─────────┼─────────┼─────────┤
|
|
63
|
+
│ Small JSON (small, GC) │ 8.8% │ 16.2% │ 8.2% │ 6.5% │
|
|
64
|
+
│ Small text (small, GC) │ 11.6% │ 20.0% │ 13.1% │ 11.5% │
|
|
65
|
+
│ Small JSON (small, no GC) │ 8.8% │ 16.2% │ 8.2% │ 6.5% │
|
|
66
|
+
│ Small text (small, no GC) │ 11.6% │ 20.0% │ 13.1% │ 11.5% │
|
|
67
|
+
│ Medium JSON (medium, GC) │ 8.3% │ 15.5% │ 8.9% │ 7.1% │
|
|
68
|
+
│ Medium logs (medium, GC) │ 15.9% │ 26.7% │ 17.9% │ 15.5% │
|
|
69
|
+
│ Medium JSON (medium, no GC) │ 8.3% │ 15.5% │ 8.9% │ 7.1% │
|
|
70
|
+
│ Medium logs (medium, no GC) │ 15.9% │ 26.7% │ 17.9% │ 15.5% │
|
|
71
|
+
└─────────────────────────────┴─────────┴─────────┴─────────┴─────────┘
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### ⚡ PROCESSING SPEED (average time in milliseconds, lower is faster)
|
|
75
|
+
```
|
|
76
|
+
┌─────────────────────────────┬─────────┬─────────┬─────────┬─────────┐
|
|
77
|
+
│ Configuration │ zlib │ lz4 │ zstd │ brotli │
|
|
78
|
+
├─────────────────────────────┼─────────┼─────────┼─────────┼─────────┤
|
|
79
|
+
│ Small JSON (small, GC) │ 0.68 │ 0.20 │ 0.30 │ 1.64 │
|
|
80
|
+
│ Small text (small, GC) │ 2.35 │ 0.68 │ 1.19 │ 6.57 │
|
|
81
|
+
│ Small JSON (small, no GC) │ 0.69 │ 0.19 │ 0.30 │ 1.72 │
|
|
82
|
+
│ Small text (small, no GC) │ 2.32 │ 0.67 │ 1.13 │ 6.45 │
|
|
83
|
+
│ Medium JSON (medium, GC) │ 21.89 │ 6.24 │ 8.58 │ 49.56 │
|
|
84
|
+
│ Medium logs (medium, GC) │ 45.91 │ 11.55 │ 22.47 │ 131.84 │
|
|
85
|
+
│ Medium JSON (medium, no GC) │ 22.90 │ 6.07 │ 8.67 │ 52.25 │
|
|
86
|
+
│ Medium logs (medium, no GC) │ 44.00 │ 10.82 │ 21.56 │ 125.21 │
|
|
87
|
+
└─────────────────────────────┴─────────┴─────────┴─────────┴─────────┘
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
**Dependencies for benchmarking:**
|
|
92
|
+
- `memory_profiler` — Memory usage analysis
|
|
93
|
+
- `benchmark-ips` — Iterations per second benchmarking
|
|
94
|
+
|
|
95
|
+
Or use the build script:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
./build.sh
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Requirements
|
|
102
|
+
|
|
103
|
+
- Ruby >= 2.7.0
|
|
104
|
+
- C compiler (gcc, clang)
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
1. Fork it
|
|
109
|
+
2. Create your feature branch (`git checkout -b feature/my-feature`)
|
|
110
|
+
3. Commit your changes (`git commit -am 'Add feature'`)
|
|
111
|
+
4. Push to the branch (`git push origin feature/my-feature`)
|
|
112
|
+
5. Create a Pull Request
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT — see [LICENSE.txt](LICENSE.txt).
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "mkmf"
|
|
4
|
+
|
|
5
|
+
USE_SYSTEM = arg_config("--use-system-libraries") ||
|
|
6
|
+
ENV["COMPRESS_USE_SYSTEM_LIBRARIES"]
|
|
7
|
+
|
|
8
|
+
ZSTD_SUBDIRS = %w[lib/common lib/multi_compress lib/decompress lib/dictBuilder].freeze
|
|
9
|
+
BROTLI_SUBDIRS = %w[c/common c/enc c/dec].freeze
|
|
10
|
+
LZ4_SOURCES = %w[lz4.c lz4hc.c lz4frame.c].freeze
|
|
11
|
+
|
|
12
|
+
def find_vendor_dir
|
|
13
|
+
candidates = [
|
|
14
|
+
File.join(__dir__, "vendor"),
|
|
15
|
+
File.join(__dir__, "..", "..", "..", "..", "ext", "multi_compress", "vendor"),
|
|
16
|
+
File.expand_path("../../ext/multi_compress/vendor", __dir__),
|
|
17
|
+
File.join(Dir.pwd, "ext", "multi_compress", "vendor"),
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
dir = __dir__
|
|
21
|
+
6.times do
|
|
22
|
+
candidates << File.join(dir, "ext", "multi_compress", "vendor")
|
|
23
|
+
dir = File.dirname(dir)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
candidates.find { |path| File.exist?(File.join(path, ".vendored")) }
|
|
27
|
+
&.then { |path| File.expand_path(path) }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def find_compress_c_dir
|
|
31
|
+
candidates = [
|
|
32
|
+
__dir__,
|
|
33
|
+
File.join(__dir__, "..", "..", "..", "..", "ext", "multi_compress"),
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
dir = __dir__
|
|
37
|
+
6.times do
|
|
38
|
+
candidates << File.join(dir, "ext", "multi_compress")
|
|
39
|
+
dir = File.dirname(dir)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
candidates.find { |path| File.exist?(File.join(path, "multi_compress.c")) }
|
|
43
|
+
&.then { |path| File.expand_path(path) } || __dir__
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def configure_system_libraries
|
|
47
|
+
puts "Building with SYSTEM libraries"
|
|
48
|
+
|
|
49
|
+
configure_homebrew if RUBY_PLATFORM.include?("darwin")
|
|
50
|
+
|
|
51
|
+
require_system_lib("zstd", header: "zstd.h", func: "ZSTD_compress")
|
|
52
|
+
require_system_lib("lz4", header: "lz4.h", func: "LZ4_compress_default")
|
|
53
|
+
require_system_lib("brotli", header: "brotli/encode.h", func: "BrotliEncoderCreateInstance", lib: "brotlienc")
|
|
54
|
+
|
|
55
|
+
have_header("zdict.h")
|
|
56
|
+
have_header("lz4hc.h")
|
|
57
|
+
have_library("lz4", "LZ4_compress_HC")
|
|
58
|
+
have_header("brotli/decode.h")
|
|
59
|
+
have_library("brotlidec", "BrotliDecoderCreateInstance")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def configure_homebrew
|
|
63
|
+
dir_config("homebrew", "/opt/homebrew")
|
|
64
|
+
$CPPFLAGS += " -I/opt/homebrew/include"
|
|
65
|
+
$LDFLAGS += " -L/opt/homebrew/lib"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def require_system_lib(name, header:, func:, lib: name)
|
|
69
|
+
return if have_header(header) && have_library(lib, func)
|
|
70
|
+
|
|
71
|
+
abort "Missing #{name}. Install: apt install lib#{name}-dev / brew install #{name}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def configure_vendored_libraries(vendor_dir)
|
|
75
|
+
versions = File.read(File.join(vendor_dir, ".vendored"))
|
|
76
|
+
puts "Building with VENDORED libraries from #{vendor_dir}"
|
|
77
|
+
puts " #{versions.tr("\n", ", ")}"
|
|
78
|
+
|
|
79
|
+
zstd_dir = File.join(vendor_dir, "zstd")
|
|
80
|
+
lz4_dir = File.join(vendor_dir, "lz4")
|
|
81
|
+
brotli_dir = File.join(vendor_dir, "brotli")
|
|
82
|
+
|
|
83
|
+
all_vendor_srcs = collect_vendor_sources(zstd_dir, lz4_dir, brotli_dir)
|
|
84
|
+
|
|
85
|
+
puts " #{all_vendor_srcs.length} vendored C files"
|
|
86
|
+
|
|
87
|
+
add_include_dirs(zstd_dir, lz4_dir, brotli_dir)
|
|
88
|
+
|
|
89
|
+
vpath_dirs = build_vpath_dirs(zstd_dir, lz4_dir, brotli_dir)
|
|
90
|
+
|
|
91
|
+
deduplicate_sources!(all_vendor_srcs)
|
|
92
|
+
|
|
93
|
+
compress_c_dir = find_compress_c_dir
|
|
94
|
+
|
|
95
|
+
$srcs = ["multi_compress.c"] + all_vendor_srcs.map { |s| File.basename(s) }
|
|
96
|
+
$VPATH = [compress_c_dir] + vpath_dirs
|
|
97
|
+
|
|
98
|
+
$warnflags = ""
|
|
99
|
+
|
|
100
|
+
vpath_dirs
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def collect_vendor_sources(zstd_dir, lz4_dir, brotli_dir)
|
|
104
|
+
zstd_srcs = ZSTD_SUBDIRS.flat_map { |d| Dir[File.join(zstd_dir, d, "*.c")] }
|
|
105
|
+
|
|
106
|
+
lz4_srcs = LZ4_SOURCES.filter_map do |f|
|
|
107
|
+
path = File.join(lz4_dir, "lib", f)
|
|
108
|
+
path if File.exist?(path)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
brotli_srcs = BROTLI_SUBDIRS.flat_map { |d| Dir[File.join(brotli_dir, d, "*.c")] }
|
|
112
|
+
|
|
113
|
+
zstd_srcs + lz4_srcs + brotli_srcs
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def add_include_dirs(zstd_dir, lz4_dir, brotli_dir)
|
|
117
|
+
[
|
|
118
|
+
File.join(zstd_dir, "lib"),
|
|
119
|
+
File.join(zstd_dir, "lib", "common"),
|
|
120
|
+
File.join(lz4_dir, "lib"),
|
|
121
|
+
File.join(brotli_dir, "c", "include"),
|
|
122
|
+
].each { |d| $CPPFLAGS += " -I#{d}" }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def build_vpath_dirs(zstd_dir, lz4_dir, brotli_dir)
|
|
126
|
+
ZSTD_SUBDIRS.map { |d| File.join(zstd_dir, d) } +
|
|
127
|
+
[File.join(lz4_dir, "lib")] +
|
|
128
|
+
BROTLI_SUBDIRS.map { |d| File.join(brotli_dir, d) }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def deduplicate_sources!(sources)
|
|
132
|
+
seen = {}
|
|
133
|
+
|
|
134
|
+
sources.reject! do |src|
|
|
135
|
+
basename = File.basename(src)
|
|
136
|
+
duplicate = seen.key?(basename)
|
|
137
|
+
puts " SKIP duplicate: #{src}" if duplicate
|
|
138
|
+
seen[basename] = true
|
|
139
|
+
duplicate
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def patch_makefile_vpath!(vpath_dirs)
|
|
144
|
+
makefile = File.read("Makefile")
|
|
145
|
+
return if makefile.include?("# vendored vpath")
|
|
146
|
+
|
|
147
|
+
vpath_lines = vpath_dirs.map { |d| "vpath %.c #{d}" }.join("\n")
|
|
148
|
+
|
|
149
|
+
makefile.sub!(/^(VPATH\s*=.*)$/m) { "#{Regexp.last_match(1)}\n# vendored vpath\n#{vpath_lines}" }
|
|
150
|
+
File.write("Makefile", makefile)
|
|
151
|
+
puts " Patched Makefile with #{vpath_dirs.length} VPATH entries"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# --- Main ---
|
|
155
|
+
|
|
156
|
+
VENDOR_DIR = find_vendor_dir
|
|
157
|
+
VENDORED = !VENDOR_DIR.nil?
|
|
158
|
+
|
|
159
|
+
if USE_SYSTEM || !VENDORED
|
|
160
|
+
configure_system_libraries
|
|
161
|
+
vpath_dirs = nil
|
|
162
|
+
else
|
|
163
|
+
vpath_dirs = configure_vendored_libraries(VENDOR_DIR)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
$CFLAGS += " -O2"
|
|
167
|
+
$CFLAGS += " -DXXH_NAMESPACE=MULTICOMPRESS_"
|
|
168
|
+
|
|
169
|
+
create_makefile("multi_compress/multi_compress")
|
|
170
|
+
|
|
171
|
+
patch_makefile_vpath!(vpath_dirs) if VENDORED && !USE_SYSTEM && vpath_dirs
|