Repository navigation
Read sparse blocks of at least 32 MiB; turn off numpy's huge pages - #129
Conversation
Two fixes from the storage and engine probe on the farm's Lustre. - A sparse block reads at least 32 MiB of data and indices (SPARSE_BLOCK_BYTES), whatever --chunk says. At --chunk 1024 a narrow matrix (4.3M x 480) was read 800 KB at a time, and each read waited on the network. On one node, subset --obs of half its cells took 6.4 to 6.9 minutes on main and 1.5 to 2.1 with the floor, at the same peak memory (820 MB). subset, split and the 10x, Visium, Xenium and CellBender conversions all read through fan_out_sparse_matrix. - main turns off numpy's requests for transparent huge pages for the run, and restores them after. On a node with fragmented memory each fault of an array of 4 MiB or more waited on a failed compaction: a 2 GB write had written nothing after 55 minutes, and took 11 seconds with the requests off. A NUMPY_MADVISE_HUGEPAGE the user set is kept. Tests: the floor is read and not exceeded whatever the input; a run turns huge pages off unless the user chose, and restores the setting. The guards of what --chunk sets take the floor away, since their matrices are smaller than it. Docs: the pipelines guide (the floor, a Huge pages section), AGENTS.md, developers.md, STATUS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Test Results (py3.13)3 839 tests 3 827 ✅ 6m 7s ⏱️ Results for commit aad12e4. |
Test Results (py3.12)3 839 tests 3 827 ✅ 9m 21s ⏱️ Results for commit aad12e4. |
Two fixes from a storage and engine probe run on the Sanger farm's Lustre, where
subsetof large h5ad files mostly sat waiting on the filesystem or in the kernel.What changed
Sparse blocks read at least 32 MiB (
SPARSE_BLOCK_BYTESincore/subset.py).sparse_block_entriessized a block as--chunkrows' worth of entries. On a narrow matrix that is a small read: 1,024 rows of 480 genes is about 800 KB ofdataandindices, and on Lustre each read waits on the network._chunk_stepalready uses to copy a dense array.fan_out_sparse_matrixgets it:subset,split, and the 10x, Visium, Xenium and CellBender conversions.mainturns off numpy's requests for transparent huge pages for the run (_small_pages/_restore_pagesincli.py).defrag=madvisethen makes each page fault compact memory directly. On a node whose memory is fragmented, every compaction fails.NUMPY_MADVISE_HUGEPAGEthe user set is kept, and the earlier setting is restored after the run for a caller that runs on (a notebook, a test).Measurements
subset --obsof half the cells of a 6.7 GB store (4.3M × 480, CSR), on Lustre, on one node, two rounds of each build:--chunkThe huge-page fix was measured on the node where it showed up, with a 2 GB write. The two runs were 10 minutes apart:
NUMPY_MADVISE_HUGEPAGE=0, the write took 11 s.The same effect probably explains the large node-to-node spread in earlier runs, for example 14 s against 64 s of system time for the same subset.
For reviewers
--chunkno longer lowers a sparse block below 32 MiB. The floor is a constant, so memory still does not follow the input. A block's temporaries in_SparseOutput.takeare a few times the block, so peak memory can rise by roughly 100–200 MB on matrices where the floor binds. The spatial store showed no change in peak RSS. The release benchmarks will show it on the 50,000 × 20,000 store.test_a_sparse_block_reads_the_floor_whatever_the_inputchecks that the floor is reached and not exceeded asn_obsgrows.test_a_run_asks_numpy_for_no_huge_pages_unless_the_user_chosechecks that huge pages are off during a run unless the user set them, and that the setting is restored afterwards.--chunksets (the F032 block tests, the F091 memory grid, the streamed-growth guard, the write-unit test) now take the floor away with_no_sparse_floor. Their matrices are smaller than 32 MiB and would otherwise be read whole.numpy._core.multiarray._set_madvise_hugepageis private but has been there since numpy 1.20. AnImportErrorleaves the setting alone.STATUS.md:_entries_per_block, which also sizes its CSC buckets) have no floor yet;AGENTS.md,docs/developers.md,STATUS.md. A changelog entry comes with the release.Local runs:
pytest -m perf209 passed;pytest -m "not integration and not perf"3,830 passed.🤖 Generated with Claude Code