c-blosc

Blosc活跃维护

面向数值数组的高性能无损压缩库,通过分块和字节混洗让压缩速度甚至超过 memcpy,适合科学计算和内存数据场景。

A blocking, shuffling and loss-less compression library that can be faster than `memcpy()`.

v1.21.7发布于 2026-10-31 12:42 UTC1,061star174fork同步于 2026-11-10 17:53 UTC

怎么上手

由 README 提炼,执行前请确认
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=your_install_prefix_directory ..
cmake --build . && ctest && cmake --build . --target install
硬件要求按 README 说明

README 未说明显存要求;面向 C89 兼容平台,主要测试 Intel(Linux、Mac OSX、Windows)与 ARM(Linux),可利用 SSE2/AVX2 指令和多核 CPU。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

面向二进制数据的高性能分块压缩库,压缩解压速度可超过 memcpy,用于加速内存受限计算

面向数值数组的高性能无损压缩库,通过分块和字节混洗让压缩速度甚至超过 memcpy,适合科学计算和内存数据场景。

核心能力

  • 按块压缩使数据块适配 CPU 缓存
  • 内置 shuffle 与 bitshuffle 过滤器提升压缩比
  • 可组合 BloscLZ、LZ4、Snappy、Zlib、Zstd 多种编解码器
  • 自动利用 SSE2/AVX2 与多线程加速
  • 以元压缩器方式统一调度过滤器与编解码器

容易踩的坑

