Skip to content

Commit 4140943

Browse files
authored
Merge pull request #291 from t20100/update-blosc2
Updated embedded library: c-blosc2 v2.13.0
2 parents b6fdc4d + 2b3d403 commit 4140943

29 files changed

+861
-84
lines changed

doc/information.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ HDF5 compression filters and compression libraries sources were obtained from:
7676
* `hdf5-blosc plugin <https://github.com/Blosc/hdf5-blosc>`_ (v1.0.0)
7777
using `c-blosc <https://github.com/Blosc/c-blosc>`_ (v1.21.5), LZ4, Snappy, ZLib and ZStd.
7878
* hdf5-blosc2 plugin (from `PyTables <https://github.com/PyTables/PyTables/>`_ v3.9.2)
79-
using `c-blosc2 <https://github.com/Blosc/c-blosc2>`_ (v2.12.0), LZ4, ZLib and ZStd.
79+
using `c-blosc2 <https://github.com/Blosc/c-blosc2>`_ (v2.13.0), LZ4, ZLib and ZStd.
8080
* `FCIDECOMP plugin <ftp://ftp.eumetsat.int/pub/OPS/out/test-data/Test-data-for-External-Users/MTG_FCI_Test-Data/FCI_Decompression_Software_V1.0.2>`_ (v1.0.2)
8181
using `CharLS <https://github.com/team-charls/charls>`_
8282
(1.x branch, commit `25160a4 <https://github.com/team-charls/charls/tree/25160a42fb62e71e4b0ce081f5cb3f8bb73938b5>`_).
@@ -93,9 +93,9 @@ HDF5 compression filters and compression libraries sources were obtained from:
9393

9494
Sources of compression libraries shared accross multiple filters were obtained from:
9595

96-
* `LZ4 v1.9.4 <https://github.com/Blosc/c-blosc2/tree/v2.12.0/internal-complibs/lz4-1.9.4>`_
96+
* `LZ4 v1.9.4 <https://github.com/Blosc/c-blosc2/tree/v2.13.0/internal-complibs/lz4-1.9.4>`_
9797
* `Snappy v1.1.10 <https://github.com/google/snappy>`_
98-
* `ZStd v1.5.5 <https://github.com/Blosc/c-blosc2/tree/v2.12.0/internal-complibs/zstd-1.5.5>`_
98+
* `ZStd v1.5.5 <https://github.com/Blosc/c-blosc2/tree/v2.13.0/internal-complibs/zstd-1.5.5>`_
9999
* `ZLib v1.2.13 <https://github.com/Blosc/c-blosc/tree/v1.21.5/internal-complibs/zlib-1.2.13>`_
100100

101101
When compiled with Intel IPP, the LZ4 compression library is replaced with `LZ4 v1.9.3 <https://github.com/lz4/lz4/releases/tag/v1.9.3>`_ patched with a patch from Intel IPP 2021.7.0.

src/c-blosc2/ANNOUNCE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Announcing C-Blosc2 2.12.0
1+
# Announcing C-Blosc2 2.13.0
22
A fast, compressed and persistent binary data store library for C.
33

44
## What is new?
55

6-
Now the `grok` codec is available globally and will be loaded dynamically. See more
7-
info about the codec in our blog post: https://www.blosc.org/posts/blosc2-grok-release/
8-
Furthermore, a new function has been added to get the unidimensional chunk indexes
9-
needed to get the slice of a Blosc2 container.
6+
A new filter for truncating integers has been added. Furthermore, the zstd codec
7+
has been optimized specially when using dicts. And finally, the grok library
8+
will be initialized when loading the plugin. This evicts having to import it in
9+
some use cases.
1010

1111
For more info, please see the release notes in:
1212

src/c-blosc2/RELEASE_NOTES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
Release notes for C-Blosc2
22
==========================
33

4+
Changes from 2.12.0 to 2.13.0
5+
=============================
6+
7+
* Added a new BLOSC_FILTER_INT_TRUNC filter for truncating integers to a
8+
given number of bits. This is useful for compressing integers that are
9+
not using all the bits of the type. See PR #577.
10+
11+
* Optimized zstd, specially when using dicts. See PR #578.
12+
13+
* Initialize grok library when loading the plugin. This is needed for other plugins
14+
to be able to use it without the need of importing the package.
15+
16+
417
Changes from 2.11.3 to 2.12.0
518
=============================
619

