Add ZXC compression codec#120662
Open
hellobertrand wants to merge 2 commits into
Open
Conversation
Integrates the ZXC library as a new, optional compression format. This includes: - New build options to enable/disable ZXC and its built-in library. - Build system integration with CPU architecture-specific SIMD optimizations (SSE2, AVX2, AVX512, NEON) for core compression/decompression functions. - API exposure in `Compression` and `FileAccess` classes. - A new project setting for ZXC compression level. - Documentation updates and round-trip tests. - Inclusion of the `zxc` third-party library (BSD-3-clause) and its `rapidhash` dependency (Expat).
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What problem(s) does this PR solve?
Adds ZXC as a new optional compression format, alongside FastLZ, Deflate, Zstandard, gzip and Brotli. ZXC is an asymmetric LZ codec (BSD-3-Clause), optimized for very fast decompression. That fits the engine's "compress once, decompress many times at load" pattern. Full rationale is in the proposal.
Additional information
Compression::MODE_ZXCwith fullcompress/decompress/get_max_compressed_buffer_size.FileAccess.COMPRESSION_ZXC, works fromPackedByteArray.compress()/decompress()andFileAccess.open_compressed().compression/formats/zxc/compression_level(range 1-6, default 3).zxcandbuiltin_zxc, gated by theZXC_ENABLEDdefine.zxc=nobuilds cleanly.zxc_compress.c /zxc_decompress.c/zxc_huffman.care compiled once per ISA variant (sse2/avx2/avx512on x86_64,neonon ARM) and selected at runtime viaCPUID/getauxval. No-march=native, single portable binary.thirdparty/zxc/(v0.12.0), documented inthirdparty/README.mdandCOPYRIGHT.txt(BSD-3-Clause, plus vendoredrapidhashunder Expat/MIT).FileAccess.xml,ProjectSettings.xml) and round-trip unit tests.Benchmark
Standalone harness mirroring the exact Compression calls (zstd level 3, fastlz, zxc). Apple M3, clang -O3, single-threaded, zstd 1.5.7, zxc 0.12.0 (NEON path selected at runtime). Throughput in MB/s (decimal). Every row round-trips.
Structured text
doc/classes/*.xml(8.3 MB)Low-compressibility binary, editor-binary slice (25 MB)
The win is decode speed: zxc-3 is 2x faster than zstd-3 and 4x faster than fastlz. It's a strong FastLZ replacement: better ratio and decode speed. It does not beat Zstandard on ratio or compression speed. Useful range is L1-L5.
Real-world load (Godot engine path)
Loading a serialized
PackedScene(16k-node level, 1.71 MB) through the engine, optimized editor build (dev_build=no optimize=speed), Apple M3:open_compressed)ZXC decodes the scene 4.7x faster than zstd-3 in pure decode, 2.2x faster through the full FileAccessCompressed path. The trade-off: zstd's output is 2.2x smaller. So on slow / cold storage where I/O dominates, the smaller file narrows the gap. ZXC's advantage is largest when data is cached or storage is fast.