项目处于纯维护模式,不再新增功能,新项目应考虑 C-Blosc2;默认内置各编解码器源码,若强制使用外部库需显式设置 PREFER_EXTERNAL_* 选项;Mac OSX 编译前需先执行 xcode-select --install 安装命令行工具。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.21.7
  1. v1.21.7Release 1.21.7最新正式版2026-10-31 · 2026-10-31 12:42 UTC

    Changes from 1.21.6 to 1.21.7

    • Internal LZ4 codec updated to 1.10.0. Thanks to Dimitri Papadopoulos.

    • Security and buffer-validation hardening:

      • Fix out-of-bounds write in blosc_getitem for negative nitems (#406).
      • Reject split blocks not covering blocksize in blosc_d (#407).
      • Reject destsize too small for block pointers in blosc_compress_context (#408). Thanks to Suraiya Sulthana.
    • Clamp destsize to avoid int32 overflow and move getenv("BLOSC_WARN") out of the multi-threaded decompression path (#387, #390). Thanks to @nhz2.

    • Validate that typesize is greater than zero (#395). Thanks to Barak Ugav.

    • Fix compilation with GCC 15 (C23) in internal Zlib (#392). Thanks to Georg Semmler.

    • Add generic RISC-V build support (#403, thanks to @carlosqwqqwq) and enable -std=gnu99 for GCC across all architectures (#399, thanks to Levi Zim).

    • Update minimum CMake version to 3.10 for compatibility with CMake 4.x (#404). Thanks to @mosfet80.

    • Various compiler warning fixes and documentation improvements (#380, #381, #382). Thanks to @nhz2, Dimitri Papadopoulos, and Richard Barnes.

  2. v1.21.6Release 1.21.62024-08-17 · 2024-08-17 16:34 UTC
    查看更新说明

    Changes from 1.21.5 to 1.21.6

    • Zlib updated to 1.3.1. Thanks to Lachlan Deakin.
    • Zstd updated to 1.5.6
    • Fixed many typos. Thanks to Dimitri Papadopoulos.
  3. v1.21.5C-Blosc 1.21.5 released!2023-09-02 · 2023-09-02 07:21 UTC
    查看更新说明

    Changes from 1.21.4 to 1.21.5

    • Fix SSE2/AVX2 build issue. Fixes #352. Thanks to Thomas VINCENT and Mark Kittisopikul.
  4. v1.21.4Release 1.21.42023-05-16 · 2023-05-16 08:38 UTC
    查看更新说明

    Changes from 1.21.3 to 1.21.4

    • Upgrade internal-complib zstd from 1.5.2 to 1.5.5.

    • Zlib updated to 1.2.13.

  5. v1.21.2Release 1.21.22022-12-07 · 2022-12-07 11:21 UTC
    查看更新说明

    Changes from 1.21.1 to 1.21.2

    • Add support for SHUFFLE_AVX2_ENABLED and SHUFFLE_SSE2_ENABLED even if AVX2 or SSE2 is not available. See PR #347. Thanks to Thomas VINCENT.

    • Upgrade internal-complib zstd from 1.5.0 to 1.5.2. Thanks to Mark Kittisopikul.

    • Many small code improvements, improved consistency and typo fixes. Thanks to Dimitri Papadopoulos Orfanos.

    • New HIDE_SYMBOLS CMake option to control the symbols exposure. Default is ON. Thanks to Mariusz Zaborski.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Blosc: A blocking, shuffling and lossless compression library

    AuthorContactURL
    Blosc Development Team[email protected]https://www.blosc.org
    GitterGH ActionsNumFOCUSCode of Conduct
    GitterCI CMakePowered by NumFOCUSContributor Covenant

    What is it?

    Note: This is in pure maintenance mode and will not acquire new features in the future. There is a more modern version of this package called C-Blosc2 which supports many more features and is more actively maintained. Visit it at: https://github.com/Blosc/c-blosc2

    Blosc is a high performance compressor optimized for binary data. It has been designed to transmit data to the processor cache faster than the traditional, non-compressed, direct memory fetch approach via a memcpy() OS call. Blosc is the first compressor (that I'm aware of) that is meant not only to reduce the size of large datasets on-disk or in-memory, but also to accelerate memory-bound computations.

    It uses the blocking technique so as to reduce activity in the memory bus as much as possible. In short, this technique works by dividing datasets in blocks that are small enough to fit in caches of modern processors and perform compression / decompression there. It also leverages, if available, SIMD instructions (SSE2, AVX2) and multi-threading capabilities of CPUs, in order to accelerate the compression / decompression process to a maximum.

    See some benchmarks about Blosc performance.

    Blosc is distributed using the BSD license, see LICENSE.txt for details.

    Meta-compression and other differences over existing compressors

    C-Blosc is not like other compressors: it should rather be called a meta-compressor. This is so because it can use different compressors and filters (programs that generally improve compression ratio). At any rate, it can also be called a compressor because it happens that it already comes with several compressor and filters, so it can actually work like a regular codec.

    Currently C-Blosc comes with support of BloscLZ, a compressor heavily based on FastLZ (https://ariya.github.io/FastLZ/), LZ4 and LZ4HC (https://lz4.org/), Snappy (https://google.github.io/snappy/), Zlib (https://zlib.net/) and Zstandard (https://facebook.github.io/zstd/).

    C-Blosc also comes with highly optimized (they can use SSE2 or AVX2 instructions, if available) shuffle and bitshuffle filters (for info on how and why shuffling works see here). However, additional compressors or filters may be added in the future.

    Blosc is in charge of coordinating the different compressor and filters so that they can leverage the blocking technique as well as multi-threaded execution (if several cores are available) automatically. That makes that every codec and filter will work at very high speeds, even if it was not initially designed for doing blocking or multi-threading.

    Finally, C-Blosc is specially suited to deal with binary data because it can take advantage of the type size meta-information for improved compression ratio by using the integrated shuffle and bitshuffle filters.

    When taken together, all these features set Blosc apart from other compression libraries.

    Compiling the Blosc library

    Blosc can be built, tested and installed using CMake_. The following procedure describes the "out of source" build.

    
      $ cd c-blosc
      $ mkdir build
      $ cd build
    

    Now run CMake configuration and optionally specify the installation directory (e.g. '/usr' or '/usr/local'):

    
      $ cmake -DCMAKE_INSTALL_PREFIX=your_install_prefix_directory ..
    

    CMake allows to configure Blosc in many different ways, like preferring internal or external sources for compressors or enabling/disabling them. Please note that configuration can also be performed using UI tools provided by CMake (ccmake or cmake-gui):

    
      $ ccmake ..      # run a curses-based interface
      $ cmake-gui ..   # run a graphical interface
    

    Build, test and install Blosc:

    
      $ cmake --build .
      $ ctest
      $ cmake --build . --target install
    

    The static and dynamic version of the Blosc library, together with header files, will be installed into the specified CMAKE_INSTALL_PREFIX.

    Codec support with CMake

    C-Blosc comes with full sources for LZ4, LZ4HC, Snappy, Zlib and Zstd and in general, you should not worry about not having (or CMake not finding) the libraries in your system because by default the included sources will be automatically compiled and included in the C-Blosc library. This effectively means that you can be confident in having a complete support for all the codecs in all the Blosc deployments (unless you are explicitly excluding support for some of them).

    But in case you want to force Blosc to use external codec libraries instead of the included sources, you can do that:

    
      $ cmake -DPREFER_EXTERNAL_ZSTD=ON ..
    

    You can also disable support for some compression libraries:

    
      $ cmake -DDEACTIVATE_SNAPPY=ON ..  # in case you don't have a C++ compiler
    

    Examples

    In the examples/ directory you can find hints on how to use Blosc inside your app.

    Supported platforms

    Blosc is meant to support all platforms where a C89 compliant C compiler can be found. The ones that are mostly tested are Intel (Linux, Mac OSX and Windows) and ARM (Linux), but exotic ones as IBM Blue Gene Q embedded "A2" processor are reported to work too.

    Mac OSX troubleshooting

    If you run into compilation troubles when using Mac OSX, please make sure that you have installed the command line developer tools. You can always install them with:

    
      $ xcode-select --install
    

    Wrapper for Python

    Blosc has an official wrapper for Python. See:

    https://github.com/Blosc/python-blosc

    Command line interface and serialization format for Blosc

    Blosc can be used from command line by using Bloscpack. See:

    https://github.com/Blosc/bloscpack

    Filter for HDF5

    For those who want to use Blosc as a filter in the HDF5 library, there is a sample implementation in the hdf5-blosc project in:

    https://github.com/Blosc/hdf5-blosc

    Mailing list

    There is an official mailing list for Blosc at:

    [email protected] https://groups.google.com/g/blosc

    Acknowledgments

    See THANKS.rst.


    Enjoy data!