@@ -1586,24 +1586,25 @@ def compute_chunks_blocks( # noqa: C901
15861586
15871587 if blocks is None :
15881588 # Get the default blocksize for the compression params
1589- # Using an 8 MB buffer should be enough for detecting the whole range of blocksizes
1590- nitems = 2 ** 23 // itemsize
15911589 # compress2 is used just to provide a hint on the blocksize
15921590 # However, it does not work well with filters that are not shuffle or bitshuffle,
15931591 # so let's get rid of them
1594- filters = cparams .get ("filters" , None )
1595- if filters :
1596- cparams2 = copy .deepcopy (cparams )
1597- for i , filter in enumerate (filters ):
1598- if filter not in (blosc2 .Filter .SHUFFLE , blosc2 .Filter .BITSHUFFLE ):
1599- cparams2 ["filters" ][i ] = blosc2 .Filter .NOFILTER
1600- else :
1601- cparams2 = cparams
1592+ # filters = cparams.get("filters", None)
1593+ # if filters:
1594+ # cparams2 = copy.deepcopy(cparams)
1595+ # for i, filter in enumerate(filters):
1596+ # if filter not in (blosc2.Filter.SHUFFLE, blosc2.Filter.BITSHUFFLE):
1597+ # cparams2["filters"][i] = blosc2.Filter.NOFILTER
1598+ # else:
1599+ # cparams2 = cparams
16021600 # Force STUNE to get a hint on the blocksize
1603- aux_tuner = cparams2 .get ("tuner" , blosc2 .Tuner .STUNE )
1604- cparams2 ["tuner" ] = blosc2 .Tuner .STUNE
1605- src = blosc2 .compress2 (np .zeros (nitems , dtype = f"V{ itemsize } " ), ** cparams2 )
1606- _ , _ , blocksize = blosc2 .get_cbuffer_sizes (src )
1601+ # aux_tuner = cparams2.get("tuner", blosc2.Tuner.STUNE)
1602+ # cparams2["tuner"] = blosc2.Tuner.STUNE
1603+ # src = blosc2.compress2(np.zeros(nitems, dtype=f"V{itemsize}"), **cparams2)
1604+ # _, _, blocksize = blosc2.get_cbuffer_sizes(src)
1605+ # We disable internal STUNE path as it is a bit costly, specially for small arrays.
1606+ # The heuristic below should be good enough in general.
1607+ blocksize = 32 * 1024
16071608 # Minimum blocksize calculation
16081609 min_blocksize = blocksize
16091610 if platform .machine () == "x86_64" :
@@ -1634,7 +1635,9 @@ def compute_chunks_blocks( # noqa: C901
16341635 if blocksize < itemsize :
16351636 blocksize = itemsize
16361637
1637- cparams2 ["tuner" ] = aux_tuner
1638+ # We disable internal STUNE path as it is a bit costly, specially for small arrays.
1639+ # See above.
1640+ # cparams2["tuner"] = aux_tuner
16381641 else :
16391642 blocksize = math .prod (blocks ) * itemsize
16401643
0 commit comments