Blender Git Loki
Git Commits -> Revision 2ea66af
Revision 2ea66af by Lukas Stockner (master) August 21, 2021, 19:39 (GMT) |
Add support for Zstandard compression for .blend files Compressing blendfiles can help save a lot of disk space, but the slowdown while loading and saving is a major annoyance. Currently Blender uses Zlib (aka gzip aka Deflate) for compression, but there are now several more modern algorithms that outperform it in every way. In this patch, I decided for Zstandard aka Zstd for several reasons: - It is widely supported, both in other programs and libraries as well as in general-purpose compression utilities on Unix - It is extremely flexible - spanning several orders of magnitude of compression speeds depending on the level setting. - It is pretty much on the Pareto frontier for all of its configurations (meaning that no other algorithm is both faster and more efficient). One downside of course is that older versions of Blender will not be able to read these files, but one can always just re-save them without compression or decompress the file manually with an external tool. The implementation here saves additional metadata into the compressed file in order to allow for efficient seeking when loading. This is standard-compliant and will be ignored by other tools that support Zstd. If the metadata is not present (e.g. because you manually compressed a .blend file with another tool), Blender will fall back to sequential reading. Saving is multithreaded to improve performance. Loading is currently not multithreaded since it's not easy to predict the access patterns of the loading code when seeking is supported. In the future, we might want to look into making this more predictable or disabling seeking for the main .blend file, which would then allow for multiple background threads that decompress data ahead of time. The compression level was chosen to get sizes comparable to previous versions at much higher speeds. In the future, this could be exposed as an option. Reviewed By: campbellbarton, brecht, mont29 Differential Revision: https://developer.blender.org/D5799 |
Commit Details:
Full Hash: 2ea66af742bca4b427f88de13254414730a33776
Parent Commit: 2b170f1
Lines Changed: +689, -72
2 Added Paths:
/build_files/cmake/Modules/FindZstd.cmake (+66, -0) (View)
/source/blender/blenlib/intern/filereader_zstd.c (+335, -0) (View)
/source/blender/blenlib/intern/filereader_zstd.c (+335, -0) (View)
12 Modified Paths:
/build_files/cmake/platform/platform_apple.cmake (+3, -0) (Diff)
/build_files/cmake/platform/platform_unix.cmake (+1, -0) (Diff)
/build_files/cmake/platform/platform_win32.cmake (+3, -0) (Diff)
/source/blender/blenlib/BLI_fileops.h (+2, -0) (Diff)
/source/blender/blenlib/BLI_filereader.h (+3, -1) (Diff)
/source/blender/blenlib/CMakeLists.txt (+3, -0) (Diff)
/source/blender/blenlib/intern/fileops.c (+27, -0) (Diff)
/source/blender/blenloader/CMakeLists.txt (+1, -1) (Diff)
/source/blender/blenloader/intern/readfile.c (+9, -0) (Diff)
/source/blender/blenloader/intern/writefile.c (+231, -66) (Diff)
/source/blender/windowmanager/CMakeLists.txt (+0, -4) (Diff)
/source/blender/windowmanager/intern/wm_files.c (+5, -0) (Diff)
/build_files/cmake/platform/platform_unix.cmake (+1, -0) (Diff)
/build_files/cmake/platform/platform_win32.cmake (+3, -0) (Diff)
/source/blender/blenlib/BLI_fileops.h (+2, -0) (Diff)
/source/blender/blenlib/BLI_filereader.h (+3, -1) (Diff)
/source/blender/blenlib/CMakeLists.txt (+3, -0) (Diff)
/source/blender/blenlib/intern/fileops.c (+27, -0) (Diff)
/source/blender/blenloader/CMakeLists.txt (+1, -1) (Diff)
/source/blender/blenloader/intern/readfile.c (+9, -0) (Diff)
/source/blender/blenloader/intern/writefile.c (+231, -66) (Diff)
/source/blender/windowmanager/CMakeLists.txt (+0, -4) (Diff)
/source/blender/windowmanager/intern/wm_files.c (+5, -0) (Diff)