minbit 3.1.0__tar.gz → 3.2.0__tar.gz

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.
Files changed (42) hide show
  1. {minbit-3.1.0 → minbit-3.2.0}/CHANGELOG.md +20 -0
  2. {minbit-3.1.0 → minbit-3.2.0}/CMakeLists.txt +1 -1
  3. {minbit-3.1.0 → minbit-3.2.0}/PKG-INFO +36 -26
  4. {minbit-3.1.0 → minbit-3.2.0}/README.md +35 -25
  5. {minbit-3.1.0 → minbit-3.2.0}/include/minbit.h +2 -2
  6. {minbit-3.1.0 → minbit-3.2.0}/pyproject.toml +4 -1
  7. {minbit-3.1.0 → minbit-3.2.0}/python/minbit/__init__.py +389 -3
  8. minbit-3.2.0/python/minbit/__main__.py +153 -0
  9. {minbit-3.1.0 → minbit-3.2.0}/python/minbit.egg-info/PKG-INFO +36 -26
  10. {minbit-3.1.0 → minbit-3.2.0}/python/minbit.egg-info/SOURCES.txt +1 -0
  11. minbit-3.2.0/python/minbit.egg-info/entry_points.txt +2 -0
  12. {minbit-3.1.0 → minbit-3.2.0}/python/tests/test_minbit.py +120 -1
  13. {minbit-3.1.0 → minbit-3.2.0}/src/c_api.cpp +1 -1
  14. {minbit-3.1.0 → minbit-3.2.0}/src/codec/minbit_codec.hpp +79 -2
  15. {minbit-3.1.0 → minbit-3.2.0}/src/core/mixer.hpp +274 -0
  16. {minbit-3.1.0 → minbit-3.2.0}/src/core/simd.hpp +85 -1
  17. {minbit-3.1.0 → minbit-3.2.0}/src/core/stream_io.hpp +50 -0
  18. {minbit-3.1.0 → minbit-3.2.0}/src/main.cpp +146 -14
  19. minbit-3.1.0/python/minbit/__main__.py +0 -89
  20. {minbit-3.1.0 → minbit-3.2.0}/FORMAT.md +0 -0
  21. {minbit-3.1.0 → minbit-3.2.0}/LICENSE +0 -0
  22. {minbit-3.1.0 → minbit-3.2.0}/MANIFEST.in +0 -0
  23. {minbit-3.1.0 → minbit-3.2.0}/python/minbit/py.typed +0 -0
  24. {minbit-3.1.0 → minbit-3.2.0}/python/minbit.egg-info/dependency_links.txt +0 -0
  25. {minbit-3.1.0 → minbit-3.2.0}/python/minbit.egg-info/top_level.txt +0 -0
  26. {minbit-3.1.0 → minbit-3.2.0}/setup.cfg +0 -0
  27. {minbit-3.1.0 → minbit-3.2.0}/setup.py +0 -0
  28. {minbit-3.1.0 → minbit-3.2.0}/src/core/arithmetic_coder.hpp +0 -0
  29. {minbit-3.1.0 → minbit-3.2.0}/src/core/bit_history.hpp +0 -0
  30. {minbit-3.1.0 → minbit-3.2.0}/src/core/hash.hpp +0 -0
  31. {minbit-3.1.0 → minbit-3.2.0}/src/core/prob_tables.hpp +0 -0
  32. {minbit-3.1.0 → minbit-3.2.0}/src/core/state_map.hpp +0 -0
  33. {minbit-3.1.0 → minbit-3.2.0}/src/models/context_map.hpp +0 -0
  34. {minbit-3.1.0 → minbit-3.2.0}/src/models/fast_predictor.hpp +0 -0
  35. {minbit-3.1.0 → minbit-3.2.0}/src/models/indirect_model.hpp +0 -0
  36. {minbit-3.1.0 → minbit-3.2.0}/src/models/linear_model.hpp +0 -0
  37. {minbit-3.1.0 → minbit-3.2.0}/src/models/match_model.hpp +0 -0
  38. {minbit-3.1.0 → minbit-3.2.0}/src/models/predictor.hpp +0 -0
  39. {minbit-3.1.0 → minbit-3.2.0}/src/models/record_model.hpp +0 -0
  40. {minbit-3.1.0 → minbit-3.2.0}/src/models/sparse_model.hpp +0 -0
  41. {minbit-3.1.0 → minbit-3.2.0}/src/models/word_model.hpp +0 -0
  42. {minbit-3.1.0 → minbit-3.2.0}/src/transforms/bcj_transform.hpp +0 -0
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to MinBit are documented in this file.
4
4
 
5
+ ## [3.2.0] - 2026-12-06
6
+
7
+ ### x86-64 Runtime CPUID SIMD Dispatch
8
+ - Added zero-overhead **x86-64 runtime CPUID + XGETBV dispatch** (`AVX2` → `SSSE3` → `SSE2`) in `src/core/simd.hpp` and `src/core/mixer.hpp` for GCC, Clang, and MSVC.
9
+ - Portable x86-64 PyPI wheels, GitHub Release binaries, and Homebrew builds (`-DMINBIT_NATIVE_OPT=OFF`) now automatically run at full **AVX2** speed on modern Intel/AMD CPUs while staying 100% compatible with older SSE2 CPUs and 100% bit-for-bit identical across all architectures.
10
+
11
+ ### System-RAM Safety Guard & Live CLI Progress / ETA
12
+ - Added cross-platform physical RAM detection (`sysctlbyname` on macOS, `sysconf` on Linux, `GlobalMemoryStatusEx` on Windows) and automatic **60% physical RAM worker-thread capping** when using `-T0` (preventing accidental OOM with high-memory presets like `-3`/`-4` on smaller hosts).
13
+ - Added explicit `--mem-mb <N>` CLI flag to cap total worker RAM budget across `c`, `d`, `t`, and `bench`.
14
+ - Added thread-safe, 200ms-throttled **live progress & ETA** on `stderr` (automatically active on interactive TTYs, automatically disabled on pipes / `-q` / `--json`, overridable via `--progress` / `--no-progress`).
15
+
16
+ ### Pythonic Stdlib-Grade UX (`minbit.open()` & Console Script)
17
+ - Added stdlib-style `minbit.open(filename, mode="rb"|"wb"|"xb"|"rt"|"wt"|"xt", ...)` supporting bounded-RAM streaming binary and text I/O, existing file-like objects, clean deadlock-free early close, and faithful error propagation (`MinBitCorruptError` / `MinBitLimitError`).
18
+ - Exposed `[project.scripts]` `minbit` console script on `pip install minbit`, upgraded with `-0`..`-4` shorthand preset flags, `-q/--quiet`, and binary `stdin`/`stdout` (`-`) streaming pipe support.
19
+
20
+ ### CI & Documentation Improvements
21
+ - Added a real `homebrew-formula-test` job on `macos-latest` in `.github/workflows/ci.yml` that taps the repo, builds `Formula/minbit.rb` from source (`--HEAD`), and executes `brew test minbit`.
22
+ - Updated `README.md` benchmark tables with explicit thread-count annotations (`1T` vs `MT`/`12T`) and a balanced positioning note vs. LZ codecs and specialized research CM engines.
23
+ - **100% Bitstream Compatible**: Levels `0..4` produce bit-for-bit identical `.mbit` v3 archives to `v3.0.0`/`v3.1.0`.
24
+
5
25
  ## [3.1.0] - 2026-12-06
6
26
 
7
27
  ### Preset `-4` (64 MiB Ultra / Archival Mode)
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.16)
2
- project(minbit VERSION 3.1.0 LANGUAGES C CXX)
2
+ project(minbit VERSION 3.2.0 LANGUAGES C CXX)
3
3
 
4
4
  set(CMAKE_CXX_STANDARD 20)
5
5
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minbit
3
- Version: 3.1.0
3
+ Version: 3.2.0
4
4
  Summary: Cross-platform minimum-bit lossless compression library (Bitwise Context Mixing, format v3)
5
5
  Author: NeiH4207
6
6
  License: MIT License
@@ -55,6 +55,7 @@ Dynamic: license-file
55
55
  # MinBit — Cross-Platform Minimum-Bit Lossless Compressor
56
56
 
