feat: drop rand for in-tree splitmix64 (src/rng.rs). Empirically - #139
Merged
Conversation
output-neutral (completes #118)
Psy-Fer
enabled auto-merge (squash)
July 27, 2026 12:24
Psy-Fer
disabled auto-merge
July 27, 2026 12:24
Psy-Fer
enabled auto-merge (squash)
July 27, 2026 12:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drop the
randdependency for an in-tree splitmix64 RNG (completes #118)Replaces the external
randcrate with a small in-tree deterministic RNG (src/rng.rs, splitmix64). This is #118's original goal — done correctly this time, and only after empirically proving the RNG choice is output-neutralWhy
rustar-aligner's only randomness is tie-breaking and EmptyDrops Monte-Carlo — paths where the exact RNG stream is not STAR-faithful anyway (STAR uses mt19937; we already diverge and report a tie-adjusted metric). What actually matters is determinism (reproducible regardless of thread scheduling), which a fixed-seed splitmix64 gives without pulling in
rand→rand_core→rand_chacha→ppv-lite86→zerocopy. Fewer deps = simpler build and a step toward the pure-Rust / C-toolchain-free goal.#118 (BenjaminDEMAILLE) proposed exactly this but just deleted
randfromCargo.tomlwithout migrating theWeightedIndexusers, so it broke the build. This PR does the migration.Empirical validation (the key point)
Before touching anything, I measured whether the RNG choice changes results, on the mouse 10x set (
test/data/singlecell/,--soloCellFilter EmptyDrops_CR) — the one path claimed to "needrand":So
WeightedIndexis just a cumulative-weight sampler (~15 lines), and removingrandcosts nothing in faithfulness.Changes
src/rng.rs(new):SplitMix64(next_u64/uniform/below),shuffle_deterministic(Fisher–Yates),cumulative_weights+sample_cumulative(WeightedIndex-equivalent). Unit-tested (determinism, range, permutation, weighted distribution).randsites to it:solo/count.rs— EmptyDrops ambient Monte-Carlo sampler.src/bin/emptydrops.rs— standalone binary, same sampler.align/read_align.rs—--outMultimapperOrder Randomtie-break shuffle.lib.rs::pick_primary_and_mapq—--runRNGseedprimary tie-break.#[cfg(test)]inindex/packed_stream.rs.)randfromCargo.toml;rand/rand_core/rand_chacha/ppv-lite86/zerocopyare gone from the dependency tree.Validation
rngunit tests) ·clippy --all-targets0 warnings ·fmtclean.