merge: stream through the spill instead of holding the merged corpus in RAM

Aperta
#289 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
numpy, python

Direzione di ricerca

Start in src/leech/splitting/splitter.py at _merge_arrays_by_split (around lines 391-397) and the read paths near lines 266-268 and 575-577, then the label peek in commands/merge_split.py around lines 245-253. Reuse _SpilledColumn and write_npy_header/_write_rows from chunking/serialization.py. Done means peak RSS is bounded by one block in tests/test_splitter_merge.py::TestMergeMemory, and output stays byte-identical for the same inputs and seed.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement review-2026-09

Tier P3 · effort M · from the 2026-09-13 review (prep F8)

_merge_arrays_by_split (src/leech/splitting/splitter.py:391-397)
preallocates every member of every split at once, so peak RSS ≈ 100% of the
merged payload (36.5 GiB on the production corpus; escapepod-models measured
41–43 GB and reserves 120). tests/test_splitter_merge.py::TestMergeMemory
asserts "near the payload", i.e. this is the accepted design — but the spill
machinery to avoid it already exists (_SpilledColumn,
ChunkSpool.write_npz(rows=...), write_npy_header + _write_rows in
chunking/serialization.py), and the merge plans already know each output
member's shape and each input's row list. Each input's read_ids member is
read twice (:575-577 and :266-268), labels twice (:673-674 and
commands/merge_split.py:245-253, which boxes the whole column into a Python
set). Output goes through np.savez (stored) while prepare defaults to
compressed.

Acceptance criteria
  • _merge_arrays_by_split appends blocks to per-split spills and streams them into the .npz; peak RSS is O(block), measured on the fixture and asserted by TestMergeMemory with the new bound. The single-merge rule from CLAUDE.md is preserved: all four entry points still go through it.
  • Each input member is read once; the label peek uses np.unique on the column.
  • One documented decision on compression for merged files (they are what the loader streams; stored members stream faster), applied consistently.
  • Output is byte-identical to today's for the same inputs and seed (test), including the CSR map and the member-set validation.
Non-goals
  • Changing split assignment or the k-fold logic.
Lingua principale
Python
Stelle
0
Fork
0
Merge medio
11h 17m
PR unite (30g)
23

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rnabioco/leech

Tutte le issue di rnabioco/leech

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.