src/c-blosc2/bench/trunc_prec_schunk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(void) {
6565
// DELTA makes compression ratio quite worse in this case
6666
//cparams.filters[1] = BLOSC_DELTA;
6767
// BLOSC_BITSHUFFLE is not compressing better and it quite slower here
68-
//cparams.filters[BLOSC_LAST_FILTER - 1] = BLOSC_BITSHUFFLE;
68+
//cparams.filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_BITSHUFFLE;
6969
// Good codec params for this dataset
7070
cparams.compcode = BLOSC_BLOSCLZ;
7171
cparams.clevel = 9;

src/c-blosc2/blosc/blosc-private.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,45 @@ static inline void* load_lib(char *plugin_name, char *libpath) {
274274
return loaded_lib;
275275
}
276276

277+
static inline void swap_store(void *dest, const void *pa, int size) {
278+
uint8_t *pa_ = (uint8_t *) pa;
279+
uint8_t *pa2_ = (uint8_t*)malloc((size_t) size);
280+
int i = 1; /* for big/little endian detection */
281+
char *p = (char *) &i;
282+
283+
if (p[0] == 1) {
284+
/* little endian */
285+
switch (size) {
286+
case 8:
287+
pa2_[0] = pa_[7];
288+
pa2_[1] = pa_[6];
289+
pa2_[2] = pa_[5];
290+
pa2_[3] = pa_[4];
291+
pa2_[4] = pa_[3];
292+
pa2_[5] = pa_[2];
293+
pa2_[6] = pa_[1];
294+
pa2_[7] = pa_[0];
295+
break;
296+
case 4:
297+
pa2_[0] = pa_[3];
298+
pa2_[1] = pa_[2];
299+
pa2_[2] = pa_[1];
300+
pa2_[3] = pa_[0];
301+
break;
302+
case 2:
303+
pa2_[0] = pa_[1];
304+
pa2_[1] = pa_[0];
305+
break;
306+
case 1:
307+
pa2_[0] = pa_[0];
308+
break;
309+
default:
310+
fprintf(stderr, "Unhandled nitems: %d\n", size);
311+
}
312+
}
313+
memcpy(dest, pa2_, size);
314+
free(pa2_);
315+
}
316+
317+
277318
#endif /* BLOSC_BLOSC_PRIVATE_H */

src/c-blosc2/blosc/blosc2.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,11 @@ int fill_codec(blosc2_codec *codec) {
843843
dlclose(lib);
844844
return BLOSC2_ERROR_FAILURE;
845845
}
846+
if (codec->compcode == BLOSC_CODEC_GROK) {
847+
// Initialize grok lib
848+
void (*init_func)(uint32_t, bool) = dlsym(lib, "blosc2_grok_init");
849+
(*init_func)(0, false);
850+
}
846851

847852
return BLOSC2_ERROR_SUCCESS;
848853
}
@@ -1750,8 +1755,7 @@ static int blosc_d(
17501755
}
17511756

