Update the project name, binary, and all associated documentation, scripts, and configuration files from `obikmer` to `obiskim`. This change ensures consistency across the codebase, including lock files, VCF outputs, benchmark targets, and user-facing documentation. - Update `mkdocs.yml` and `.crate-kit/VERSION` to reflect the new project name and version 0.3.4. - Rename all references in `DevDocMD/` documentation, including architecture, implementation, and theory sections, from `obikmer` to `obiskim`. - Update `UserDocMD/` files to use `.obiskim.lock` and `.obiskim.gate` for lock files, and update VCF contig IDs to `obiskim_<partition>_<layer>`. - Modify `benchmark/` scripts and Makefiles to use `obiskim` binary names and `obiskim_dist/` directories for distribution and comparison tasks. - Update `prompts/` files to reference the `obiskim` repository and commands instead of `obikmer`. - Rename temporary directories in `scripts/` smoke tests from `obikmer_*` to `obiskim_*`. - Update `src/obikphylo/src/siblings/algorithms/alignment_vcf.rs` to use `obiskim` in VCF source identifiers and assertions. - Update `src/obiskim/Cargo.toml` version to 1.4.9 and update `src/obiskim/src/cmd/phylo/args/outputs.rs` documentation. - Update `src/obisys/src/lock.rs` to use `.obiskim.lock`, `.obiskim.gate`, and `.obiskim.promote` file names.
4.5 KiB
Merge: scaling to thousands of genomes (open, 2026-11-17)
Open design question raised during the mmap refactor (merge_mmap_audit.md). Target: merges of ~6 000 genomes of a few Gb each. Nothing here is implemented or measured. Figures are estimates, labelled as such.
What scales with what (after the mmap refactor)
| Cost | Depends on | Status |
|---|---|---|
| Live source layers + dst columns per partition (merge pass 2) | SRC_GROUP × src_n, not the source count |
fixed by plan A |
| Pass-2 column RAM | SRC_GROUP × src_n × N_part × (1/8 | 1) B |
bounded, see below |
| Pass-1 de Bruijn graph | ≥ ~19 B per new k-mer (HashMap<u64, AtomicU8>, verified in obidebruinj/src/debruijn/graph.rs) |
unchanged |
| Columnar intermediate files | n_genomes × n_layers × n_partitions (6 000 × 2 × 256 ≈ 3 M files, estimate) |
does not scale |
Sparse pack |
used to map all columns of a layer at once (ColumnarBitMatrix::open); layers are packed one after another, so n_genomes maps per partition (186 × 192 concurrent ≈ 36 k, estimate) |
fixed 2026-11-17: now goes columnar → dense matrix.pbmx (sequential concatenation, unmapped) → sparse, one mapping per partition |
N_part: k-mers of one dst partition over all layers. Pass-2 column RAM stays below pass-1 graph RAM for one-shot merges. It dominates only for incremental merges, where few genomes are added to a large index: the new layer is small, the existing layers are large. Example (estimate): N_total = 1e12, counts, 192 concurrent partitions → ~1.5 TB. A memory-budgeted concurrency cap is needed there whatever the column strategy. obisys::MemoryBudget exists but is no longer used by merge.
Why a columnar intermediate at all
The sparse format (bitmatrix/sparse.rs) is row-major and deduplicated: per slot, either one genome (singleton.pfiv) or a dict_id (multi.pfiv) into a dictionary of distinct genome sets (dict_offsets + dict_values.bin). Its builder only offers push_row(genomes), i.e. the complete genome set of a row, rows in slot order.
Merge discovers values column by column (source by source), in random slot order (MPHF order). The columnar files are a transposition buffer: they absorb random per-column writes, and pack transposes them row by row.
Options to build the final format directly
-
All sources at once. That is exactly what plan A removed. No.
-
Whole matrix in RAM.
N_part × n_genomes / 8B per partition: ~3 TB at 6 000 genomes andN_part = 4e9(estimate). No. -
External sort of
(slot, genome)pairs. Volume ∝ non-zeros ≈ Σ genome k-mers (~6 000 × 3e9). That is huge, while the final format is small precisely because genome sets repeat. No. -
Incremental sparse update per source group (most promising). Per group:
- fill the group's columns in RAM (as now);
- stream the partition's existing sparse matrix sequentially in slot order;
- for each row: new set = old set ∪ group bits. Through the dictionary this is a transition
(old dict_id, group bit pattern) → new dict_id, which can be memoised in a table; - write the new sparse matrix sequentially, then publish.
No columnar files, no
pack, no per-genome mapping, sequential I/O only. It also removes the re-merge bug: it starts from an existing sparse matrix instead of requiring a columnar one.The cost is one full pass over the partition's sparse matrix per group. With
SRC_GROUP = 2and 6 000 genomes that is 3 000 rewrites, far too many. Groups must therefore be large (64–256 sources), and group column RAM grows with them:group × N_part / 8B, e.g. 32 GB per partition for 64 sources atN_part = 4e9(estimate). One parameter trades passes against RAM, and it should be sized from a memory budget. The count matrix (sparse_intmatrix.rs) has its own format and needs the same analysis.
Related findings
- The module header of
bitmatrix/sparse.rssays "not used by any production code path yet". This is stale:finalize_indexedpacks to sparse by default. - The new layer of a merge is not byte-reproducible run to run: unitig segmentation varies, so the MPHF, evidence and matrix row order vary with it (measured 2026-11-17,
layer_1/*differs in all 256 partitions;layer_0and metadata are identical).obiskim indexshows the same behaviour. Merge oracles therefore compare sorted dumps, not file hashes. Where the non-determinism originates (parallel graph fill or unitig walk) is not established.