|
1 | | -Announcing Python-Blosc2 4.7.0 |
| 1 | +Announcing Python-Blosc2 4.8.0 |
2 | 2 | ============================== |
3 | 3 |
|
4 | | -We are happy to announce this release, which brings a **DSL → JavaScript JIT |
5 | | -backend** for running compute kernels under WebAssembly/Pyodide, a new helper to |
6 | | -check whether your DSL kernels actually JIT-compile, and a batch of miniexpr |
7 | | -fixes. |
| 4 | +We are happy to announce this release, which brings support for |
| 5 | +**sharing containers safely across processes** — opt-in file locking for |
| 6 | +``SChunk``/``NDArray``/``EmbedStore``/``DictStore``, atomic archive |
| 7 | +replacement, and readers that follow another process's writes — plus a |
| 8 | +couple of data-loss and data-correctness bug fixes worth upgrading for even |
| 9 | +if you don't touch any of the new locking API. |
8 | 10 |
|
9 | 11 | The main highlights are: |
10 | 12 |
|
11 | | -- **DSL → JavaScript backend (``jit_backend="js"``)**: under WebAssembly/Pyodide, |
12 | | - ``@blosc2.dsl_kernel`` kernels can now be transpiled to JavaScript and run via |
13 | | - the browser's JIT. It is the **default there** for transpilable floating-point |
14 | | - kernels (silently falling back to miniexpr for anything it can't handle), and |
15 | | - beats the WASM TinyCC JIT on compute-heavy kernels (e.g. ~2.8x on a Newton |
16 | | - fractal). It supports index/shape symbols (``_i0``/``_n0``/``_ndim``/ |
17 | | - ``_flat_idx``) and integer inputs with a floating-point output. Request it |
18 | | - explicitly with ``compute(jit_backend="js")``; outside WebAssembly that raises. |
19 | | - Native builds are unaffected. |
20 | | - |
21 | | -- **New ``blosc2.validate_dsl_jit()``**: an introspection helper that reports |
22 | | - whether a DSL kernel actually JIT-compiles (vs. silently falling back to the |
23 | | - interpreter) for given operand/output dtypes — without running it on real |
24 | | - data. |
25 | | - |
26 | | -- **miniexpr fixes**: clearer errors for ``;``-joined statements and for |
27 | | - assigning to an input parameter, and a fix for a name collision where DSL |
28 | | - variables named ``out``/``idx``/``nitems``/``inputs``/``output`` clashed with |
29 | | - codegen-internal identifiers and silently fell back to the interpreter. |
30 | | - |
31 | | -A quick taste — run a DSL kernel on the JS backend under Pyodide:: |
32 | | - |
33 | | - @blosc2.dsl_kernel |
34 | | - def k(a, b): |
35 | | - return a * a + b * b |
36 | | - |
37 | | - out = k.compute(operands, jit_backend="js") # JS JIT under WebAssembly |
| 13 | +- **Cross-process locking**: a new ``locking`` storage parameter (and the |
| 14 | + ``BLOSC_LOCKING`` env var to enable it fleet-wide) serializes accesses to an |
| 15 | + on-disk ``SChunk``/``NDArray``/``EmbedStore``/``DictStore`` against other |
| 16 | + handles and processes via a small sidecar lock file. ``holding_lock()`` |
| 17 | + holds the exclusive lock across several operations and now auto-refreshes |
| 18 | + the handle right after acquiring it, so a decision made inside the block |
| 19 | + never acts on a stale in-memory read. |
| 20 | + |
| 21 | +- **Cross-process writes for ``EmbedStore``/``DictStore``** (``.b2d``): under |
| 22 | + locking, one process can add or remove keys while another has the store |
| 23 | + open, and the other side's next lookup sees the change — no need to |
| 24 | + reopen the store. |
| 25 | + |
| 26 | +- **Atomic ``.b2z`` archives**: writing a ``DictStore.to_b2z()`` file (which |
| 27 | + ``TreeStore`` also uses) now swaps the new file in atomically. A process |
| 28 | + reading the archive concurrently always gets either the complete old |
| 29 | + version or the complete new one — never a partially-written file from a |
| 30 | + save that's still in progress. This needs no locking on the reader's side. |
| 31 | + |
| 32 | +- **Growth-SWMR**: a reader ``NDArray`` handle opened before a ``resize()`` |
| 33 | + made through another handle follows the new shape on its next data access, |
| 34 | + or via the new explicit ``NDArray.refresh()`` / ``SChunk.refresh()``. |
| 35 | + |
| 36 | +- **Two bug fixes worth knowing about**: ``NDArray.append()`` could silently |
| 37 | + delete another writer's just-appended data under concurrent growth (fixed |
| 38 | + by refreshing the cached shape before computing the resize target); and |
| 39 | + ``detect_aligned_chunks()`` could silently return the wrong chunk's data |
| 40 | + for an aligned slice on arrays whose shape isn't a multiple of the chunk |
| 41 | + shape (a floor-division bug that undercounted the chunk grid). |
| 42 | + |
| 43 | +- New user guide page, |
| 44 | + `Sharing containers across processes |
| 45 | + <https://www.blosc.org/python-blosc2/getting_started/sharing_across_processes.html>`_, |
| 46 | + covering all of the above plus the caveats (NFS, ``mmap_mode``, Windows |
| 47 | + in-use-file rename). |
| 48 | + |
| 49 | +A quick taste — hold the lock across a read-modify-write from two processes:: |
| 50 | + |
| 51 | + with ndarr.holding_lock(): |
| 52 | + ndarr[:] = ndarr[:] + 1 # atomic w.r.t. other locked handles |
38 | 53 |
|
39 | 54 | Install it with:: |
40 | 55 |
|
|
0 commit comments