57
57
  [![CI](https://github.com/NeiH4207/minbit/actions/workflows/ci.yml/badge.svg)](https://github.com/NeiH4207/minbit/actions/workflows/ci.yml)
58
+ [![PyPI](https://img.shields.io/pypi/v/minbit.svg)](https://pypi.org/project/minbit/)
58
59
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
59
60
  [![Standard: C++20 / C11](https://img.shields.io/badge/Standard-C%2B%2B20%20%7C%20C11-informational.svg)](include/minbit.h)
60
61
  [![Format: .mbit v3](https://img.shields.io/badge/Format-.mbit%20v3-brightgreen.svg)](FORMAT.md)
@@ -70,15 +71,15 @@ Across **all 5 international standard benchmarks** — **Silesia (211.94 MB)**,
70
71
  ### Homebrew (macOS & Linux)
71
72
  ```bash
72
73
  brew tap NeiH4207/minbit https://github.com/NeiH4207/minbit.git
74
+ # brew trust NeiH4207/minbit # if prompted on Homebrew 7+
73
75
  brew install NeiH4207/minbit/minbit
74
76
  ```
75
77
 
76
78
  ### Python (`pip`)
79
+ Prebuilt native wheels for **macOS (ARM64 & Intel)**, **Linux (`manylinux_2_28` x86-64 & aarch64)**, and **Windows (x64)** — zero compiler or runtime dependencies required, with automatic x86-64 runtime **AVX2 / SSSE3 / SSE2** dispatch:
77
80
  ```bash
78
- # Install from source / GitHub (or PyPI once published)
79
- pip install git+https://github.com/NeiH4207/minbit.git
80
- # Verify bundled native library & SIMD backend:
81
- python -m minbit --version
81
+ pip install minbit
82
+ minbit --version
82
83
  ```
83
84
 
84
85
  ### Prebuilt Binaries (macOS ARM64, Linux x86-64, Windows x64)
@@ -88,11 +89,11 @@ Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](
88
89
 
89
90
  ## Key Features
90
91
 
91
- - **100% Bit-Exact Cross-Platform Archives**: An archive compressed on **Windows (x86-64 AVX2/SSE2)**, **Linux (GCC/Clang x86-64/ARM64)**, or **macOS (Apple Silicon ARM64 NEON)** is guaranteed **bit-for-bit identical** and cross-decodable everywhere:
92
- - Unified SIMD [`LogisticMixer`](src/core/mixer.hpp) (`AVX2 _mm256_mulhrs_epi16` == `ARM64 NEON vqrdmulhq_s16` == `SSSE3 _mm_mulhrs_epi16` == scalar `(x * err2 + 16384) >> 15`).
92
+ - **100% Bit-Exact Cross-Platform Archives & Runtime SIMD Dispatch**: An archive compressed on **Windows (x86-64)**, **Linux (GCC/Clang x86-64/ARM64)**, or **macOS (Apple Silicon ARM64 NEON / Intel)** is guaranteed **bit-for-bit identical** and cross-decodable everywhere:
93
+ - Unified SIMD [`LogisticMixer`](src/core/mixer.hpp) (`AVX2 _mm256_mulhrs_epi16` == `ARM64 NEON vqrdmulhq_s16` == `SSSE3 _mm_mulhrs_epi16` == scalar `(x * err2 + 16384) >> 15`), with **automatic x86-64 CPUID runtime dispatch** (`AVX2` → `SSSE3` → `SSE2`) in portable binaries and PyPI wheels.
93
94
  - Self-contained IEEE-754 deterministic `det_exp` / `det_log` / `det_round` in [`src/core/simd.hpp`](src/core/simd.hpp) (no OS `libm` ULP divergence).
94
- - **Streaming Chunked Format (`.mbit` v3) & Security Hardening** ([`src/codec/minbit_codec.hpp`](src/codec/minbit_codec.hpp)):
95
- - Bounded-RAM pipelined multi-threaded compression & decompression for arbitrarily large files and Unix/Windows `stdin`/`stdout` pipes (`-` path).
95
+ - **Streaming Chunked Format (`.mbit` v3), RAM Safety & Security Hardening** ([`src/codec/minbit_codec.hpp`](src/codec/minbit_codec.hpp)):
96
+ - Bounded-RAM pipelined multi-threaded compression & decompression for arbitrarily large files and Unix/Windows `stdin`/`stdout` pipes (`-` path), with **automatic 60% physical RAM thread capping on `-T0`**, explicit `--mem-mb <N>` memory budget, and live `stderr` progress/ETA on interactive terminals.
96
97
  - Header **CRC-16/CCITT**, per-block **IEEE CRC-32**, whole-stream **XXH64** + exact length/block-count footer, hard 64 MiB anti-OOM ceiling, and configurable `--max-out-mb` anti-zip-bomb guard.
97
98
  - Strict bijective per-block ARM64 (`BL`+`ADRP`) and x86 (`E8`/`E9`) BCJ filters ([`src/transforms/bcj_transform.hpp`](src/transforms/bcj_transform.hpp)) + automatic incompressible `RAW` fallback.
98
99
  - **Multi-Modal Adaptive Modeling**:
@@ -100,9 +101,9 @@ Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](
100
101
  - Lexical UTF-8 `WordModel` with unfragmented word/bigram/trigram/skip-bigram, `PrevLine` column alignment, and `<tag>`/bracket nesting ([`src/models/word_model.hpp`](src/models/word_model.hpp)).
101
102
  - Out-of-sample cross-validated modular AMDF row/pixel stride discovery (`sx ∈ {1,2,3,4}`), 6-tap fixed-point 2D NLMS Wiener filter, and **16-bit carry-aware MSB/LSB prediction** for 16-bit medical imagery & PCM audio ([`src/models/record_model.hpp`](src/models/record_model.hpp), [`src/models/linear_model.hpp`](src/models/linear_model.hpp)).
102
103
  - **Pareto Preset Spectrum (`-0` .. `-4`)**:
103
- - `-0` (`FastPredictor`, ~12 MB RAM/thread): matches `zstd -22` / `xz -9e` multi-core compression speed while producing **12%–30% smaller** files.
104
- - `-2` (~58 MB RAM/thread) & `-3` (~210 MB RAM/thread): high-ratio general archival surpassing `zpaq -m5` on Silesia, Canterbury, Calgary, and `enwik8_10m`.
105
- - `-4` (Ultra 64 MiB, ~710 MB RAM/thread): 512 MiB `ContextMap` + 64 MiB sliding window surpassing `zpaq -m5` on **full 100 MB `enwik8`** (`1.5662 bpb`) and `silesia/webster` (`1.0923 bpb`).
104
+ - `-0` (`FastPredictor`, ~16 MB RAM/thread): matches `zstd -22` / `xz -9e` multi-core compression speed while producing **12%–30% smaller** files.
105
+ - `-2` (~68 MB RAM/thread) & `-3` (~224 MB RAM/thread): high-ratio general archival surpassing `zpaq -m5` on Silesia, Canterbury, Calgary, and `enwik8_10m`.
106
+ - `-4` (Ultra 64 MiB, ~740 MB RAM/thread): 512 MiB `ContextMap` + 64 MiB sliding window surpassing `zpaq -m5` on **full 100 MB `enwik8`** (`1.5662 bpb`) and `silesia/webster` (`1.0923 bpb`).
106
107
 
107
108
  ---
108
109
 
@@ -140,9 +141,11 @@ Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](
140
141
  | `xml` | 5,345,280 | 451,540 | 430,566 | 434,900 | 379,649 | 326,945 | 321,563 | 300,645 | **295,212*** |
141
142
  | **TOTAL** | **211,938,580** | 52,363,658 | 49,564,563 | 48,456,100 | 48,035,603 | 39,112,522 | 42,625,116 | 39,764,930 | **38,673,757*** |
142
143
  | **Ratio / bpb** | `100% / 8.00` | `24.71% / 1.98` | `23.39% / 1.87` | `22.86% / 1.83` | `22.66% / 1.81` | `18.45% / 1.48` | `20.11% / 1.61` | `18.76% / 1.50` | **`18.25% / 1.46`** |
143
- | **Enc / Dec MB/s** | — | `2.51 / 573.1` | `0.73 / 268.2` | `2.61 / 112.7` | `9.70 / 8.67` | `0.46 / 0.45` | **`2.40 / 2.11`** | `0.90 / 0.87` | `0.56 / 0.54` |
144
+ | **Enc / Dec MB/s** | — | `2.51 / 573.1` *(1T)* | `0.73 / 268.2` *(1T)* | `2.61 / 112.7` *(1T)* | `9.70 / 8.67` *(1T)* | `0.46 / 0.45` *(MT)* | **`2.40 / 2.11`** *(12T)* | `0.90 / 0.87` *(12T)* | `0.56 / 0.54` *(12T)* |
144
145
 
145
- > **Honest Trade-Off Note**: Context mixing decoders are symmetric with their encoders (`~2.1–4.3 MB/s` multi-core on `-0`, `~0.5–1.6 MB/s` on `-2/-3`), unlike LZ77/LZMA decoders (`110–660 MB/s`). Use MinBit when **minimizing storage/bandwidth bytes** matters most (archival, medical/scientific datasets, release payloads, cold backups).
146
+ > **Honest Positioning & Trade-Offs**:
147
+ > - **vs. LZ77/LZMA codecs (`zstd`, `brotli`, `xz`)**: Context mixing decoders are symmetric with their encoders (`~2.1–4.3 MB/s` multi-core on `-0`, `~0.5–1.6 MB/s` on `-2/-3`; single-thread `-0` is `~0.4–0.6 MB/s`), unlike LZ decoders (`110–660 MB/s`). Throughput numbers in the table above explicitly note thread counts (`1T` vs `MT`/`12T`). Choose LZ codecs for latency-critical hot reads; choose MinBit when **minimizing storage/bandwidth bytes** matters most (archival, medical/scientific datasets, release payloads, cold backups).
148
+ > - **vs. extreme research CM/neural compressors (`paq8px`, `cmix`, `nncp`)**: Specialized multi-GB / multi-hour engines with format-specific preprocessors (JPEG/PDF/DEFLATE/EXE parsers) achieve even higher ratios on Hutter Prize / Silesia, at the cost of much higher RAM, slower speed, and non-embeddable complexity. MinBit targets the practical **embeddable library sweet spot**: zero dependencies, stable C11 ABI + Python wheels, bounded-RAM streaming, multi-core parallelism, and a single general-purpose engine beating `zpaq -m5` across all 5 standard corpora.
146
149
 
147
150
  ---
148
151
 
@@ -184,14 +187,22 @@ if (minbit_compress_alloc(src, src_sz, &comp, &comp_sz, &copt) == MINBIT_OK) {
184
187
  ```
185
188
  Also provides caller-buffer (`minbit_compress_buffer` / `minbit_decompress_buffer`), streaming file (`minbit_compress_file` / `minbit_decompress_file` / `minbit_verify_file`), and custom I/O callback streaming (`minbit_compress_stream_cb` / `minbit_decompress_stream_cb`).
186
189
 
187
- ### Python Package (`python/minbit`)
190
+ ### Python Package (`pip install minbit`)
188
191
  ```python
189
192
  import minbit
190
193
 
194
+ # One-shot bytes API
191
195
  comp = minbit.compress(data, level=2, threads=0)
192
196
  raw = minbit.decompress(comp, max_output_bytes=64 * 1024 * 1024)
193
197
 
194
- # Bounded-RAM streaming files & file-like objects
198
+ # Stdlib-style streaming open() (binary & UTF-8 text modes, bounded RAM)
199
+ with minbit.open("archive.txt.mbit", "wt", level=0, encoding="utf-8") as f:
200
+ f.write("Hello MinBit streaming!\n")
201
+
202
+ with minbit.open("archive.txt.mbit", "rt", encoding="utf-8") as f:
203
+ print(f.read())
204
+
205
+ # Direct C-level bounded-RAM file & integrity verification API
195
206
  stats = minbit.compress_file("scan.dcm", "scan.dcm.mbit", level=0, threads=0)
196
207
  minbit.verify_file("scan.dcm.mbit")
197
208
  minbit.decompress_file("scan.dcm.mbit", "scan_restored.dcm")
@@ -199,24 +210,23 @@ minbit.decompress_file("scan.dcm.mbit", "scan_restored.dcm")
199
210
 
200
211
  ### CLI Examples
201
212
  ```bash
202
- # Fast multi-core compression (matches zstd -22 / xz -9e encode speed, 12–19% smaller files)
203
- ./build/minbit c -0 -T0 input.dat output.mbit
213
+ # Fast multi-core compression (auto RAM-safe threads + live TTY progress/ETA)
214
+ minbit c -0 -T0 input.dat output.mbit
204
215
 
205
- # High-ratio multi-core compression
206
- ./build/minbit c -2 -T0 input.dat output.mbit
216
+ # High-ratio multi-core compression with explicit RAM cap (e.g. 2 GiB budget)
217
+ minbit c -3 -T0 --mem-mb 2048 input.dat output.mbit
207
218
 
208
- # Maximum compression ratio (-3) or Ultra 64 MiB Archival (-4 for enwik8/enwik9)
209
- ./build/minbit c -3 -T0 --block-kb 8192 input.dat output.mbit
210
- ./build/minbit c -4 -T0 enwik8 enwik8.mbit
219
+ # Ultra 64 MiB Archival (-4 for enwik8/enwik9; auto-caps threads to 60% physical RAM)
220
+ minbit c -4 -T0 enwik8 enwik8.mbit
211
221
 
212
222
  # Unix/Windows streaming pipe (bounded RAM for arbitrarily large archives)
213
- tar cf - my_folder/ | ./build/minbit c -0 -T0 - my_folder.tar.mbit
223
+ tar cf - my_folder/ | minbit c -0 -T0 - my_folder.tar.mbit
214
224
 
215
225
  # Decompress with anti-zip-bomb cap (automatically parallelizes across blocks)
216
- ./build/minbit d --max-out-mb 1024 output.mbit restored.dat
226
+ minbit d --max-out-mb 1024 output.mbit restored.dat
217
227
 
218
228
  # Verify archive integrity without writing output
219
- ./build/minbit t output.mbit
229
+ minbit t output.mbit
220
230
  ```
221
231
 
222
232
  ## Documentation & License
@@ -1,6 +1,7 @@
1
1
  # MinBit — Cross-Platform Minimum-Bit Lossless Compressor
2
2
 
3
3
  [![CI](https://github.com/NeiH4207/minbit/actions/workflows/ci.yml/badge.svg)](https://github.com/NeiH4207/minbit/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/minbit.svg)](https://pypi.org/project/minbit/)
4
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
6
  [![Standard: C++20 / C11](https://img.shields.io/badge/Standard-C%2B%2B20%20%7C%20C11-informational.svg)](include/minbit.h)
6
7
  [![Format: .mbit v3](https://img.shields.io/badge/Format-.mbit%20v3-brightgreen.svg)](FORMAT.md)
@@ -16,15 +17,15 @@ Across **all 5 international standard benchmarks** — **Silesia (211.94 MB)**,
16
17
  ### Homebrew (macOS & Linux)
17
18
  ```bash
18
19
  brew tap NeiH4207/minbit https://github.com/NeiH4207/minbit.git
20
+ # brew trust NeiH4207/minbit # if prompted on Homebrew 7+
19
21
  brew install NeiH4207/minbit/minbit
20
22
  ```
21
23
 
22
24
  ### Python (`pip`)
25
+ Prebuilt native wheels for **macOS (ARM64 & Intel)**, **Linux (`manylinux_2_28` x86-64 & aarch64)**, and **Windows (x64)** — zero compiler or runtime dependencies required, with automatic x86-64 runtime **AVX2 / SSSE3 / SSE2** dispatch:
23
26
  ```bash
24
- # Install from source / GitHub (or PyPI once published)
25
- pip install git+https://github.com/NeiH4207/minbit.git
26
- # Verify bundled native library & SIMD backend:
27
- python -m minbit --version
27
+ pip install minbit
28
+ minbit --version
28
29
  ```
29
30
 
30
31
  ### Prebuilt Binaries (macOS ARM64, Linux x86-64, Windows x64)
@@ -34,11 +35,11 @@ Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](
34
35
 
35
36
  ## Key Features
36
37
 
37
- - **100% Bit-Exact Cross-Platform Archives**: An archive compressed on **Windows (x86-64 AVX2/SSE2)**, **Linux (GCC/Clang x86-64/ARM64)**, or **macOS (Apple Silicon ARM64 NEON)** is guaranteed **bit-for-bit identical** and cross-decodable everywhere:
38
- - Unified SIMD [`LogisticMixer`](src/core/mixer.hpp) (`AVX2 _mm256_mulhrs_epi16` == `ARM64 NEON vqrdmulhq_s16` == `SSSE3 _mm_mulhrs_epi16` == scalar `(x * err2 + 16384) >> 15`).
38
+ - **100% Bit-Exact Cross-Platform Archives & Runtime SIMD Dispatch**: An archive compressed on **Windows (x86-64)**, **Linux (GCC/Clang x86-64/ARM64)**, or **macOS (Apple Silicon ARM64 NEON / Intel)** is guaranteed **bit-for-bit identical** and cross-decodable everywhere:
39
+ - Unified SIMD [`LogisticMixer`](src/core/mixer.hpp) (`AVX2 _mm256_mulhrs_epi16` == `ARM64 NEON vqrdmulhq_s16` == `SSSE3 _mm_mulhrs_epi16` == scalar `(x * err2 + 16384) >> 15`), with **automatic x86-64 CPUID runtime dispatch** (`AVX2` → `SSSE3` → `SSE2`) in portable binaries and PyPI wheels.
39
40
  - Self-contained IEEE-754 deterministic `det_exp` / `det_log` / `det_round` in [`src/core/simd.hpp`](src/core/simd.hpp) (no OS `libm` ULP divergence).
40
- - **Streaming Chunked Format (`.mbit` v3) & Security Hardening** ([`src/codec/minbit_codec.hpp`](src/codec/minbit_codec.hpp)):
41
- - Bounded-RAM pipelined multi-threaded compression & decompression for arbitrarily large files and Unix/Windows `stdin`/`stdout` pipes (`-` path).
41
+ - **Streaming Chunked Format (`.mbit` v3), RAM Safety & Security Hardening** ([`src/codec/minbit_codec.hpp`](src/codec/minbit_codec.hpp)):
42
+ - Bounded-RAM pipelined multi-threaded compression & decompression for arbitrarily large files and Unix/Windows `stdin`/`stdout` pipes (`-` path), with **automatic 60% physical RAM thread capping on `-T0`**, explicit `--mem-mb <N>` memory budget, and live `stderr` progress/ETA on interactive terminals.
42
43
  - Header **CRC-16/CCITT**, per-block **IEEE CRC-32**, whole-stream **XXH64** + exact length/block-count footer, hard 64 MiB anti-OOM ceiling, and configurable `--max-out-mb` anti-zip-bomb guard.
43
44
  - Strict bijective per-block ARM64 (`BL`+`ADRP`) and x86 (`E8`/`E9`) BCJ filters ([`src/transforms/bcj_transform.hpp`](src/transforms/bcj_transform.hpp)) + automatic incompressible `RAW` fallback.
44
45
  - **Multi-Modal Adaptive Modeling**:
@@ -46,9 +47,9 @@ Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](
46
47
  - Lexical UTF-8 `WordModel` with unfragmented word/bigram/trigram/skip-bigram, `PrevLine` column alignment, and `<tag>`/bracket nesting ([`src/models/word_model.hpp`](src/models/word_model.hpp)).
47
48
  - Out-of-sample cross-validated modular AMDF row/pixel stride discovery (`sx ∈ {1,2,3,4}`), 6-tap fixed-point 2D NLMS Wiener filter, and **16-bit carry-aware MSB/LSB prediction** for 16-bit medical imagery & PCM audio ([`src/models/record_model.hpp`](src/models/record_model.hpp), [`src/models/linear_model.hpp`](src/models/linear_model.hpp)).
48
49
  - **Pareto Preset Spectrum (`-0` .. `-4`)**:
49
- - `-0` (`FastPredictor`, ~12 MB RAM/thread): matches `zstd -22` / `xz -9e` multi-core compression speed while producing **12%–30% smaller** files.
50
- - `-2` (~58 MB RAM/thread) & `-3` (~210 MB RAM/thread): high-ratio general archival surpassing `zpaq -m5` on Silesia, Canterbury, Calgary, and `enwik8_10m`.
51
- - `-4` (Ultra 64 MiB, ~710 MB RAM/thread): 512 MiB `ContextMap` + 64 MiB sliding window surpassing `zpaq -m5` on **full 100 MB `enwik8`** (`1.5662 bpb`) and `silesia/webster` (`1.0923 bpb`).
50
+ - `-0` (`FastPredictor`, ~16 MB RAM/thread): matches `zstd -22` / `xz -9e` multi-core compression speed while producing **12%–30% smaller** files.
51
+ - `-2` (~68 MB RAM/thread) & `-3` (~224 MB RAM/thread): high-ratio general archival surpassing `zpaq -m5` on Silesia, Canterbury, Calgary, and `enwik8_10m`.
52
+ - `-4` (Ultra 64 MiB, ~740 MB RAM/thread): 512 MiB `ContextMap` + 64 MiB sliding window surpassing `zpaq -m5` on **full 100 MB `enwik8`** (`1.5662 bpb`) and `silesia/webster` (`1.0923 bpb`).
52
53
 
53
54
  ---
54
55
 
@@ -86,9 +87,11 @@ Download CLI + `libminbit` + `include/minbit.h` directly from [GitHub Releases](
86
87
  | `xml` | 5,345,280 | 451,540 | 430,566 | 434,900 | 379,649 | 326,945 | 321,563 | 300,645 | **295,212*** |
87
88
  | **TOTAL** | **211,938,580** | 52,363,658 | 49,564,563 | 48,456,100 | 48,035,603 | 39,112,522 | 42,625,116 | 39,764,930 | **38,673,757*** |
88
89
  | **Ratio / bpb** | `100% / 8.00` | `24.71% / 1.98` | `23.39% / 1.87` | `22.86% / 1.83` | `22.66% / 1.81` | `18.45% / 1.48` | `20.11% / 1.61` | `18.76% / 1.50` | **`18.25% / 1.46`** |
89
- | **Enc / Dec MB/s** | — | `2.51 / 573.1` | `0.73 / 268.2` | `2.61 / 112.7` | `9.70 / 8.67` | `0.46 / 0.45` | **`2.40 / 2.11`** | `0.90 / 0.87` | `0.56 / 0.54` |
90
+ | **Enc / Dec MB/s** | — | `2.51 / 573.1` *(1T)* | `0.73 / 268.2` *(1T)* | `2.61 / 112.7` *(1T)* | `9.70 / 8.67` *(1T)* | `0.46 / 0.45` *(MT)* | **`2.40 / 2.11`** *(12T)* | `0.90 / 0.87` *(12T)* | `0.56 / 0.54` *(12T)* |
90
91
 
91
- > **Honest Trade-Off Note**: Context mixing decoders are symmetric with their encoders (`~2.1–4.3 MB/s` multi-core on `-0`, `~0.5–1.6 MB/s` on `-2/-3`), unlike LZ77/LZMA decoders (`110–660 MB/s`). Use MinBit when **minimizing storage/bandwidth bytes** matters most (archival, medical/scientific datasets, release payloads, cold backups).
92
+ > **Honest Positioning & Trade-Offs**:
93
+ > - **vs. LZ77/LZMA codecs (`zstd`, `brotli`, `xz`)**: Context mixing decoders are symmetric with their encoders (`~2.1–4.3 MB/s` multi-core on `-0`, `~0.5–1.6 MB/s` on `-2/-3`; single-thread `-0` is `~0.4–0.6 MB/s`), unlike LZ decoders (`110–660 MB/s`). Throughput numbers in the table above explicitly note thread counts (`1T` vs `MT`/`12T`). Choose LZ codecs for latency-critical hot reads; choose MinBit when **minimizing storage/bandwidth bytes** matters most (archival, medical/scientific datasets, release payloads, cold backups).
94
+ > - **vs. extreme research CM/neural compressors (`paq8px`, `cmix`, `nncp`)**: Specialized multi-GB / multi-hour engines with format-specific preprocessors (JPEG/PDF/DEFLATE/EXE parsers) achieve even higher ratios on Hutter Prize / Silesia, at the cost of much higher RAM, slower speed, and non-embeddable complexity. MinBit targets the practical **embeddable library sweet spot**: zero dependencies, stable C11 ABI + Python wheels, bounded-RAM streaming, multi-core parallelism, and a single general-purpose engine beating `zpaq -m5` across all 5 standard corpora.
92
95
 
93
96
  ---
94
97
 
@@ -130,14 +133,22 @@ if (minbit_compress_alloc(src, src_sz, &comp, &comp_sz, &copt) == MINBIT_OK) {
130
133
  ```
131
134
  Also provides caller-buffer (`minbit_compress_buffer` / `minbit_decompress_buffer`), streaming file (`minbit_compress_file` / `minbit_decompress_file` / `minbit_verify_file`), and custom I/O callback streaming (`minbit_compress_stream_cb` / `minbit_decompress_stream_cb`).
132
135
 
133
- ### Python Package (`python/minbit`)
136
+ ### Python Package (`pip install minbit`)
134
137
  ```python
135
138
  import minbit
136
139
 
140
+ # One-shot bytes API
137
141
  comp = minbit.compress(data, level=2, threads=0)
138
142
  raw = minbit.decompress(comp, max_output_bytes=64 * 1024 * 1024)
139
143
 
140
- # Bounded-RAM streaming files & file-like objects
144
+ # Stdlib-style streaming open() (binary & UTF-8 text modes, bounded RAM)
145
+ with minbit.open("archive.txt.mbit", "wt", level=0, encoding="utf-8") as f:
146
+ f.write("Hello MinBit streaming!\n")
147
+
148
+ with minbit.open("archive.txt.mbit", "rt", encoding="utf-8") as f:
149
+ print(f.read())
150
+
151
+ # Direct C-level bounded-RAM file & integrity verification API
141
152
  stats = minbit.compress_file("scan.dcm", "scan.dcm.mbit", level=0, threads=0)
142
153
  minbit.verify_file("scan.dcm.mbit")
143
154
  minbit.decompress_file("scan.dcm.mbit", "scan_restored.dcm")
@@ -145,24 +156,23 @@ minbit.decompress_file("scan.dcm.mbit", "scan_restored.dcm")
145
156
 
146
157
  ### CLI Examples
147
158
  ```bash
148
- # Fast multi-core compression (matches zstd -22 / xz -9e encode speed, 12–19% smaller files)
149
- ./build/minbit c -0 -T0 input.dat output.mbit
159
+ # Fast multi-core compression (auto RAM-safe threads + live TTY progress/ETA)
160
+ minbit c -0 -T0 input.dat output.mbit
150
161
 
151
- # High-ratio multi-core compression
152
- ./build/minbit c -2 -T0 input.dat output.mbit
162
+ # High-ratio multi-core compression with explicit RAM cap (e.g. 2 GiB budget)
163
+ minbit c -3 -T0 --mem-mb 2048 input.dat output.mbit
153
164
 
154
- # Maximum compression ratio (-3) or Ultra 64 MiB Archival (-4 for enwik8/enwik9)
155
- ./build/minbit c -3 -T0 --block-kb 8192 input.dat output.mbit
156
- ./build/minbit c -4 -T0 enwik8 enwik8.mbit
165
+ # Ultra 64 MiB Archival (-4 for enwik8/enwik9; auto-caps threads to 60% physical RAM)
166
+ minbit c -4 -T0 enwik8 enwik8.mbit
157
167
 
158
168
  # Unix/Windows streaming pipe (bounded RAM for arbitrarily large archives)
159
- tar cf - my_folder/ | ./build/minbit c -0 -T0 - my_folder.tar.mbit
169
+ tar cf - my_folder/ | minbit c -0 -T0 - my_folder.tar.mbit
160
170
 
161
171
  # Decompress with anti-zip-bomb cap (automatically parallelizes across blocks)
162
- ./build/minbit d --max-out-mb 1024 output.mbit restored.dat
172
+ minbit d --max-out-mb 1024 output.mbit restored.dat
163
173
 
164
174
  # Verify archive integrity without writing output
165
- ./build/minbit t output.mbit
175
+ minbit t output.mbit
166
176
  ```
167
177
 
168
178
  ## Documentation & License
@@ -24,7 +24,7 @@ extern "C" {
24
24
  */
25
25
 
26
26
  #define MINBIT_VERSION_MAJOR 3
27
- #define MINBIT_VERSION_MINOR 1
27
+ #define MINBIT_VERSION_MINOR 2
28
28
  #define MINBIT_VERSION_PATCH 0
29
29
 
30
30
  #define MINBIT_FORMAT_VERSION 3u
@@ -92,7 +92,7 @@ typedef struct minbit_stats {
92
92
 
93
93
  typedef struct minbit_header_info {
94
94
  uint32_t format_version; /* 1, 2, or 3 */
95
- int level; /* 0..3 */
95
+ int level; /* 0..4 */
96
96
  uint32_t max_block_size; /* v3 max block size (0 for v1/v2) */
97
97
  uint64_t original_size_hint; /* populated for legacy v1/v2; 0 for streaming v3 */
98
98
  } minbit_header_info_t;
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "minbit"
7
- version = "3.1.0"
7
+ version = "3.2.0"
8
8
  description = "Cross-platform minimum-bit lossless compression library (Bitwise Context Mixing, format v3)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -32,6 +32,9 @@ classifiers = [
32
32
  ]
33
33
  dependencies = []
34
34
 
35
+ [project.scripts]
36
+ minbit = "minbit.__main__:main"
37
+
35
38
  [project.urls]
36
39
  Homepage = "https://github.com/NeiH4207/minbit"
37
40
  Repository = "https://github.com/NeiH4207/minbit"