17521757
/* The number of compressed data streams for this block */
1753-
if (!dont_split && !leftoverblock && !context->use_dict) {
1754-
// We don't want to split when in a training dict state
1758+
if (!dont_split && !leftoverblock) {
17551759
nstreams = (int32_t)typesize;
17561760
}
17571761
else {
@@ -2599,8 +2603,20 @@ int blosc2_compress_ctx(blosc2_context* context, const void* src, int32_t srcsiz
25992603
dict_maxsize = srcsize / 20;
26002604
}
26012605
void* samples_buffer = context->dest + context->header_overhead;
2602-
unsigned nblocks = 8; // the minimum that accepts zstd as of 1.4.0
2603-
unsigned sample_fraction = 1; // 1 allows to use most of the chunk for training
2606+
unsigned nblocks = (unsigned)context->nblocks;
2607+
int dont_split = (context->header_flags & 0x10) >> 4;
2608+
if (!dont_split) {
2609+
nblocks = nblocks * context->typesize;
2610+
}
2611+
if (nblocks < 8) {
2612+
nblocks = 8; // the minimum that accepts zstd as of 1.4.0
2613+
}
2614+
2615+
// 1 allows to use most of the chunk for training, but it is slower,
2616+
// and it does not always seem to improve compression ratio.
2617+
// Let's use 16, which is faster and still gives good results
2618+
// on test_dict_schunk.c, but this seems very dependent on the data.
2619+
unsigned sample_fraction = 16;
26042620
size_t sample_size = context->sourcesize / nblocks / sample_fraction;
26052621

26062622
// Populate the samples sizes for training the dictionary
@@ -2613,7 +2629,9 @@ int blosc2_compress_ctx(blosc2_context* context, const void* src, int32_t srcsiz
26132629
// Train from samples
26142630
void* dict_buffer = malloc(dict_maxsize);
26152631
BLOSC_ERROR_NULL(dict_buffer, BLOSC2_ERROR_MEMORY_ALLOC);
2616-
int32_t dict_actual_size = (int32_t)ZDICT_trainFromBuffer(dict_buffer, dict_maxsize, samples_buffer, samples_sizes, nblocks);
2632+
int32_t dict_actual_size = (int32_t)ZDICT_trainFromBuffer(
2633+
dict_buffer, dict_maxsize,
2634+
samples_buffer, samples_sizes, nblocks);
26172635

26182636
// TODO: experiment with parameters of low-level fast cover algorithm
26192637
// Note that this API is still unstable. See: https://github.com/facebook/zstd/issues/1599
@@ -2622,7 +2640,9 @@ int blosc2_compress_ctx(blosc2_context* context, const void* src, int32_t srcsiz
26222640
// fast_cover_params.d = nblocks;
26232641
// fast_cover_params.steps = 4;
26242642
// fast_cover_params.zParams.compressionLevel = context->clevel;
2625-
//size_t dict_actual_size = ZDICT_optimizeTrainFromBuffer_fastCover(dict_buffer, dict_maxsize, samples_buffer, samples_sizes, nblocks, &fast_cover_params);
2643+
// size_t dict_actual_size = ZDICT_optimizeTrainFromBuffer_fastCover(
2644+
// dict_buffer, dict_maxsize, samples_buffer, samples_sizes, nblocks,
2645+
// &fast_cover_params);
26262646

26272647
if (ZDICT_isError(dict_actual_size) != ZSTD_error_no_error) {
26282648
BLOSC_TRACE_ERROR("Error in ZDICT_trainFromBuffer(): '%s'."

src/c-blosc2/blosc/stune.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ int split_block(blosc2_context *context, int32_t typesize, int32_t blocksize) {
198198

199199
int compcode = context->compcode;
200200
return (
201-
// Fast codecs like blosclz and lz4 always prefer to always split
202-
((compcode == BLOSC_BLOSCLZ) || (compcode == BLOSC_LZ4)) &&
201+
// Fast codecs like blosclz, lz4 seems to prefer to split
202+
((compcode == BLOSC_BLOSCLZ) || (compcode == BLOSC_LZ4)
203+
// and low levels of zstd too
204+
|| ((compcode == BLOSC_ZSTD) && (context->clevel <= 5))
205+
) &&
203206
// ...but split seems to harm cratio too much when not using shuffle
204207
(context->filter_flags & BLOSC_DOSHUFFLE) &&
205208
(typesize <= MAX_STREAMS) &&

src/c-blosc2/doc/reference/blosc1.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Main API
2020

2121
.. doxygenfunction:: blosc2_set_nthreads
2222

23+
.. doxygentypedef:: blosc_threads_callback
24+
25+
.. doxygenfunction:: blosc2_set_threads_callback
26+
2327
.. doxygenfunction:: blosc1_get_compressor
2428

2529
.. doxygenfunction:: blosc1_set_compressor

src/c-blosc2/doc/reference/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ metainfo to your datasets (metalayers).
1717
:maxdepth: 2
1818
:caption: Contents:
1919

20-
utility
20+
utility_variables
21+
utility_functions
2122
blosc1
2223
context
2324
plugins

src/c-blosc2/doc/reference/metalayers.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ Variable-length metalayers
2929
.. doxygenfunction:: blosc2_vlmeta_update
3030

3131
.. doxygenfunction:: blosc2_vlmeta_get
32+
33+
.. doxygenfunction:: blosc2_vlmeta_delete
34+
35+
.. doxygenfunction:: blosc2_vlmeta_get_names

0 commit comments

Comments
 (0)