take/sparse-indexing + b2view#640
Merged
Merged
Conversation
Instead of a fixed max_sparse_refine_candidates cutoff, estimate refinement cost from candidate count × operand count vs scan cost from total rows. Avoids both premature fallback for large but selective queries and pathological refinement of near-full-table predicates. Constants calibrated from profiling with sparse-gather optimisations.
… capacity after arrow import
…. NDArray.take has a new faste path for 1d now.
…boolean condition
The on-disk miniexpr prefilter used a shared b2nd_array_t.chunk_cache buffer that was read on the fast path without holding the lock, while a different worker could concurrently free and replace that same buffer on a cache miss. This led to sporadic SIGSEGV crashes on Apple Silicon, where the weaker memory model and timing made the race visible much more often. In-memory arrays were unaffected because they bypass this path. A previous workaround used per-thread caches, which avoided the crash but made every worker fetch/copy the same on-disk chunk independently. That fixed correctness at the cost of much higher sys time, memory use, and overall runtime. Replace the shared mutable b2nd_array_t.chunk_cache use in miniexpr with a per-input shared cache owned by me_udata. Each cache entry has a small state machine (EMPTY, LOADING, READY, ERROR) plus a lock. The first worker reaching a chunk marks it LOADING, fetches and copies the chunk once, then publishes it as READY; the remaining workers wait briefly and reuse the same immutable chunk buffer. This preserves safe lifetime and restores chunk sharing without duplicated I/O. Also free SChunk with the GIL held again so threadpool teardown cannot race with active miniexpr workers during deallocation. Add a persisted regression test covering repeated a[a < 5][:] on a disk-backed array under multi-threaded execution.
- keep the miniexpr shared chunk-cache fix and replace yield-based waiting
with a blocking lock handoff for safer contention behavior
- pass the requested open mode into reopened NDArray wrappers
- make vlmeta derive access state from its parent SChunk instead of keeping
an independent mode snapshot
- break the new vlmeta->SChunk reference cycle with a weak reference
- make query-result caching hot-cache-only and stop persisting query cache
catalogs or __query_cache__ sidecars in any open mode
- document the no-hidden-writes rule in blosc2.open
- preserve _from_schunk mode/storage state in EmbedStore
- stop upgrading reopened Proxy caches/sources to append mode implicitly
- keep read-only Proxy opens observational by falling back to source reads
when a missing chunk would otherwise require mutating the cache
- update tests for open-mode propagation, read-only metadata behavior,
hot-cache-only query reuse, and read-only proxy reopening
… overall behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR merges two related feature branches into one:
take / sparse-indexing / fancy-indexing
CTable columns
full decompression
repeated queries
Cross-cutting improvements
blosc2.open(...) as obj:
b2view — Interactive Browser for Blosc2 Data
A new CLI viewer (blosc2 view) for interactively exploring Blosc2 objects in the terminal. Built with rich and textual, it supports browsing: