|
| 1 | +# NEAT v4.4.3 |
| 2 | +Major performance and memory overhaul focused on making NEAT viable for large |
| 3 | +genomes on supercomputing hardware. No user-visible API changes (other than |
| 4 | +chunk size now auto-tuning by default). |
| 5 | + |
| 6 | +**Benchmark (ecoli 10× coverage, 4 threads, identical configs):** |
| 7 | + |
| 8 | +| Metric | v4.4.2 | v4.4.3 | Improvement | |
| 9 | +|-------------------------|------------|------------|-----------------| |
| 10 | +| ecoli SE wall time | 14:55 | 1:35 | 9.4× faster | |
| 11 | +| ecoli PE wall time | 14:46 | 1:35 | 9.4× faster | |
| 12 | +| ecoli SE total CPU | 3,227 s | 331 s | 9.7× less | |
| 13 | +| ecoli PE total CPU | 3,168 s | 338 s | 9.4× less | |
| 14 | +| Peak resident memory | 549 MB | 175 MB | 3.1× less | |
| 15 | +| Peak heap (memray) | 1.27 GB | 0.32 GB | 4× less | |
| 16 | +| Per-worker memory | O(N×cov) | O(1) | bounded | |
| 17 | +| `pysam.sort` calls | 2 | 0 | gone | |
| 18 | +| BAM correctness | 0.06% dups | strict | fixed | |
| 19 | + |
| 20 | +**Versus NEAT 2.1 (single-threaded baseline):** |
| 21 | +- SE: 12:28 → 1:35 (7.9× faster, 56% less CPU) |
| 22 | +- PE: 20:12 → 1:35 (12.8× faster, 72% less CPU) |
| 23 | + |
| 24 | +**Scale-test (c_elegans 10× coverage, 4 threads, 100 Mb genome — ~7× the |
| 25 | +ecoli reference):** |
| 26 | + |
| 27 | +| Metric | Value | |
| 28 | +|-------------------------|---------------------------------------------------------| |
| 29 | +| Wall time | 19:16 | |
| 30 | +| Total CPU | 4,085 s | |
| 31 | +| Peak resident memory | 304 MB | |
| 32 | +| BAM records | 6,685,764 | |
| 33 | +| BAM sort violations | 0 | |
| 34 | +| Stitch step (parallel) | 5.3 s | |
| 35 | +| Auto-tuned chunk size | 3.1 Mb (35 chunks) | |
| 36 | + |
| 37 | +Scaling behavior vs ecoli is ~linear in genome size as expected. The stitch |
| 38 | +step is bounded by raw disk I/O via `pysam.cat`, so it stays at single-digit |
| 39 | +seconds even as the BAM grows. Per-worker peak RSS is 304 MB ÷ 4 ≈ 76 MB, |
| 40 | +which is the reference segment + models — independent of chunk size and |
| 41 | +coverage. |
| 42 | + |
| 43 | +**What changed in the hot path:** |
| 44 | +- Vectorized error sampling in `get_sequencing_errors` — replaced a ~150-iteration |
| 45 | + per-read Python loop with batched numpy. Eliminated 28M `np.prod` calls per |
| 46 | + 185k-read run. |
| 47 | +- Vectorized `get_quality_scores` — replaced per-base scalar `rng.normal` with |
| 48 | + one batched call. |
| 49 | +- Replaced per-read `PairwiseAligner.align()` in `make_cigar` with a direct |
| 50 | + walker that builds the CIGAR from known error/mutation positions in O(L). |
| 51 | + 99% of reads now skip alignment entirely. |
| 52 | +- Rewrote `apply_errors` as a single ascending-position pass. The previous |
| 53 | + implementation did one `np.concatenate` and one `MutableSeq` slice/concat |
| 54 | + per error — quadratic in errors-per-read. The new pass is linear regardless |
| 55 | + of error count. |
| 56 | +- Removed redundant `deepcopy(self.reference_segment)` calls in |
| 57 | + `convert_masking` and `finalize_read_and_write`. Biopython `Seq` is |
| 58 | + immutable; the downstream operations make their own working copies. |
| 59 | + |
| 60 | +**What changed in the I/O path:** |
| 61 | +- Removed both `pysam.sort` calls. Per-worker BAMs are emitted coordinate-sorted |
| 62 | + by construction; `pysam.merge` of sorted inputs already produces sorted output. |
| 63 | + The final sort allocated a 1 GB buffer that dominated peak memory. |
| 64 | +- Replaced `pysam.merge` with `pysam.cat` for the final stitch. cat does a raw |
| 65 | + BGZF concatenation (no decompression / re-encode), bounded by raw disk I/O |
| 66 | + instead of BGZF rate. At human-30× scale this is the difference between a |
| 67 | + multi-hour stitch and a multi-minute one. |
| 68 | +- Each chunk now owns a non-overlapping reference range for read1 placement |
| 69 | + (`responsibility_length`), enabling the cat-based stitch and eliminating |
| 70 | + ~0.06% over-coverage in chunk-overlap regions. |
| 71 | +- Streamed FASTQ and BAM records directly to output during read generation. |
| 72 | + Workers no longer accumulate `reads_to_write` — per-worker memory is now |
| 73 | + bounded by reference segment + models, not by chunk size × coverage. |
| 74 | +- Stitch steps (FASTQ concat, VCF dedup, BAM cat) now run concurrently in |
| 75 | + threads. On a single-disk system the wall is bounded by the BAM cat alone; |
| 76 | + on parallel filesystems the overlap is more pronounced. |
| 77 | +- FASTQ stitch is now byte-level: per-chunk gzip streams are concatenated |
| 78 | + without decompression / re-encode (concatenated gzip streams form a valid |
| 79 | + gzip file per the spec). |
| 80 | + |
| 81 | +**Defaults and ergonomics:** |
| 82 | +- `parallel_block_size` now auto-tunes from genome length and thread count |
| 83 | + (target: ~8 chunks per thread). For small bacterial genomes this matches the |
| 84 | + old hardcoded 500 kb; for human-scale genomes it produces ~6 Mb chunks |
| 85 | + instead of ~500 kb, dramatically reducing stitch overhead. Specify the option |
| 86 | + explicitly to override. |
| 87 | +- FASTQ output is no longer shuffled; reads come out in the natural sampling |
| 88 | + order. Pipe through `seqkit shuffle` if you need a uniform shuffle (documented |
| 89 | + in README). |
| 90 | +- Added a "Multi-node deployment on HPC clusters" section to the README |
| 91 | + showing a SLURM array-job pattern for whole-genome simulation across nodes. |
| 92 | + |
| 93 | +**Caveats:** |
| 94 | +- Several of the vectorization fixes change how the PRNG stream is consumed. |
| 95 | + Same seed will produce statistically equivalent reads, but not bit-identical |
| 96 | + to v4.4.2. Re-baseline any regression tests that compared exact output. |
| 97 | + |
1 | 98 | # NEAT v4.4.2 |
2 | 99 | - Added GC bias modeling to generate reads and a function to create a GC bias model from real data. |
3 | 100 | - Added improvements and efficiency upgrades to generate-reads. |
|
0 commit comments