Skip to content

B6a: Memory harness, then recast streaming #96

Closed

Description

@Claptar

Part of #87.

wave 3 · 0.17.6 · size M · starts after: B1 (#89) (both edit commands/recast.py)

Goal. The perf suite can see memory that --chunk does not bound, and recast stays within it.

Owns: tests/perf_counters.py, tests/test_performance.py, core/recast.py, commands/recast.py

Approach:

  • Do this first. Extend perf_counters to count decoded bytes and peak RSS (in a subprocess). Add wide-matrix and anndata-0.13 sharded Zarr v3 fixtures, and grow n_var as well as n_obs (F091, F146). This harness is what B6b is measured with.
  • Bounding memory:
    • check_cast streams blocks (F029);
    • CSC densify and sparsify use column blocks sized by --chunk (F030);
    • the transpose's pass 2 steps by bytes, not average nnz (F077);
    • densify uses --chunk rows, not the source chunk height (F078).
  • Correctness:
    • the index-dtype overflow check always runs, and --force does not skip it (F013);
    • float16 sparse output that anndata cannot read is refused (F058);
    • explicit zeros are dropped after a lossy cast (F121);
    • nested matrix paths are converted, not copied (F043).

Findings

Ref Sev Finding Where
F013 H --force silently disables the index-dtype overflow check, and dense-to-sparse never runs it, so indptr can wrap src/adata/core/recast.py:752
F029 H recast --dtype on a dense matrix loads the whole matrix (plus cast copies) in check_cast, whatever --chunk is src/adata/core/recast.py:138
F030 H densify and sparsify of CSC allocate n_rows x --chunk per block, so memory scales with n_obs src/adata/core/recast.py:559
F043 M recast of a two-level nested matrix path reports success but copies the matrix unconverted src/adata/commands/recast.py:167
F058 M recast --dtype float16 on a sparse matrix exits 0 ('every value round-trips') but writes a store anndata/scipy cannot read src/adata/core/recast.py:61
F077 M Streaming transpose steps pass 2 by the average nnz per major, so skewed matrices read many times --chunk at once src/adata/core/recast.py:490
F078 M Densifying to CSR/CSC (recast --layout, 10x-h5 export) uses the dense source's chunk row height as the element chunk of data/indices: down … src/adata/core/recast.py:612
F091 M The peak-memory guard uses only an 8-column CSR fixture and grows only n_obs, so it cannot see the paths --chunk does not bound tests/test_performance.py:1634
F121 L Lossy --force cast to a sparse layout from dense keeps entries that became zero src/adata/core/recast.py:625
F146 L The complexity guards count elements and store calls, never decoded bytes, RSS or descriptors, and use only default-chunked fixtures, so … tests/perf_counters.py:60

Done when one PR on fix/b6a closes this, with a regression test against an oracle for every finding, and docs and changelog in the same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions